mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 13:01:34 +00:00
Fixed #53, minor improvements
This commit is contained in:
+17
-1
@@ -1,6 +1,7 @@
|
||||
ESX = nil
|
||||
local Categories = {}
|
||||
local Vehicles = {}
|
||||
local hasSqlRun = false
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
@@ -14,7 +15,13 @@ function RemoveOwnedVehicle (plate)
|
||||
})
|
||||
end
|
||||
|
||||
AddEventHandler('onMySQLReady', function ()
|
||||
AddEventHandler('onMySQLReady', function()
|
||||
LoadVehicles()
|
||||
end)
|
||||
|
||||
function LoadVehicles()
|
||||
hasSqlRun = true
|
||||
|
||||
Categories = MySQL.Sync.fetchAll('SELECT * FROM vehicle_categories')
|
||||
local vehicles = MySQL.Sync.fetchAll('SELECT * FROM vehicles')
|
||||
|
||||
@@ -30,6 +37,15 @@ AddEventHandler('onMySQLReady', function ()
|
||||
|
||||
table.insert(Vehicles, vehicle)
|
||||
end
|
||||
end
|
||||
|
||||
-- extremely useful when restarting script mid-game
|
||||
Citizen.CreateThread(function()
|
||||
Citizen.Wait(100) -- hopefully enough for connection to the SQL server
|
||||
|
||||
if not hasSqlRun then
|
||||
LoadVehicles()
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_vehicleshop:setVehicleOwned')
|
||||
|
||||
Reference in New Issue
Block a user