OnPlayerStateChange
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.
| Name | Description |
|---|---|
| playerid | The ID of the player that changed state. |
| PLAYER_STATE:newstate | The player's new state. |
| PLAYER_STATE:oldstate | The player's previous state. |
Returns
It is always called first in filterscripts.
Examples
public OnPlayerStateChange(playerid, PLAYER_STATE:newstate, PLAYER_STATE: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;
}
Notes
ملاحظة
يمكن للشخصيات غير القابلة للعب استدعاء دالة رد النداء هذه أيضًا.
Related Callbacks
The following callbacks might be useful, as they're related to this callback in one way or another.
- OnPlayerInteriorChange: This callback is called when a player changes interior.
Related Functions
The following functions might be useful, as they're related to this callback in one way or another.
- GetPlayerState: Get a player's current state.
- GetPlayerSpecialAction: Get a player's current special action.
- SetPlayerSpecialAction: Set a player's special action.