💻 Server
Server represents all Server controls in the Server side

🎒 Examples
-- prints "Server started" when the server is starting
Server.Subscribe("Start", function()
Console.Log("Server started")
end)
-- prints "Server stopped" when the server stops / shutdown
Server.Subscribe("Stop", function()
Console.Log("Server stopped")
end)
-- prints the delta time about every 33 ms
Server.Subscribe("Tick", function(delta_time)
Console.Log("Tick: " .. delta_time)
end)
🗿 Static Functions
| Data | ||
GetAllValuesKeys: table of string | Gets a list of all values keys | |
GetValue: any | Gets a value given a key | |
SetValue | Sets a global value in the Server, which can be accessed from anywhere (server side) | |
| Diagnostics | ||
GetLogLevel: integer | Returns the current log level | |
GetTickRate: integer | Returns the Configured Tick Rate | |
GetTime: integer | Gets the Unix Epoch Time in milliseconds | |
GetVersion: string | Returns the server version | |
| Lifecycle | ||
Restart | Restarts the server, reloading all Packages and reconnecting all Players | |
Stop | Stops the server | |
Subscribe: function | Subscribes for an Event | |
Unsubscribe | Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback | |
| Moderation | ||
BanBySteamID | Bans the player from the server by its Steam ID, ideal for banning from inside PlayerConnect event | |
KickBySteamID | Kicks the player from the server by its Steam ID, ideal for kicking from inside PlayerConnect event or while holding the connection | |
Unban | Unbans a Player by its Steam ID | |
| Network | ||
GetConnectionCount: integer | Returns the number of connected players (including players in the process of connecting) | |
GetHeldConnections: table of table | Returns all players currently held in the loading screen | |
GetIP: string | Returns the server Public IP | |
GetPort: integer | Returns the server Port | |
GetQueryPort: integer | Returns the server QueryPort | |
HoldConnection: boolean | Holds a connecting player in the loading screen with a message, before he starts downloading the server files | |
IsAnnounced: boolean | Returns if the Server is announced in the Master List | |
ReleaseConnection: boolean | Lets a held player in, he starts downloading the server files and joins as usual | |
| Packages | ||
GetPackages: table of table | Returns a list of Packages running, optionally returns all Packages installed in the server | |
IsPackageLoaded: boolean | Returns if a Package is currently loaded | |
LoadPackage: boolean | Loads a Package | |
ReloadPackage: boolean | Reloads a Package on the next server tick | |
UnloadPackage: boolean | Unloads a Package | |
| Settings | ||
GetCustomSettings: table of table | Returns the Server Custom Settings passed as parameter or New Game screen | |
GetDefaultEntityDimension: integer | Returns the default entity dimension | |
GetDefaultPlayerDimension: integer | Returns the default player dimension | |
GetDescription: string | Returns the Server Description | |
GetMaxPlayers: integer | Returns the Max Players configured | |
GetName: string | Returns the Server Name | |
IsUnsafeLibsEnabled: boolean | Returns if the server was started with --enable_unsafe_libs | |
SetDefaultEntityDimension | Sets the default server dimension that entities will spawn in | |
SetDefaultPlayerDimension | Sets the default server dimension that players will spawn in | |
SetDescription | Sets the description of the server, optionally overrides Config.toml | |
SetLogo | Sets the logo of the server, optionally overrides Config.toml | |
SetMaxPlayers | Sets the maximum player slots of the server, optionally overrides Config.toml | |
SetName | Sets the name of the server, optionally overrides Config.toml | |
SetPassword | Sets the password of the server, optionally overrides Config.toml | |
| World | ||
AddMapSpawnPoint | Adds a spawn point to the current map's spawn points list | |
ChangeMap | Restarts the server in a new Map, restarts all packages and reconnects all players | |
GetActorsInRadius: table of Base Actor | Returns the actors within the specified radius | |
GetEntityByID: Base Entity or nil | Returns the entity with the specified ID | |
GetMap: string | Returns the current Map Package name | |
GetMapAsset: string | Returns the current Map Asset reference | |
GetMapConfig: table | Returns a list of the Custom Config of the current map (defined in the map package's Package.toml) | |
GetMapSpawnPoints: table of table | Returns a list of the Spawn Points of the current map (defined in the map package's Package.toml) | |
GetPlayersInRadius: table of Player | Returns the players within the specified radius | |
Datastatic functions

GetValueModerate
Gets a value given a key
local ret = Server.GetValue(key, fallback)
Returns
| Type | Descrição |
|---|---|
| any | Value at key or fallback if key doesn't exist |
See also GetAllValuesKeys, SetValue.

SetValueModerate
Sets a global value in the Server, which can be accessed from anywhere (server side)
Please refer to Entity Values for more information
Server.SetValue(key, value, sync_on_client?)
Parameters
| Name | Type | Descrição |
|---|---|---|
key | string | Key |
value | any | The value, can be any serializable type (not functions) |
sync_on_client? | boolean | If enabled will sync this value through all clients, accessible through Client.GetValue() static class Default false |
See also GetAllValuesKeys, GetValue, ValueChange.
Diagnosticsstatic functions

GetLogLevelOptimal
Returns the current log level
local ret = Server.GetLogLevel()
Returns
| Type | Descrição |
|---|---|
| integer | the log level |

GetTickRateOptimal
Returns the Configured Tick Rate
local ret = Server.GetTickRate()
Returns
| Type | Descrição |
|---|---|
| integer | the server Tick Rate |

GetTimeOptimal
Gets the Unix Epoch Time in milliseconds
local ret = Server.GetTime()
Returns
| Type | Descrição |
|---|---|
| integer | the unix timestamp |

GetVersionOptimal
Returns the server version
local ret = Server.GetVersion()
Returns
| Type | Descrição |
|---|---|
| string | the server version |
Lifecyclestatic functions

RestartSlow
Restarts the server, reloading all Packages and reconnecting all Players
Server.Restart()

SubscribeOptimal
Subscribes for an Event
local ret = Server.Subscribe(event_name, callback)
Returns
| Type | Descrição |
|---|---|
| function | the function callback itself |

UnsubscribeOptimal
Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
Server.Unsubscribe(event_name, callback?)
Moderationstatic functions

BanBySteamIDModerate
Bans the player from the server by its Steam ID, ideal for banning from inside PlayerConnect event
The Steam ID is added to banned_ids in the Config.toml, and the player is kicked if connected. It also works for players who are not connected
Server.BanBySteamID(player_steam_id, reason)

KickBySteamIDModerate
Kicks the player from the server by its Steam ID, ideal for kicking from inside PlayerConnect event or while holding the connection
Server.KickBySteamID(player_steam_id, reason)

UnbanModerate
Unbans a Player by its Steam ID
Server.Unban(player_steam_id)
Parameters
| Name | Type | Descrição |
|---|---|---|
player_steam_id | string | The Player's Steam ID (SteamID64) |
Networkstatic functions

GetConnectionCountOptimal
Returns the number of connected players (including players in the process of connecting)
local ret = Server.GetConnectionCount()
Returns
| Type | Descrição |
|---|---|
| integer | Number of connected players |

GetHeldConnectionsModerate
Returns all players currently held in the loading screen
Useful to rebuild your queue after reloading the package
local ret = Server.GetHeldConnections()
See also HoldConnection, ReleaseConnection.

GetIPOptimal
Returns the server Public IP
local ret = Server.GetIP()
Returns
| Type | Descrição |
|---|---|
| string | the server Public IP |

GetPortOptimal
Returns the server Port
local ret = Server.GetPort()
Returns
| Type | Descrição |
|---|---|
| integer | the server Port |

GetQueryPortOptimal
Returns the server QueryPort
local ret = Server.GetQueryPort()
Returns
| Type | Descrição |
|---|---|
| integer | the server QueryPort |

HoldConnectionModerate
Holds a connecting player in the loading screen with a message, before he starts downloading the server files
Only works from inside the PlayerConnect event, or on a connection already held, which only updates its message (e.g. his position in your queue). The player waits until you call Server.ReleaseConnection() or kick him, which lets you verify him asynchronously (database, web API) or build your own queue.
Held players are not counted in max_players nor shown in the server list. If the server is full, new connections only get in up to max_held_connections from the Config.toml, which is 0 by default (full servers refuse new players)
local ret = Server.HoldConnection(player_steam_id, message)
Parameters
| Name | Type | Descrição |
|---|---|---|
player_steam_id | string | The Player's Steam ID (SteamID64) |
message | string | Plain text shown in the loading screen, up to 256 bytes |
Returns
| Type | Descrição |
|---|---|
| boolean | If the connection is now held |
See also ReleaseConnection, GetHeldConnections, PlayerConnect.

IsAnnouncedOptimal
Returns if the Server is announced in the Master List
local ret = Server.IsAnnounced()
Returns
| Type | Descrição |
|---|---|
| boolean | if the Server is announced in the Master List |

ReleaseConnectionModerate
Lets a held player in, he starts downloading the server files and joins as usual
Returns false if the server is full (max_players is always respected) or the player is not held, in which case he stays held
local ret = Server.ReleaseConnection(player_steam_id)
Parameters
| Name | Type | Descrição |
|---|---|---|
player_steam_id | string | The Player's Steam ID (SteamID64) |
Returns
| Type | Descrição |
|---|---|
| boolean | If the player was let in |
See also HoldConnection, GetHeldConnections.
Packagesstatic functions

GetPackagesSlow
Returns a list of Packages running, optionally returns all Packages installed in the server
local ret = Server.GetPackages(only_loaded?, package_type_filter?)
Parameters
| Name | Type | Descrição |
|---|---|---|
only_loaded? | boolean | Set to true the function return only loaded and running packages. Caution: setting to false will retrieve Packages list from disk, which is a slow operation! Default true |
package_type_filter? | PackageType | Which Package type to return. Leave it default to return all types Default PackageType.All |

IsPackageLoadedOptimal
Returns if a Package is currently loaded
local ret = Server.IsPackageLoaded(package_name)
Parameters
| Name | Type | Descrição |
|---|---|---|
package_name | string | The package folder name |
Returns
| Type | Descrição |
|---|---|
| boolean | If the package is loaded |

LoadPackageSlow
Loads a Package
local ret = Server.LoadPackage(package_folder_name)
Parameters
| Name | Type | Descrição |
|---|---|---|
package_folder_name | string | The package to load |
Returns
| Type | Descrição |
|---|---|
| boolean | if the Package was loaded |
See also ReloadPackage, UnloadPackage.

ReloadPackageSlow
Reloads a Package on the next server tick
Reloads a Package
Note: the package is effectively reloaded in the next server tick
local ret = Server.ReloadPackage(package_folder_name)
Parameters
| Name | Type | Descrição |
|---|---|---|
package_folder_name | string | The package to reload |
Returns
| Type | Descrição |
|---|---|
| boolean | if the Package was found |
See also LoadPackage, UnloadPackage.

UnloadPackageSlow
Unloads a Package
Note: the package is effectively unloaded in the next server tick
local ret = Server.UnloadPackage(package_folder_name)
Parameters
| Name | Type | Descrição |
|---|---|---|
package_folder_name | string | The package you want unload |
Returns
| Type | Descrição |
|---|---|
| boolean | if the Package was found |
See also LoadPackage, ReloadPackage.
Settingsstatic functions

GetCustomSettingsSlow
Returns the Server Custom Settings passed as parameter or New Game screen
local ret = Server.GetCustomSettings()

GetDefaultEntityDimensionOptimal
Returns the default entity dimension
local ret = Server.GetDefaultEntityDimension()
Returns
| Type | Descrição |
|---|---|
| integer | Default entity dimension |
See also SetDefaultEntityDimension.

GetDefaultPlayerDimensionOptimal
Returns the default player dimension
local ret = Server.GetDefaultPlayerDimension()
Returns
| Type | Descrição |
|---|---|
| integer | Default player dimension |
See also SetDefaultPlayerDimension.

GetDescriptionOptimal
Returns the Server Description
local ret = Server.GetDescription()
Returns
| Type | Descrição |
|---|---|
| string | the Server Description |
See also SetDescription.

GetMaxPlayersOptimal
Returns the Max Players configured
local ret = Server.GetMaxPlayers()
Returns
| Type | Descrição |
|---|---|
| integer | the max players configured |
See also SetMaxPlayers.

GetNameOptimal
Returns the Server Name
local ret = Server.GetName()
Returns
| Type | Descrição |
|---|---|
| string | The Server Name |
See also SetName.

IsUnsafeLibsEnabledOptimal
Returns if the server was started with --enable_unsafe_libs
local ret = Server.IsUnsafeLibsEnabled()
Returns
| Type | Descrição |
|---|---|
| boolean | Whether the server was started with --enable_unsafe_libs |

SetDefaultEntityDimensionOptimal
Sets the default server dimension that entities will spawn in
You can change it before spawning an entity and restore it afterwards to just spawn a specific entity directly on it
Server.SetDefaultEntityDimension(default_dimension)
Parameters
| Name | Type | Descrição |
|---|---|---|
default_dimension | integer | The new default server dimension that entities will spawn in |
See also GetDefaultEntityDimension.

SetDefaultPlayerDimensionOptimal
Sets the default server dimension that players will spawn in
Server.SetDefaultPlayerDimension(default_dimension)
Parameters
| Name | Type | Descrição |
|---|---|---|
default_dimension | integer | The new default server dimension that players will spawn in |
See also GetDefaultPlayerDimension.

SetDescriptionOptimal
Sets the description of the server, optionally overrides Config.toml
Server.SetDescription(description, persist_to_config_file?)
Parameters
| Name | Type | Descrição |
|---|---|---|
description | string | The new description |
persist_to_config_file? | boolean | Persist to config file Default false |
See also GetDescription.

SetLogoOptimal
Sets the logo of the server, optionally overrides Config.toml
Server.SetLogo(logo_url, persist_to_config_file?)

SetMaxPlayersOptimal
Sets the maximum player slots of the server, optionally overrides Config.toml
Server.SetMaxPlayers(max_players, persist_to_config_file?)
Parameters
| Name | Type | Descrição |
|---|---|---|
max_players | integer | The maximum players |
persist_to_config_file? | boolean | Persist to config file Default false |
See also GetMaxPlayers.

SetNameOptimal
Sets the name of the server, optionally overrides Config.toml
Server.SetName(name, persist_to_config_file?)
Parameters
| Name | Type | Descrição |
|---|---|---|
name | string | The new name |
persist_to_config_file? | boolean | Persist to config file Default false |
See also GetName.

SetPasswordOptimal
Sets the password of the server, optionally overrides Config.toml
Server.SetPassword(password, persist_to_config_file?)
Worldstatic functions

AddMapSpawnPointOptimal
Adds a spawn point to the current map's spawn points list
Server.AddMapSpawnPoint(location, rotation?)
Parameters
| Name | Type | Descrição |
|---|---|---|
location | Vector | Spawn location |
rotation? | Rotator | Spawn rotation Default Rotator() |
See also GetMapSpawnPoints.

ChangeMapSlow
Restarts the server in a new Map, restarts all packages and reconnects all players
Server.ChangeMap(map_path)
Parameters
| Name | Type | Descrição |
|---|---|---|
map_path | string | The new map to load |

GetActorsInRadiusModerate
Returns the actors within the specified radius
local ret = Server.GetActorsInRadius(location, radius, only_classes?, dimension?)
Parameters
| Name | Type | Descrição |
|---|---|---|
location | Vector | The center location of the search |
radius | number | The search radius |
only_classes? | table of string | Only actors of these classes will be returned (pass empty for all classes) Default [] |
dimension? | integer | The dimension to search in (pass 0 for all dimensions) Default 0 |
Returns
| Type | Descrição |
|---|---|
| table of Base Actor | The actors found in radius |

GetEntityByIDModerate
Returns the entity with the specified ID
local ret = Server.GetEntityByID(entity_id)
Parameters
| Name | Type | Descrição |
|---|---|---|
entity_id | integer | The entity ID |
Returns
| Type | Descrição |
|---|---|
| Base Entity or nil | the entity |

GetMapOptimal
Returns the current Map Package name
local ret = Server.GetMap()
Returns
| Type | Descrição |
|---|---|
| string | the current map package |

GetMapAssetOptimal
Returns the current Map Asset reference
local ret = Server.GetMapAsset()
Returns
| Type | Descrição |
|---|---|
| string | the current map asset |

GetMapConfigSlow
Returns a list of the Custom Config of the current map (defined in the map package's Package.toml)
local ret = Server.GetMapConfig()
Returns
| Type | Descrição |
|---|---|
| table | a list of the Custom Config of the current map |

GetMapSpawnPointsModerate
Returns a list of the Spawn Points of the current map (defined in the map package's Package.toml)
local ret = Server.GetMapSpawnPoints()
See also AddMapSpawnPoint.

GetPlayersInRadiusModerate
Returns the players within the specified radius
local ret = Server.GetPlayersInRadius(location, radius, dimension?)
🚀 Events
ChangeMap | Called when the map changes | |
PackageLoad | Triggered when any package is loaded | |
PackageUnload | Triggered when any package is unloaded | |
PlayerConnect | Called when a player is attempting to connect to the server, after Steam authenticated him | |
PlayerDisconnect | Called when a player is disconnecting from the server | |
Restart | Triggered when the server is restarting | |
Start | Triggered once when the server has started and all packages are loaded | |
Stop | Triggered when the server is stopping | |
Tick | Triggered every 33ms by default | |
ValueChange | Triggered when a Value is changed with Server.SetValue() |

ChangeMap
Called when the map changes
This is always called just before Restart event
Server.Subscribe("ChangeMap", function(old_map, new_map)
-- ChangeMap was called
end)

PackageLoad
Triggered when any package is loaded
Server.Subscribe("PackageLoad", function(package_name)
-- PackageLoad was called
end)
Arguments
| Name | Type | Descrição |
|---|---|---|
package_name | string | The package name (its folder name) |
See also GetPackages, IsPackageLoaded, LoadPackage, UnloadPackage, ReloadPackage.

PackageUnload
Triggered when any package is unloaded
Server.Subscribe("PackageUnload", function(package_name)
-- PackageUnload was called
end)
Arguments
| Name | Type | Descrição |
|---|---|---|
package_name | string | The package name (its folder name) |
See also GetPackages, IsPackageLoaded, LoadPackage, UnloadPackage, ReloadPackage.

PlayerConnect
Called when a player is attempting to connect to the server, after Steam authenticated him
It is called before the Player entity is created and before he starts downloading the server files.
To refuse the connection, call Server.KickBySteamID() or Server.BanBySteamID() with the player_steam_id (returning false is deprecated). To decide later (e.g. after an asynchronous check, or to make him wait in a queue), call Server.HoldConnection()
Server.Subscribe("PlayerConnect", function(ip, player_account_id, player_name, player_steam_id)
-- PlayerConnect was called
end)
Arguments
| Name | Type | Descrição |
|---|---|---|
ip | string | IP of the player |
player_account_id | string | Account ID of the player |
player_name | string | Player name |
player_steam_id | string | SteamID of the player |
See also KickBySteamID, BanBySteamID, HoldConnection, PlayerDisconnect.

PlayerDisconnect
Called when a player is disconnecting from the server
It is also called for players who never fully connected, including the ones held with Server.HoldConnection()
Server.Subscribe("PlayerDisconnect", function(ip, player_account_id, player_name, player_steam_id, disconnect_reason)
-- PlayerDisconnect was called
end)
Arguments
| Name | Type | Descrição |
|---|---|---|
ip | string | IP of the player |
player_account_id | string | Account ID of the player |
player_name | string | Player name |
player_steam_id | string | SteamID of the player |
disconnect_reason | string | Reason for disconnection |
See also PlayerConnect.

Restart
Triggered when the server is restarting
Server.Subscribe("Restart", function()
-- Restart was called
end)

Start
Triggered once when the server has started and all packages are loaded
Server.Subscribe("Start", function()
-- Start was called
end)

Stop
Triggered when the server is stopping
Server.Subscribe("Stop", function()
-- Stop was called
end)


