open.mp | OnPlayerStateChange
  • Home
  • FAQ
  • Forum
  • Servers
  • Docs
  • Blog
  • Login
  • Englishاللغة العربيةar-TNবাংলাbosanski jezikDeutschΕλληνικάEspañoleestiفارسیFrançaisHrvatskimagyarBahasa IndonesiaItaliano日本語ქართულიlietuvių kalbaNederlandsNorskjęzyk polskiPortuguêsRomânăРусскийslovenski jezikсрпски језикไทยWikang TagalogTürkçeУкраїнськаاردوTiếng Việt简体中文繁體中文
warning Not Translated

This page has not been translated into the language that your browser requested. The English content is being shown as a fallback.

If you want to contribute a translation for this page then please click here.

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.

NameDescription
playeridThe ID of the player that changed state.
newstateThe player's new state.
oldstateThe player's previous state.

Refer to Player States for a list of all available player states.

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;
}

Notes

tip

This callback can also be called by NPC.

Related Functions

  • GetPlayerState: Get a player's current state.
  • GetPlayerSpecialAction: Get a player's current special action.
  • SetPlayerSpecialAction: Set a player's special action.

Community

  • Discord
  • Instagram
  • Twitter
  • Twitch
  • YouTube
  • Facebook
  • VK

More

  • SA-MP
  • Blog
  • GitHub