Skip to main content

Server

Server-side utilities for sending commands to player clients.

public static class Server

Namespace: DeadworksManaged.Api
Source: Server.cs#L7

Properties​

Server.MapName​

The current map name, set when the server starts up.

Signature

public static string MapName { get; internal set; } = "";

Source: Server.cs#L9

Server.IsChangingLevel​

True while the map is changing, until the next map's IDeadworksPlugin.OnStartupServer. It turns on at ChangeLevel, or for a change started elsewhere, such as changelevel in the server console, once the current map starts shutting down, which is before every player gets a disconnect event with ClientDisconnectedEvent.IsMapChange. Anything done to players, pawns or panels meanwhile is lost with the old map. If the change fails, such as for a map that doesn't exist, it turns off again after a few seconds.

Signature

public static bool IsChangingLevel { get; }

Source: Server.cs#L18

Methods​

Server.ChangeLevel()​

Change to map. Everyone connected stays connected and reloads into it; see ClientConnectEvent.IsMapChangeReconnect. IsChangingLevel is true from this call.

Signature

public static void ChangeLevel(string map)

Parameters

  • map: A map name, such as dl_midtown.

Throws

  • ArgumentException: map is empty or isn't a plain map name.

Source: Server.cs#L32

Server.ClientCommand()​

Sends a console command to the client in the given slot.

Signature

public static void ClientCommand(int slot, string command)

Source: Server.cs#L60

Server.ExecuteCommand()​

Executes a command on the server console.

Signature

public static void ExecuteCommand(string command)

Source: Server.cs#L68

Server.SetAddons()​

Sets the server's addons string. Clients receive this in SignonState/connection messages.

Signature

public static void SetAddons(string addons)

Source: Server.cs#L76

Server.AddSearchPath()​

Adds a search path to the engine's filesystem. Use pathID "GAME" for general content.

Signature

public static bool AddSearchPath(string path, string pathID = "GAME", bool addToHead = true)

Parameters

  • path: Path to a directory or VPK file.
  • pathID: Search path group (e.g. "GAME", "MOD").
  • addToHead: If true, path is searched first (highest priority).

Source: Server.cs#L87

Server.EnumerateConVars()​

Enumerates all registered ConVars by index.

Signature

public static List<ConVarEntry> EnumerateConVars()

Source: Server.cs#L97

Server.EnumerateConCommands()​

Enumerates all registered ConCommands by index.

Signature

public static List<ConCommandEntry> EnumerateConCommands()

Source: Server.cs#L111

Server.AddEngineLogListener()​

Adds a listener to receive all engine logging output. Multiple listeners are supported.

Signature

public static void AddEngineLogListener(EngineLogHandler handler)

Source: Server.cs#L142

Server.RemoveEngineLogListener()​

Removes a previously added engine log listener. The native listener is unregistered when the last listener is removed.

Signature

public static void RemoveEngineLogListener(EngineLogHandler handler)

Source: Server.cs#L156

Server.CreateFakeClient()​

Connects a fake client ("bot") that occupies a real player slot but has no netchannel. Returns its player slot, or -1 when the engine had no slot free. An unreserved Deadlock server keeps no slots at all, so this fails until a match has been set up.

Signature

public static int CreateFakeClient(string name)

Source: Server.cs#L172

Server.Kick()​

Disconnects the player in slot. They're sent back to the main menu without being told why, so tell them first if they should know. The reason is for plugins: it's what IDeadworksPlugin.OnClientDisconnecting and IDeadworksPlugin.OnClientDisconnect see.

Signature

public static void Kick(int slot, ENetworkDisconnectionReason reason = ENetworkDisconnectionReason.NetworkDisconnectKicked)

Source: Server.cs#L184

Server.HasCommandLineParm()​

Returns true if the given parameter is present on the engine command line (e.g. "-nomaster").

Signature

public static bool HasCommandLineParm(string parm)

Source: Server.cs#L188