SetPlayerToSpectatePlayer
Server-Side Function
Server-Side
|
C#
|
Sets a player spectating another player.
Syntax
|
In C# Server-Side Function
API.setPlayerToSpectatePlayer(Client player, Client target);
Required Arguments
- player: parameter input should be in Client type.
- target: parameter input should be in Client type.
|
Usage example(s)
The command below sets you to spectate another player
|
In C# Server-Side Function
[Command("spectate", "Usage: /spectate <target_name>")]
public void CMD_SpectatePlayer(Client player, String targetName)
{
List<Client> allPlayers = API.getAllPlayers();
foreach(Client c in allPlayers)
{
if(c.name == targetName)
{
API.setPlayerToSpectatePlayer(player, c);
API.sendChatMessageToPlayer(player, "You're now spectaing player : " + c.name);
return;
}
}
API.sendChatMessageToPlayer(player, "[SERVER]: The specified player name does not match any currently online player");
}
|
References