hello, I come to you because I can not find the solution to prevent the vehicles of the players and those of society of despawn. I would like to leave them present at all times even after a reboot with esx_edengarage , is it possible?
Use this native right after the vehicle has spawned.
https://runtime.fivem.net/doc/reference.html#_0xAD738C3085FE7E11
function SpawnVehicle(vehicle)
ESX.Game.SpawnVehicle(vehicle.model,{
x=this_Garage.SpawnPoint.Pos.x ,
y=this_Garage.SpawnPoint.Pos.y,
z=this_Garage.SpawnPoint.Pos.z + 1
},this_Garage.SpawnPoint.Heading, function(callback_vehicle)
ESX.Game.SetVehicleProperties(callback_vehicle, vehicle)
SetVehRadioStation(callback_vehicle, "OFF")
TaskWarpPedIntoVehicle(GetPlayerPed(-1), callback_vehicle, -1)
local plate = GetVehicleNumberPlateText(callback_vehicle)
TriggerServerEvent("ls:mainCheck", plate, callback_vehicle, true)
end)
TriggerServerEvent('eden_garage:modifystate', vehicle, false, 0)
end
this is our function exit garage during the spawn vehicle
I tried to apply:
SetVehicleHasBeenOwnedByPlayer(vehicle, true)
&
SetEntityAsNoLongerNeeded(vehicle, true)
And a :
local = id
The question is, how to apply this native:
SET_ENTITY_AS_MISSION_ENTITY
The exact same way.
SetEntityAsMissionEntity(vehicle, true, true)
I’ve just doing that and it doesn’t work, maybe because i’m in localhost and i was the only entity, so the serv just clean all entity. Or maybe it’s not the good way to put him
ESX.Game.SpawnVehicle(vehicle.model,{
x=this_Garage.SpawnPoint.Pos.x ,
y=this_Garage.SpawnPoint.Pos.y,
z=this_Garage.SpawnPoint.Pos.z + 1
},this_Garage.SpawnPoint.Heading, function(callback_vehicle)
ESX.Game.SetVehicleProperties(callback_vehicle, vehicle)
SetVehRadioStation(callback_vehicle, "OFF")
TaskWarpPedIntoVehicle(GetPlayerPed(-1), callback_vehicle, -1)
local plate = GetVehicleNumberPlateText(callback_vehicle)
TriggerServerEvent("ls:mainCheck", plate, callback_vehicle, true)
end)
TriggerServerEvent('eden_garage:modifystate', vehicle, false, 0)
SetEntityAsMissionEntity(vehicle, true, true) --DESPAWN
end
function ranger(vehicle,vehicleProps)
ESX.Game.DeleteVehicle(vehicle)
local idGarage=getInfoGarage().Id
TriggerServerEvent('eden_garage:modifystate', vehicleProps, true, idGarage)
TriggerEvent('esx:showNotification', _U('vehicle_in_garage'))
SetEntityAsMissionEntity(vehicle, true, true) --DESPAWN
end
Thx for your Help
is this a known fix?
I find it very confusing some people say their vehicles despawn some don’t, if you set it like this, will it actually stay until a restart?