Class Server
A set of tools to easily work with the server.
public static class Server
- Inheritance
-
Server
- Inherited Members
Properties
Broadcast
Gets the cached Broadcast component.
public static Broadcast Broadcast { get; }
Property Value
- Broadcast
BuildType
Gets a value indicating the type of build this server is hosted on.
public static Version.VersionType BuildType { get; }
Property Value
- Version.VersionType
Frametime
Gets the actual frametime of the server.
public static double Frametime { get; }
Property Value
FriendlyFire
Gets or sets a value indicating whether friendly fire is enabled.
public static bool FriendlyFire { get; set; }
Property Value
- See Also
Host
Gets the player's host of the server. Might be null when called when the server isn't loaded.
public static Player Host { get; }
Property Value
IpAddress
Gets the Ip address of the server.
public static string IpAddress { get; }
Property Value
IsBeta
Gets a value indicating whether this server is on a beta version of SCP:SL.
public static bool IsBeta { get; }
Property Value
IsDedicated
Gets a value indicating whether this server is a dedicated server.
public static bool IsDedicated { get; }
Property Value
IsHeavilyModded
Gets or sets a value indicating whether the server is marked as Heavily Modded.
[Obsolete("This field has been deleted because it used the wrong field (TransparentlyModded)")]
public static bool IsHeavilyModded { get; set; }
Property Value
IsIdleModeEnabled
Gets or sets a value indicating whether idle mode is enabled.
public static bool IsIdleModeEnabled { get; set; }
Property Value
IsTransparentlyModded
Gets or sets a value indicating whether the server is marked as Transparently Modded.
public static bool IsTransparentlyModded { get; set; }
Property Value
IsVerified
Gets a value indicating whether this server is verified.
public static bool IsVerified { get; }
Property Value
IsWhitelisted
Gets or sets a value indicating whether this server has the whitelist enabled.
public static bool IsWhitelisted { get; set; }
Property Value
LateJoinEnabled
Gets a value indicating whether late join is enabled.
public static bool LateJoinEnabled { get; }
Property Value
LateJoinTime
Gets the late join time, in seconds. If a player joins less than this many seconds into a game, they will be given a random class.
public static float LateJoinTime { get; }
Property Value
MaxPlayerCount
Gets or sets the maximum number of players able to be on the server.
public static int MaxPlayerCount { get; set; }
Property Value
MaxTps
Gets or sets the max ticks per second of the server.
public static short MaxTps { get; set; }
Property Value
Name
Gets or sets the name of the server.
public static string Name { get; set; }
Property Value
PermissionsHandler
Gets the RemoteAdmin permissions handler.
public static PermissionsHandler PermissionsHandler { get; }
Property Value
- PermissionsHandler
PlayerCount
Gets the number of players currently on the server.
public static int PlayerCount { get; }
Property Value
- See Also
PluginAssemblies
Gets a dictionary that pairs assemblies with their associated plugins.
public static Dictionary<Assembly, IPlugin<IConfig>> PluginAssemblies { get; }
Property Value
Port
Gets the port of the server.
public static ushort Port { get; }
Property Value
SendSpawnMessage
Gets the cached SendSpawnMessage MethodInfo.
public static MethodInfo SendSpawnMessage { get; }
Property Value
SessionVariables
Gets the dictionary of the server's session variables.
Session variables can be used to save temporary data. Data is stored in a Dictionary<TKey, TValue>. The key of the data is always a string, whereas the value can be any object. The data stored in a session variable can be accessed by different assemblies; it is recommended to uniquely identify stored data so that it does not conflict with other plugins that may also be using the same name. Data saved with session variables is not being saved on server restart. If the data must be saved after a restart, a database must be used instead.
public static Dictionary<string, object> SessionVariables { get; }
Property Value
StreamingAllowed
Gets a value indicating whether streaming of this version is allowed.
public static bool StreamingAllowed { get; }
Property Value
Tps
Gets the actual ticks per second of the server.
public static double Tps { get; }
Property Value
Version
Gets the server's version.
public static string Version { get; }
Property Value
WhitelistedPlayers
Gets the list of user IDs of players currently whitelisted.
public static HashSet<string> WhitelistedPlayers { get; }
Property Value
Methods
ExecuteCommand(string, CommandSender)
Executes a server command.
public static string ExecuteCommand(string command, CommandSender sender = null)
Parameters
command
stringThe command to be run.
sender
CommandSenderThe CommandSender running the command.
Returns
Restart()
Restarts the server, reconnects all players.
public static void Restart()
- See Also
RestartRedirect(ushort)
Redirects players to a server on another port, restarts the current server.
public static bool RestartRedirect(ushort redirectPort)
Parameters
redirectPort
ushortThe port to redirect players to.
Returns
Remarks
If the returned value is false, the server won't restart.
Shutdown()
Shutdowns the server, disconnects all players.
public static void Shutdown()
- See Also
Shutdown(bool, bool)
Shutdowns the server, disconnects all players.
public static void Shutdown(bool quit, bool suppressShutdownBroadcast = false)
Parameters
quit
boolIndicates whether to terminate the application after shutting down the server.
suppressShutdownBroadcast
boolIndicates whether to suppress the broadcast notification about the shutdown.
- See Also
ShutdownRedirect(ushort)
Redirects players to a server on another port, shutdowns the current server.
public static bool ShutdownRedirect(ushort redirectPort)
Parameters
redirectPort
ushortThe port to redirect players to.
Returns
Remarks
If the returned value is false, the server won't shutdown.
TryGetSessionVariable<T>(string, out T)
Safely gets an object from SessionVariables, then casts it to T
.
public static bool TryGetSessionVariable<T>(string key, out T result)
Parameters
key
stringThe key of the object to get.
result
TWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter is used.
Returns
Type Parameters
T
The returned object type.