SpawnPlayer

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 11:02, 14 September 2020
MP2 (Talk | contribs)
(Note about fixing SpawnPlayer for players in vehicles)
← Previous diff
Current revision
MP2 (Talk | contribs)
(Link to function)
Line 9: Line 9:
{{notes2| {{notes2|
-* Kills the player if they are in a vehicle and then they spawn with a bottle in their hand. To fix this, eject them from the vehicle with SetPlayerPos first.+* Kills the player if they are in a vehicle and then they spawn with a bottle in their hand. To fix this, eject them from the vehicle with [[SetPlayerPos]] first.
-* If a player is in spectate mode and you want to spawn them, use [[TogglePlayerSpectating]] instead.+* If a player is in [[GetPlayerState|spectate mode]] and you want to spawn them, use [[TogglePlayerSpectating]] instead.
Otherwise they won't be spawned and instead will show the player flying mid-air.}} Otherwise they won't be spawned and instead will show the player flying mid-air.}}

Current revision



Description:

(Re)Spawns a player.


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


Return Values:

  • 1: The function was executed successfully.
  • 0: The function failed to execute. This means the player is not connected.


Image:32px-Circle-style-warning.png

Important
Notes

  • Kills the player if they are in a vehicle and then they spawn with a bottle in their hand. To fix this, eject them from the vehicle with SetPlayerPos first.
  • If a player is in spectate mode and you want to spawn them, use TogglePlayerSpectating instead.

Otherwise they won't be spawned and instead will show the player flying mid-air.


Example Usage:

if (strcmp(cmdtext, "/spawn", true) == 0)
{
    SpawnPlayer(playerid);
    return 1;
}

Related Functions

The following functions may be helpful as they relate to this function in one way or another.


Related Callbacks

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

Personal tools