diff --git a/client/main.lua b/client/main.lua
index 74052db..30721a3 100644
--- a/client/main.lua
+++ b/client/main.lua
@@ -10,6 +10,7 @@ end)
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
Utils.createBlips()
+ print('[INFO] Resource started')
_Loaded = true
end
end)
diff --git a/client/testDrive.lua b/client/testDrive.lua
new file mode 100644
index 0000000..d56af60
--- /dev/null
+++ b/client/testDrive.lua
@@ -0,0 +1,56 @@
+local testDriving = false
+local testVehicle
+local testShop
+
+RegisterNUICallback('testDrive', function(data, cb)
+ ESX.TriggerServerCallback('h-vshop:testDrive', function(success)
+ print(success)
+ if success then
+ testDriving = true
+ local shop = Utils.getShop()
+ testShop = shop
+
+ if shop then
+ local sPos = shop.delivery.pos
+ local sHeading = shop.delivery.heading
+ ESX.Game.SpawnLocalVehicle(data.vehicle, sPos, heading, function(vehicle)
+ testVehicle = vehicle
+ print('Test vehicle spawned: '..vehicle)
+ end)
+ Wait(100)
+ SetPedIntoVehicle(PlayerPedId(), testVehicle, -1)
+ StartTestTimer()
+ end
+ cb(true)
+ else
+ cb(false)
+ end
+ end, data.vehicle)
+end)
+
+RegisterNUICallback('stopTestDrive', function(data, cb)
+ if testDriving then
+ testDriving = false
+ SendNUIMessage({
+ type = 'stopTimer',
+ })
+ ESX.Game.DeleteVehicle(testVehicle)
+ SetEntityCoords(PlayerPedId(), testShop.pos)
+ ESX.TriggerServerCallback('h-vshop:removeBucket', function(success)
+ if not success then
+ print('Failed to remove bucket')
+ end
+ end)
+ cb(true)
+ else
+ cb(false)
+ end
+end)
+
+local testTime = Config.TestTime
+StartTestTimer = function ()
+ SendNUIMessage({
+ type = 'startTimer',
+ time = testTime
+ })
+end
\ No newline at end of file
diff --git a/client/utils.lua b/client/utils.lua
index c218cd2..86e0bf6 100644
--- a/client/utils.lua
+++ b/client/utils.lua
@@ -60,7 +60,7 @@ Utils.openShop = function ()
type = 'open',
shop = shop,
cars = cars,
- translation = Config.Translation
+ translation = Config.Translation,
})
SetNuiFocus(true, true)
end
@@ -77,6 +77,22 @@ Utils.deleteVehicle = function()
end
end
+Utils.loadModel = function(model)
+ RequestModel(model)
+
+ while not HasModelLoaded(model) do
+ Wait(1)
+ end
+
+ print('Loading Completed')
+
+ SendNUIMessage({
+ type = 'loadingDone'
+ })
+
+ return true
+end
+
Utils.spawnShowcase = function(vehicle)
local shop = Utils.getShop()
local pos = shop.preview
@@ -88,6 +104,12 @@ Utils.spawnShowcase = function(vehicle)
if not cars then return end
if pos then
+
+ local loaded = Utils.loadModel(cars[1].model)
+ while not loaded do
+ Wait(1)
+ end
+
if not currentVeh and not vehicle then
ESX.Game.SpawnLocalVehicle(cars[1].model, vector3(pos.x, pos.y, pos.z), heading, function(vehicle)
currentVeh = vehicle
@@ -123,6 +145,7 @@ end
Utils.spawnVehicle = function(model, plate)
local shop = Utils.getShop()
+
if shop then
local sPos = shop.delivery.pos
local sHeading = shop.delivery.heading
@@ -148,12 +171,24 @@ Utils.spawnVehicle = function(model, plate)
end
Utils.getShopVehicles = function (category)
- local vehicles = {}
- for k,v in pairs(Config.Vehicles) do
- if v.category == category then
- vehicles[#vehicles+1] = v
+ if type(category) == "table" then
+ local vehicles = {}
+ for i = 1, #category do
+ local name = category[i]
+ for _,v in pairs(Config.Vehicles) do
+ if v.category == name then
+ vehicles[#vehicles+1] = v
+ end
+ end
end
+ return vehicles or nil
+ else
+ local vehicles = {}
+ for k,v in pairs(Config.Vehicles) do
+ if v.category == category then
+ vehicles[#vehicles+1] = v
+ end
+ end
+ return vehicles
end
-
- return vehicles
end
\ No newline at end of file
diff --git a/fxmanifest.lua b/fxmanifest.lua
index 67d3f05..c03c07c 100644
--- a/fxmanifest.lua
+++ b/fxmanifest.lua
@@ -2,6 +2,8 @@ fx_version 'adamant'
game 'gta5'
+lua54 'yes'
+
server_scripts {
'@oxmysql/lib/MySQL.lua',
'server/*.lua',
@@ -17,6 +19,7 @@ shared_scripts {
}
ui_page 'web/dist/index.html'
+--ui_page 'http://localhost:3000/'
files {
'web/dist/**'
diff --git a/server/callbacks.lua b/server/callbacks.lua
index 2a54407..0e38b23 100644
--- a/server/callbacks.lua
+++ b/server/callbacks.lua
@@ -1,5 +1,7 @@
local shop = {}
+local inUseBuckets = {}
+
ESX.RegisterServerCallback('esx_vehicleshop:isPlateTaken', function(source, cb, plate)
MySQL.scalar('SELECT plate FROM owned_vehicles WHERE plate = ?', {plate},
function(result)
@@ -33,6 +35,30 @@ ESX.RegisterServerCallback('h-vshop:setOwned', function(source, cb, props)
end
end)
+ESX.RegisterServerCallback('h-vshop:testDrive', function (source, cb, model)
+ local bucketSet = shop.testDrive(source, model)
+
+ if bucketSet then
+ cb(true)
+ else
+ cb(false)
+ end
+end)
+
+ESX.RegisterServerCallback('h-vshop:removeBucket', function (source, cb, bucket)
+ if source ~= nil and source ~= -1 then
+ local bucket = GetPlayerRoutingBucket(source)
+
+ if bucket ~= 0 then
+ SetPlayerRoutingBucket(source, 0)
+ inUseBuckets[bucket] = nil
+ cb(true)
+ else
+ cb(false)
+ end
+ end
+end)
+
function shop.setOwned(source, props)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
@@ -62,19 +88,30 @@ function shop.purchaseCar(source,model, plate)
TriggerClientEvent('esx:showNotification', source, 'Sorry but you need: $' .. vPrice .. ' to purchase a ' .. vehicle.name)
return false
end
- elseif Config.Payment == 'money' then
- local money = xPlayer.getMoney()
- if money >= vPrice then
- xPlayer.removeMoney(vPrice)
- TriggerClientEvent('esx:showNotification', source, 'You have purchased a ' .. vehicle.name .. ' for $' .. vPrice)
+ end
+ else
+ print('Issues finding the vehicle from the config.lua file!')
+ end
+end
+
+function shop.testDrive(source, model)
+ local car = findCarByModel(model)
+ if source ~= -1 or source ~= nil and car then
+ local bucket = GetPlayerRoutingBucket(source)
+
+ if bucket == 0 then
+ local r = math.random(400, 900)
+ if not inUseBuckets[r] then
+ inUseBuckets[r] = true
+ SetPlayerRoutingBucket(source, r)
+ Player(source).state.bucket = r
return true
else
- TriggerClientEvent('esx:showNotification', source, 'Sorry but you need: $' .. vPrice .. ' to purchase a ' .. vehicle.name)
return false
end
+ else
+ return false
end
- else
- print('Issues finding the vehicle from the config.lua file!')
end
end
@@ -88,3 +125,16 @@ function findCarByModel(model)
return false
end
+
+local Debug = false
+
+if Debug then
+ RegisterCommand('getPlayerBucket', function(source)
+ local bucket = GetPlayerRoutingBucket(source)
+ print('Bucket: ' .. bucket)
+ end)
+
+ RegisterCommand('resetPlayerBucket', function (source)
+ SetPlayerRoutingBucket(source, 0)
+ end)
+end
\ No newline at end of file
diff --git a/shared/config.lua b/shared/config.lua
index e167d40..d8ff971 100644
--- a/shared/config.lua
+++ b/shared/config.lua
@@ -5,6 +5,7 @@ Config.PlateLetters = 3
Config.PlateNumbers = 3
Config.PlateUseSpace = true
Config.Payment = 'bank'
+Config.TestTime = 30 -- Sekundes Nahui!
-- This table is used to configure different shops!
Config.Shops = {
@@ -13,7 +14,7 @@ Config.Shops = {
description = 'At our dealership you can find only premium quality vehicles that are brand new and not used!',
pos = vec3(-33.942856, -1102.008789, 26.415405), -- Vec3(x, y, z)
preview = vec3(-43.279121, -1099.938477, 26.415405), previewHeading = 68.031494, -- Vec3(x, y, z)
- category = 'sports', -- Vehicle Category
+ category = {'sports', 'suv', 'bmw', 'audi'}, -- Vehicle Category you can have a table of categories or a string example: 'sports' or {'sports', 'offroad'} don't remove X from the categories list!
blip = { -- Blip Settings
color = 3,
sprite = 355,
diff --git a/web/dist/index.html b/web/dist/index.html
index 0a8f2f1..55948ef 100644
--- a/web/dist/index.html
+++ b/web/dist/index.html
@@ -2,11 +2,11 @@
+
+
+
\ No newline at end of file
diff --git a/web/src/views/Home.vue b/web/src/views/Home.vue
new file mode 100644
index 0000000..c4a1308
--- /dev/null
+++ b/web/src/views/Home.vue
@@ -0,0 +1,16 @@
+
+