Hello I am working on a garage script to work with a menu and its not working correctly and work wondering if I could get some help. when I open the menu it will show the cars but flashes/flickers and changes a lot I will put parts of the code here. I have a feeling its something in the server script when it says table.insert(vehicules, {vehicle = vehicle, state = v.state}) and I don’t know how to change it without it breaking hope someone can help me with this.
Client side
WarMenu.Display()
elseif WarMenu.IsMenuOpened('getcar') then
ESX.TriggerServerCallback('eden_garage:getVehicles', function(vehicles)
for _,v in pairs(vehicles) do
local hashVehicle = v.vehicle.model
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicle)
local labelvehicle
if(v.state) then
labelvehicle = vehicleName..': Returns'
else
labelvehicle = vehicleName..': Exit'
end
if WarMenu.Button(labelvehicle) then
if(v.state)then
SpawnVehicle(vehicle)
else
TriggerEvent('esx:showNotification', 'Your vehicle is already out')
end
end
end
end)
Server side
ESX.RegisterServerCallback('eden_garage:getVehicles', function(source, cb)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local vehicules = {}
MySQL.Async.fetchAll("SELECT * FROM owned_vehicles WHERE owner=@identifier",{['@identifier'] = xPlayer.getIdentifier()}, function(data)
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
table.insert(vehicules, {vehicle = vehicle, state = v.state})
end
cb(vehicules)
end)
end)