TogglePlayerSpectating
From SA-MP Wiki
Description:
Toggle whether a player is in spectator mode or not. While in spectator mode a player can spectate (watch) other players and vehicles. After using this function, either PlayerSpectatePlayer or PlayerSpectateVehicle needs to be used.
(playerid, toggle)
playerid | The ID of the player who should spectate |
toggle | 1 to enable spectating and 0 to disable |
Return Values:
- 1: The function was executed successfully.
- 0: The function failed to execute. The player does not exist.
![]() Warning | If the player is not loaded in before setting the spectate status to false, the connection can be closed unexpectedly. |
![]() Notes |
|
Tip | When a player is in spectate mode their HUD is hidden, making it useful for setting a player's camera without the HUD. Also, objects near the player's camera will be streamed in, making this useful for interpolating cameras. |
Example Usage:
public OnPlayerDeath(playerid, killerid, reason) { TogglePlayerSpectating(playerid, 1); PlayerSpectatePlayer(playerid, killerid); return 1; }
[edit]
Related Functions
The following functions may be helpful as they relate to this function in one way or another.
- PlayerSpectatePlayer: Spectate a player.
- PlayerSpectateVehicle: Spectate a vehicle.