@ dutchplayers Have tried latest artifact and issue persists, have you tried with more than one player? WIth one player the vehicles don’t seem to disappear when you go away, I tested with 3 players we parked a car outside pinkcage then went inside, after 3 seconds we exited and the car was gone.
Hello all, how this script work ? i have onesync_enabled 1, the script is start in config.lua but when i restart the server all vehicles i bought at vehicleshop are not spawned.
i tested to do “pv-save-to-file” in RCON console, but he say : “print Persistent Vehicles: 0 vehicles saved to file”
@Zastaax As this is a standalone resource, you’ll have to follow the instructions in the readme.md file in the repository to get it set up properly.
Essentially, you’ll want to call the persistent vehicle events from the corresponding events in other resources. For example, if you’re using ESX then inside of the ESX.Game.SpawnVehicle function, you’d pass its entity to the register-vehicle event and as long as this resource is started, it will make any vehicle spawned by the ESX.Game.SpawnVehicle function persistent.
If you’re not using ESX, then you’ll want to call these events from whatever function you’re using to spawn/remove/update vehicles.
@Braanflakes I put the function : “TriggerEvent(‘persistent-vehicles/register-vehicle’, entity)” in my es_extended/client/function.lua
ESX.Game.SpawnVehicle = function(modelName, coords, heading, cb)
local model = (type(modelName) == 'number' and modelName or GetHashKey(modelName))
Citizen.CreateThread(function()
RequestModel(model)
while not HasModelLoaded(model) do
Citizen.Wait(0)
end
local vehicle = CreateVehicle(model, coords.x, coords.y, coords.z, heading, true, false)
local id = NetworkGetNetworkIdFromEntity(vehicle)
SetNetworkIdCanMigrate(id, true)
SetEntityAsMissionEntity(vehicle, true, false)
SetVehicleHasBeenOwnedByPlayer(vehicle, true)
SetVehicleNeedsToBeHotwired(vehicle, false)
SetModelAsNoLongerNeeded(model)
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
while not HasCollisionLoadedAroundEntity(vehicle) do
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
Citizen.Wait(0)
end
TriggerEvent('persistent-vehicles/register-vehicle', entity)
SetVehRadioStation(vehicle, 'OFF')
if cb ~= nil then
cb(vehicle)
end
end)
end
And after I don’t know what to do,
Thx for answer !
EDIT : i get a error now
[91mSCRIPT ERROR: @enc0ded-persistent-vehicles/server/main.lua:191: attempt to index a nil value (local ‘props’)e[0m
not for us, tested with several artifacts … saving and spawning some well, but some cars changing cords and spawn random next to other in further locations …
When i sell a vehicle to a player with esx_vehicleshop, the player have the car with the plate like EUG 572 and when we go far away from the car, and come back to it, the plate was changed to a random plate or sometimes, the car disapear…
@Braanflakes@Hatchett
Did you know why in the file ‘vehicle-data.json’ the number plate is not the same when i sell vehicle for someone at esx_vehicleshop ? because when the serveur restarting or when i go far away from my car the number plate become like befor