Get the vehicle ID the player was last in?
#1

Hi,
I'm creating a trunk script for my gamemode, and I'm a bit confused.
I want to know how I can get the vehicle ID the player was last in.

For example, if the player drove a Mesa (ID 32) recently and is now on foot how can I detect that?

GetPlayerVehicleID only detects IF the player is in the vehicle.

Thanks.
Reply
#2

new P_LastVeh[MAX_PLAYERS];

Could use that when a player sit's in a vehicle to store it.

P_LastVeh[playerid] = GetPlayerVehicleID(playerid);
Reply
#3

pawn Код:
//Above your script:
new LastPlayerInVec[MAX_VEHICLES] = (-1);

//Callback OnPlayerExitVehicle:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(GetPlayerState(playerid) == 2) // Is he/she the driver?
        LastPlayerInVec[vehicleid] = playerid;
    return 1;
}

//The function
stock GetLastPlayerInVehicle(vehicleid)
{
    if(LastPlayerInVec[vehicleid] != -1) //Did someone entered it?
        return LastPlayerInVec[vehicleid];
    return 0;
}
Try this ^^

[EDIT]
Damn bmuk was faster
Reply
#4

Thanks guys, helped a lot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)