OnPlayerStateChange

OnPlayerStateChange

Description:
Callback OnPlayerStateChange is called when a player changes state. For example, when a player changes from being the driver of a vehicle to being on-foot.
Callback OnPlayerStateChange can also be called by NPC.


Parameters:
(playerid, newstate, oldstate)
int playerid The ID of the player that changed state.
int newstate The player's new state.
int oldstate The player's previous state.


Return Values:
This callback does not handle returns.
  • It is always called first in filterscripts.


Examples:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        AddVehicleComponent(vehicleid, 1010); // Add NOS to the vehicle
    }
    return 1;
}


Related Callbacks
The following callbacks might be useful as well, as they are related to this callback in one way or another.


Related Functions
The following functions may be useful, as they are related to this function in one way or another.