[HELP] how to get vehicle position, GetVehicleNodePosition doesn't working

Hello, why it doesnt working?

local spawned_car = CreateVehicle(vehicle,coordsx,coordsy,coordsz,244.0, true, false)
SetVehicleOnGroundProperly(spawned_car)
SetModelAsNoLongerNeeded(vehicle)
local pos ={}
GetVehicleNodePosition(spawned_car,pos)

Are you trying to get the coords of the client who is in the vehicle?

local pos = GetEntityCoords(spawned_car, false) should do it.

https://runtime.fivem.net/doc/reference.html#_0x3FEF770D40960D5A

2 Likes

Strangely, it gives 0 :neutral_face:

basicly, I wanted to make protection from pushing cars when they are not active (taxi, police car).
I take the last coordinates compare with the coordinates now, if there are changes, I return the machine to last coords. Do you know if there is another solution?

No, i get coords when spawn taxi cars, after i checking car was pushed or not (compare the coordinates before and after) , if they differ teleport car back. Is this a bad decision?

It’s probably easier to just freeze the position of the spawned vehicle, that way it won’t move at all and you don’t need to check for it.

2 Likes