i modified a script to store vehicles x,y,z,a(angle/heading) every x seconds in mysql.
This works perfectly and is tested.
Then i wrote a bit to load them on startup which seems to work (like print shows) but cars are NOT spawned… no errors or warnings shown in console.
Code:Client & Server
Codeedit: I uppercased save function.
Do you have any ideas? I found nothing related to this idk… my goal is to load all vehicles on serverstartup and to disable veh despawn if player disconnects (not coded yet as i do step by step)
your (loop , it shouldnt be a loop lol ) will trigger your function after 360000000 of client will load.
and it will re-trigger the event within 360000000.
youre grabbing data from database via a callback into client , you set that as a function into client side.
then open a thread once , trigger the client sided event. thats all.
for example
function SpawnVehOne()
modelRequest(Config.Zones.Veh_One.Model)
VehOne = CreateVehicle(Config.Zones.Veh_One.Model, Config.Zones.Veh_One.X,Config.Zones.Veh_One.Y,Config.Zones.Veh_One.Z,Config.Zones.Veh_One.Heading, false, true)
SetVehicleOnGroundProperly(VehOne)
local vehicleProps = NYAM.Game.GetVehicleProperties(VehOne)
local vehHash = Config.Zones.Veh_Two.Model
local vehName = GetDisplayNameFromVehicleModel(vehHash)
local newPlate = 'SHOWCASE' .. string.upper(NYAM.GetRandomString(1))
vehicleProps.plate = newPlate
SetVehicleNumberPlateText(VehOne, newPlate)
TriggerEvent('nyam_hotwire:forceTurnOver', VehOne)
Citizen.Wait(5000)
if DoesEntityExist(VehOne) then
FreezeEntityPosition(VehOne, true)
end
end
this is how a create a vehicle from configs , for my car show room
and here you can see the thread , as it spawn em and clear few rnd npcs around
Citizen.CreateThread(function()
SpawnVehOne()
SpawnVehTwo()
SpawnVehThree()
SpawnVehFour()
SpawnVehFive()
SpawnVehSix()
SpawnVehSeven()
SpawnVehEight()
SpawnVehNine()
while true do
Wait(150)
ClearAreaOfPeds(-1153.03, -1761.63, 4.0, 20.0, 0)
ClearAreaOfVehicles(-1153.03, -1761.63, 4.0, 20.0, false, false, false, false, false)
end
end)
Appreciate your example; i got my results from db so i keep it dynamic. If i translate your function i will end up more or less at the same code i wrote (i think).
I used ESX. vehicle create but yea.
im new to lua and to fivem. 12 years ago i was a very powerful coder at pawn (samp multiplayer written in c) but lua is kinda new to me with this way and also documentation is mh well you know^^
//edit yea got it, you do it server-side^^ ill try thanks for the hint