PDA

View Full Version : Change Vehicle Respawn Position


Rokzlive
29/07/2015, 09:17 AM
Im trying to find a way to change where a vehicle respawns to without having to destroy and create the vehicle all over again.

The solution i have toyed with is updating the variables of X, Y, Z, A that i have assigned to the vehicles and then, once the vehicle respawns, using SetVehiclePos to change the vehicles position to the one i want it to be at.

As shown:

public OnVehicleSpawn(vehicleid)
{
if(SVehicleType[vehicleid] == 2)
{
SetVehiclePos(vehicleid,TN_PV_pvData[vehicleid][vX],TN_PV_pvData[vehicleid][vY],TN_PV_pvData[vehicleid][vZ]);
SetVehicleZAngle(vehicleid,TN_PV_pvData[vehicleid][vA]);
}
return 1;
}

Now unfortunately, the SA:MP wiki has incorrect information. This function is only called when the vehicle is first created. It is never called after that (for example when the vehicle respawns). The wiki said it was called when it spawns AND respawns. Thus, the function is not doing what I intended.

Is there another way to remedy this? Or do i have to just destroy it and recreate it?