Curious what’s going on because I have no idea where to go from here.
When you are playing by yourself, it works flawlessly. Players can track their car across the world with GPS, lock and unlock the car remotely, and everything I want them to do. The problem comes in, when the player leaves rendering distance of their vehicle when another player is within render distance. What I mean by that, is if Player A owns Vehicle A, and leaves the render distance, Vehicle A disappears on their screen. It still gets commands and shows it’s correct coordinates, until Player B enters the render distance of Vehicle A. At that point, the vehicle stops being reported and interacting, and the vector returns as (vector3(0,0,0)). As soon as Player A reenters the render distance, Vehicle A begins reporting again with the correct coordinates.
This is GPS-breaking. If a player wants to find their vehicle and they’re not in render distance, it will report as 0,0,0 until they’re within 2-4 blocks of the vehicle.
RequestModel(veh)
while not HasModelLoaded(veh) do Wait(1) end
local myCar = CreateVehicle(veh, xpos, ypos, zpos, hedn, true, false)
SetVehicleOnGroundProperly(myCar)
SetEntityAsMissionEntity(myCar) -- Also tried (myCar, true, false) and true true, false false
SetModelAsNoLongerNeeded(veh)
SetVehicleNumberPlateText(myCar, tostring(plate))
SetEntityHeading(myCar, hedn)
SetVehicleDoorsLocked(myCar, 2)
SetNetworkIdCanMigrate(VehToNet(myCar), true)
SetNetworkIdExistsOnAllMachines(VehToNet(myCar), true)
vehSpawned = VehToNet(myCar)
TriggerServerEvent('mygame:vehspawned', vehSpawned)