The open.mp logo
Home
FAQ
Forums
Servers
Partners
Docs
Blog

warning Not Translated

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

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

OnPlayerSpawn

Description

This callback is called when a player spawns.(i.e. after caling SpawnPlayer function)

NameDescription
playeridThe ID of the player that spawned.

Returns

0 - Will prevent other filterscripts from receiving this callback.

1 - Indicates that this callback will be passed to the next filterscript.

It is always called first in filterscripts.

Examples

public OnPlayerSpawn(playerid)
{
    new PlayerName[MAX_PLAYER_NAME],
    string[40];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(string, sizeof(string), "%s has spawned successfully.", PlayerName);
    SendClientMessageToAll(0xFFFFFFFF, string);
    return 1;
}

Notes

tip

The game sometimes deducts \$100 from players after spawn.

Related Callbacks

The following callbacks might be useful, as they're related to this callback in one way or another.

  • OnPlayerDeath: This callback is called when a player dies.
  • OnVehicleSpawn: This callback is called when a vehicle respawns.

Related Functions

The following functions might be useful, as they're related to this callback in one way or another.

  • SpawnPlayer: Force a player to spawn.
  • AddPlayerClass: Add a class.
  • SetSpawnInfo: Set the spawn setting for a player.

Community

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

More

  • SA-MP
  • Blog
  • GitHub