SA-MP Forums Archive
Checking the last driver of a vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Checking the last driver of a vehicle (/showthread.php?tid=587203)



Checking the last driver of a vehicle - Krakuski - 28.08.2015

Howdy,
Does anyone know how I can create a script to detect the previous driver of a vehicle? I've been trying and I just haven't gotten it. Thanks


Re: Checking the last driver of a vehicle - Abagail - 28.08.2015

pawn Код:
new lastDriver[MAX_VEHICLES];
public OnPlayerStateChange(playerid, newstate, oldstate) {
    if(newstate == PLAYER_STATE_DRIVER)
    {
            if(IsPlayerInAnyVehicle(playerid))
                  lastDriver[GetPlayerVehicleID(playerid)] = playerid;
    }

    return 1;
}



Re: Checking the last driver of a vehicle - R0 - 29.08.2015

There you go:
pawn Код:
new VehicleLastDriver[MAX_VEHICLES]; //put this at the top of the script
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetPlayerVehicleID(playerid) != 0)
        {
            VehicleLastDriver[GetPlayerVehicleID(playerid)] = playerid;
        }
    }
    return 1;
}



Re: Checking the last driver of a vehicle - Krakuski - 29.08.2015

Thank you both, REP+


Re: Checking the last driver of a vehicle - Krakuski - 29.08.2015

Last question, How would I be able to make a command such as /lastdriver to actually see who was in the vehicle?