Fixed #54, fixed starting script from server boot

This commit is contained in:
ElPumpo
2018-07-25 11:38:35 +02:00
parent 6a4ccf0cd7
commit a2f6061e3c
3 changed files with 19 additions and 7 deletions
+11 -3
View File
@@ -10,7 +10,6 @@ local Keys = {
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}
local GUI = {}
local HasAlreadyEnteredMarker = false
local LastZone = nil
local CurrentAction = nil
@@ -23,7 +22,6 @@ local LastVehicles = {}
local CurrentVehicleData = nil
ESX = nil
GUI.Time = 0
Citizen.CreateThread(function ()
while ESX == nil do
@@ -31,7 +29,7 @@ Citizen.CreateThread(function ()
Citizen.Wait(0)
end
Citizen.Wait(300)
Citizen.Wait(5000)
ESX.TriggerServerCallback('esx_vehicleshop:getCategories', function (categories)
Categories = categories
@@ -56,6 +54,16 @@ Citizen.CreateThread(function ()
end
end)
RegisterNetEvent('esx_vehicleshop:sendCategories')
AddEventHandler('esx_vehicleshop:sendCategories', function (categories)
Categories = categories
end)
RegisterNetEvent('esx_vehicleshop:sendVehicles')
AddEventHandler('esx_vehicleshop:sendVehicles', function (vehicles)
Vehicles = vehicles
end)
function DeleteShopInsideVehicles ()
while #LastVehicles > 0 do
local vehicle = LastVehicles[1]
+3 -3
View File
@@ -27,9 +27,9 @@ CREATE TABLE `cardealer_vehicles` (
);
CREATE TABLE `owned_vehicles` (
`owner` varchar(30) DEFAULT NULL,
`plate` varchar(12) DEFAULT NULL,
`vehicle` longtext DEFAULT NULL,
`owner` varchar(30) NOT NULL,
`plate` varchar(12) NOT NULL,
`vehicle` longtext,
PRIMARY KEY (`plate`)
);
+5 -1
View File
@@ -37,11 +37,15 @@ function LoadVehicles()
table.insert(Vehicles, vehicle)
end
-- send information after db has loaded, making sure everyone gets vehicle information
TriggerClientEvent('esx_vehicleshop:sendCategories', -1, Categories)
TriggerClientEvent('esx_vehicleshop:sendVehicles', -1, Vehicles)
end
-- extremely useful when restarting script mid-game
Citizen.CreateThread(function()
Citizen.Wait(100) -- hopefully enough for connection to the SQL server
Citizen.Wait(10000) -- hopefully enough for connection to the SQL server
if not hasSqlRun then
LoadVehicles()