Hello! What’s wrong?
Explanations:
Well, when the menu is not yet open, it works, I have all available vehicles from the database but when I close and open back the menu, it’s fully wrong : it show me the same vehicle and when I try to click on the first, the vehicle doesn’t spawn but when I try on the second it works.
Please, help me, I’m searching since 3 hours
video:
database:
|vehicle | plate |
|--------|-------|
|BF400 | BBBBBB|
|FLATBED | CCCCCC|
part of code:
function SetupMenu(VehiclesList, playerJob)
while not vehicleList do Wait(10) end
vehicleItem = {}
for k, vehicle in pairs(VehiclesList) do
vehicleList.SubMenu:RemoveItemAt(k)
vehicleItem[k] = NativeUI.CreateItem(VehiclesList[k].vehicle.." | "..VehiclesList[k].plate, VehiclesList[k].vehicle.." | "..VehiclesList[k].plate)
vehicleList.SubMenu:AddItem(vehicleItem[k])
end
vehicleList.SubMenu.OnItemSelect = function(sender, item, index)
if not IsPedInAnyVehicle(GetPlayerPed(-1), true) then
for k, vehicle in pairs(vehicleItem) do
if item == vehicleItem[k] then
TriggerServerEvent("csg:RetrieveVehicleFromDatabse", playerJob, VehiclesList[k].vehicle, VehiclesList[k].plate)
end
end
else
NotificationText("Vous êtes déjà dans un véhicule !")
end
end
end