OnPlayerRequestSpawn

From SA-MP Wiki

Jump to: navigation, search


Description:

Called when a player attempts to spawn via class selection either by pressing SHIFT or clicking the 'Spawn' button.


Image:32px-Ambox_warning_orange.png

Note

This callback can also be called by NPC.


Parameters:
(playerid)
playeridThe ID of the player that requested to spawn.


Return Values:

Returning 0 in this callback will prevent the player from spawning.
  • It is always called first in filterscripts so returning 0 there also blocks other scripts from seeing it.


Example Usage:

public OnPlayerRequestSpawn(playerid)
{
    if(!IsPlayerAdmin(playerid))
    {
        SendClientMessage(playerid, -1, "You may not spawn.");
        return 0;
    }
    return 1;
}
Tip

Image:Light_bulb_icon.png

To prevent players from spawning with certain classes, the last viewed class must be saved in a variable in OnPlayerRequestClass.


Related Callbacks

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

Personal tools
Navigation
Toolbox
In other languages