OnPlayerStateChange

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 11:54, 23 June 2014
GameMan (Talk | contribs)
(ru link)
← Previous diff
Revision as of 22:44, 10 May 2015
MP2 (Talk | contribs)

Next diff →
Line 1: Line 1:
{{Scripting}} {{Scripting}}
-{{Description|This callback is called when a player changes [[state]].}}+{{Description|This callback is called when a player changes [[state]]. For example, when a player changes from being the driver of a vehicle to being on-foot.}}
{{Parameters|playerid, newstate, oldstate}} {{Parameters|playerid, newstate, oldstate}}

Revision as of 22:44, 10 May 2015



Description:

This callback is called when a player changes state. For example, when a player changes from being the driver of a vehicle to being on-foot.


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


Return Values:

This callback does not handle returns.


Example Usage:

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 might be useful, as they're related to this callback in one way or another.

In other languages