OnPlayerRequestSpawn

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:27, 21 April 2014
MP2 (Talk | contribs)

← Previous diff
Revision as of 22:47, 10 May 2015
MP2 (Talk | contribs)

Next diff →
Line 1: Line 1:
{{Scripting}} {{Scripting}}
-{{Description|Called when a player attempts to spawn via class selection.}}+{{Description|Called when a player attempts to spawn via class selection either by pressing SHIFT or clicking the 'Spawn' button.}}
{{Parameters|playerid}} {{Parameters|playerid}}
-{{Param|playerid|The ID of the player who requested to spawn.}}+{{Param|playerid|The ID of the player that requested to spawn.}}
{{Returns|Returning '''0''' in this callback will prevent the player from spawning.}} {{Returns|Returning '''0''' in this callback will prevent the player from spawning.}}
Line 24: Line 24:
{{RelatedCallbacks}} {{RelatedCallbacks}}
 +{{OnPlayerSpawn}}
{{OnPlayerRequestClass}} {{OnPlayerRequestClass}}

Revision as of 22:47, 10 May 2015



Description:

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


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


Return Values:

Returning 0 in this callback will prevent the player from spawning.


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.

In other languages