ServerProxy

Description

API for common server functionality.

Methods

uint GetCurrentServerSequence()

  • Description: Gets the current server sequence number. This is a value incremented each server tick.

double GetRealtimeSinceStartupAsDouble()

  • Description: Retrieves the real time since the startup of the server as a double value.

void SendChatMessageToAll(string message)

  • Description: Sends a chat message to all clients.

void SendServerMessage(string message)

  • Description: Sends a server prefixed chat message to everyone.

void SendChatMessageToSingle(ushort clientId, string message)

  • Description: Sends a chat message to a specific client.

PlayerProxy TryGetPlayerById(ushort clientId)

  • Description: If player is not found for some reason it will return null.

void DisconnectClient(ushort id, string reason)


ClientProxy GetClientById(ushort clientId)


IEnumerable<PlayerProxy> EnumeratePlayers()

  • Description: Enumerate all players that are 'ready to play'.

List<PlayerProxy> GetPlayers()


IEnumerable<ClientInfo> EnumerateClients()

  • Description: Enumerate all clients.

void SetClassConfiguration(ClassConfiguration classConfiguration)

  • Description: Sets current class configuration. This will be applied when game environment and configuration is reset. You might want to use 'OnPreGameEnvironmentAndConfigurationReset' callback for setting this.

ClassConfiguration GetClassConfiguration()


bool IsCvar(string name)

  • Description: Returns true if cvar exists by name.

void SetCvar(string name, string value)

  • Description: If the cvar exists by name, will attempt to set the value of the cvar (may throw if parsing to target type fails). If cvar does not exist, will throw an error.

string GetCvar(string name)

  • Description: If the cvar exists by name, will return the cvar string. If the cvar does not exist, will throw an error

string GetGamemode()

  • Description: Get the active gamemode. If there is no active gamemode, will return null.

string GetMapName()

  • Description: Get the active map name.

void SendActionMessage(ActionMessageType actionMessageType, string actionMessage, ushort toClient)

  • Description: Sends action message to the client.

void IncreaseTeamScore(PlayerTeam team, int by)

  • Description: Increase the team score. This will show up in the in-game scoreboard.

int GetTeamScore(PlayerTeam team)


void EndRound(PlayerTeam winnerTeam)

  • Description: End the current round. This is particularly useful for custom gamemodes.

void DrawAABB(ushort toClient, aabb box, Color32 color, float lifetime)


void DrawLine(ushort toClient, Vector3 start, Vector3 end, Color32 color, float lifetime)


void DrawArrow(ushort toClient, Vector3 start, Vector3 end, Color32 color, float lifetime)


void DrawSphere(ushort toClient, Vector3 center, float radius, Color32 color, float lifetime)


string GetVersion()

  • Description: Returns the version of the server.

int GetAppId()

  • Description: Returns the steam specific app id of the server.

void BeginShutdown(double time)

  • Description: Begins shutdown process. The server will be shut down after the time has elapsed. If there is already an ongoing shutdown process then the shutdown process is overridden.

void SetShutdownReason(string reason)

  • Description: Reason shown in disconnect view when the server has shutdown.
  • Parameters:
    • reason: Reason shown in disconnect view when the server has shutdown.