Saving vehicles positions
#5

Use OnPlayerStateChange since its way more reliable
PHP код:
new OldCar[MAX_PLAYERS];
public 
OnPlayerStateChange(playeridnewstateoldstate) {
    if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER// Player entered a vehicle as a driver
    
{
        if(
GetPlayerVehicleID(playerid) <= 3) return true;
        
OldCar[playerid] = GetPlayerVehicleID(playerid);
    }
    if(
oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT) {
        
GetVehiclePos(OldCar[playerid],Float:vx,Float:vy,Float:vz);
        
GetVehicleZAngle(OldCar[playerid],Float:va);
        
Vehicle[OldCar[playerid]][Positionx] = vx;
        
Vehicle[OldCar[playerid]][Positiony] = vy;
        
Vehicle[OldCar[playerid]][Positionz] = vz;
    }
    return 
1;

From wiki about OnPlayerExitVehicle
Quote:

Not called if the player falls off a bike or is removed from a vehicle by other means such as using SetPlayerPos.

EDIT: Forgot the > 3
Reply


Messages In This Thread
Saving vehicles positions - by ivibeserro - 21.06.2016, 16:17
Re: Saving vehicles positions - by ATGOggy - 21.06.2016, 16:21
Re: Saving vehicles positions - by ivibeserro - 21.06.2016, 22:40
Re: Saving vehicles positions - by jlalt - 21.06.2016, 22:42
Re: Saving vehicles positions - by TwinkiDaBoss - 21.06.2016, 23:01
Re: Saving vehicles positions - by ATGOggy - 22.06.2016, 03:31
Re: Saving vehicles positions - by ivibeserro - 22.06.2016, 12:47

Forum Jump:


Users browsing this thread: 1 Guest(s)