Table of Contents

Class Server

Namespace
CounterStrikeSharp.API
Assembly
CounterStrikeSharp.API.dll
public class Server
Inheritance
Server

Properties

CurrentTime

Returns the current map time in seconds, as an interval of the server's tick interval. e.g. 70.046875 would represent 70 seconds of map time and the 4483rd tick of the server (70.046875 / 0.015625).

public static float CurrentTime { get; }

Property Value

float

Remarks

Increments even when server is hibernating

EngineTime

Returns the total time the server has been running in seconds.

public static double EngineTime { get; }

Property Value

double

Remarks

Increments even when server is hibernating

GameDirectory

public static string GameDirectory { get; }

Property Value

string

MapName

public static string MapName { get; }

Property Value

string

MaxPlayers

public static int MaxPlayers { get; }

Property Value

int

TickCount

Returns the current map tick count. CS2 is a 64 tick server, so the value will increment by 64 every second.

public static int TickCount { get; }

Property Value

int

TickInterval

Duration of a single game tick in seconds, based on a 64 tick server (hard coded in CS2).

public static float TickInterval { get; }

Property Value

float

TickedTime

Returns the total time the server has been running in seconds.

public static double TickedTime { get; }

Property Value

double

Remarks

Does not increment when server is hibernating

Methods

ExecuteCommand(string)

Executes a command on the server, as if it was entered from the console.

public static void ExecuteCommand(string command)

Parameters

command string

GetMapList()

public static string[] GetMapList()

Returns

string[]

IsMapValid(string)

public static bool IsMapValid(string mapName)

Parameters

mapName string

Returns

bool

NextFrame(Action)

Queue a task to be executed on the next game frame. Does not execute if the server is hibernating.

public static void NextFrame(Action task)

Parameters

task Action

NextFrameAsync(Action)

Queue a task to be executed on the next game frame. Does not execute if the server is hibernating.

Returns Task that completes once the synchronous task has been completed.

public static Task NextFrameAsync(Action task)

Parameters

task Action

Returns

Task

NextWorldUpdate(Action)

Queue a task to be executed on the next pre world update. Executes if the server is hibernating.

public static void NextWorldUpdate(Action task)

Parameters

task Action

NextWorldUpdateAsync(Action)

Queue a task to be executed on the next pre world update. Executes if the server is hibernating.

Returns Task that completes once the synchronous task has been completed.

public static Task NextWorldUpdateAsync(Action task)

Parameters

task Action

Returns

Task

PrecacheModel(string)

public static void PrecacheModel(string name)

Parameters

name string

PrintToChatAll(string)

public static void PrintToChatAll(string message)

Parameters

message string

PrintToConsole(string)

public static void PrintToConsole(string s)

Parameters

s string

RunOnTick(int, Action)

Queue a task to be executed on the specified tick. See TickCount to retrieve the current tick. Does not execute if the server is hibernating.

public static void RunOnTick(int tick, Action task)

Parameters

tick int
task Action

RunOnTickAsync(int, Action)

Queue a task to be executed on the specified tick. See TickCount to retrieve the current tick. Does not execute if the server is hibernating.

Returns Task that completes once the synchronous task has been completed.

public static Task RunOnTickAsync(int tick, Action task)

Parameters

tick int
task Action

Returns

Task