💻 Server
Server represents all Server controls in the Server side.

🗿Static Class
This is a Static Class. Access it's methods directly with
.. It's not possible to spawn new instances.💂Authority
This static class can be accessed only on 🟦 Server side.
🧑💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!
🎒 Examples
Server/Index.lua
-- 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
| Returns | Name | Description | |
|---|---|---|---|
AddMapSpawnPoint | Adds a spawn point to the current map's spawn points list | ||
BanByAccountID | Ban the player from the server by it's Account ID, ideal for banning from inside PlayerConnect event | ||
ChangeMap | Restarts the server in a new Map, restarts all packages and reconnects all players | ||
| table of Base Actor | GetActorsInRadius | Returns the actors within the specified radius | |
| table of string | GetAllValuesKeys | Gets a list of all values keys | |
| integer | GetCompressionLevel | Returns the server Compression Level being used | |
| integer | GetConnectionCount | Returns the number of connected players (including players in the process of connecting) | |
| table of table | GetCustomSettings | Returns the Server Custom Settings passed as parameter or New Game screen | |
| integer | GetDefaultEntityDimension | Returns the default entity dimension | |
| integer | GetDefaultPlayerDimension | Returns the default player dimension | |
| string | GetDescription | Returns the Server Description | |
| Base Entity or nil | GetEntityByID | Returns the entity with the specified ID | |
| string | GetIP | Returns the server Public IP | |
| integer | GetLogLevel | Returns the current log level | |
| string | GetMap | Returns the current Map Package name | |
| string | GetMapAsset | Returns the current Map Asset reference | |
| table | GetMapConfig | Returns a list of the Custom Config of the current map (stored in the MAP_NAME.toml) | |
| table of table | GetMapSpawnPoints | Returns a list of the Spawn Points of the current map (stored in the MAP_NAME.toml) | |
| integer | GetMaxPlayers | Returns the Max Players configured | |
| string | GetName | Returns the Server Name | |
| table of table | GetPackages | Returns a list of Packages running, optionally returns all Packages installed in the server | |
| table of Player | GetPlayersInRadius | Returns the players within the specified radius | |
| integer | GetPort | Returns the server Port | |
| integer | GetQueryPort | Returns the server QueryPort | |
| integer | GetTickRate | Returns the Configured Tick Rate | |
| integer | GetTime | Gets the Unix Epoch Time in milliseconds | |
| any | GetValue | Gets a value given a key | |
| string | GetVersion | Returns the server version | |
| boolean | IsAnnounced | Returns if the Server is announced in the Master List | |
| boolean | IsPackageLoaded | Returns if a Package is currently loaded | |
KickByAccountID | Kicks the player from the server by it's Account ID, ideal for kicking from inside PlayerConnect event | ||
| boolean | LoadPackage | Loads a Package | |
| boolean | ReloadPackage | No description provided | |
Restart | Restarts the server, reloading all Packages and reconnecting all Players | ||
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 | ||
SetValue | Sets a global value in the Server, which can be accessed from anywhere (server side) | ||
Stop | Stops the server | ||
| function | Subscribe | Subscribes for an Event | |
Unban | Unbans a Player by it's account ID | ||
| boolean | UnloadPackage | Unloads a Package | |
Unsubscribe | Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback |

AddMapSpawnPoint
Adds a spawn point to the current map's spawn points list
Server.AddMapSpawnPoint(location, rotation?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | location | Required parameter | Spawn location |
| Rotator | rotation? | Rotator() | Spawn rotation |
See also GetMapSpawnPoints.

BanByAccountID
Ban the player from the server by it's Account ID, ideal for banning from inside PlayerConnect event
Server.BanByAccountID(player_account_id, reason)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | player_account_id | Required parameter | No description provided |
| string | reason | Required parameter | No description provided |

ChangeMap
Restarts the server in a new Map, restarts all packages and reconnects all players
Server.ChangeMap(map_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | map_path | Required parameter | The new map to load |

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

GetAllValuesKeys
Gets a list of all values keys
local ret = Server.GetAllValuesKeys()

GetCompressionLevel
Returns the server Compression Level being used
local ret = Server.GetCompressionLevel()
Returns
| Type | Description |
|---|---|
| integer | the server Compression Level |

GetConnectionCount
Returns the number of connected players (including players in the process of connecting)
local ret = Server.GetConnectionCount()
Returns
| Type | Description |
|---|---|
| integer | No description provided |

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

GetDefaultEntityDimension
Returns the default entity dimension
local ret = Server.GetDefaultEntityDimension()
Returns
| Type | Description |
|---|---|
| integer | No description provided |
See also SetDefaultEntityDimension.

GetDefaultPlayerDimension
Returns the default player dimension
local ret = Server.GetDefaultPlayerDimension()
Returns
| Type | Description |
|---|---|
| integer | No description provided |
See also SetDefaultPlayerDimension.

GetDescription
Returns the Server Description
local ret = Server.GetDescription()
Returns
| Type | Description |
|---|---|
| string | the Server Description |
See also SetDescription.

GetEntityByID
Returns the entity with the specified ID
local ret = Server.GetEntityByID(entity_id)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | entity_id | Required parameter | No description provided |
Returns
| Type | Description |
|---|---|
| Base Entity or nil | the entity |

GetIP
Returns the server Public IP
local ret = Server.GetIP()
Returns
| Type | Description |
|---|---|
| string | the server Public IP |

GetLogLevel
Returns the current log level
local ret = Server.GetLogLevel()
Returns
| Type | Description |
|---|---|
| integer | the log level |

GetMap
Returns the current Map Package name
local ret = Server.GetMap()
Returns
| Type | Description |
|---|---|
| string | the current map package |

GetMapAsset
Returns the current Map Asset reference
local ret = Server.GetMapAsset()
Returns
| Type | Description |
|---|---|
| string | the current map asset |

GetMapConfig
Returns a list of the Custom Config of the current map (stored in the MAP_NAME.toml)
local ret = Server.GetMapConfig()
Returns
| Type | Description |
|---|---|
| table | a list of the Custom Config of the current map |

GetMapSpawnPoints
Returns a list of the Spawn Points of the current map (stored in the MAP_NAME.toml)
local ret = Server.GetMapSpawnPoints()
See also AddMapSpawnPoint.

GetMaxPlayers
Returns the Max Players configured
local ret = Server.GetMaxPlayers()
Returns
| Type | Description |
|---|---|
| integer | the max players configured |
See also SetMaxPlayers.

GetName
Returns the Server Name
local ret = Server.GetName()
Returns
| Type | Description |
|---|---|
| string | The Server Name |
See also SetName.

GetPackages
Returns a list of Packages running, optionally returns all Packages installed in the server
local ret = Server.GetPackages(only_loaded?, package_type_filter?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | only_loaded? | true | 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! |
| PackageType | package_type_filter? | PackageType.All | Which Package type to return. Leave it default to return all types. |

GetPlayersInRadius
Returns the players within the specified radius
local ret = Server.GetPlayersInRadius(location, radius, dimension?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | location | Required parameter | The center location of the search |
| number | radius | Required parameter | The search radius |
| integer | dimension? | 0 | The dimension to search in |

GetPort
Returns the server Port
local ret = Server.GetPort()
Returns
| Type | Description |
|---|---|
| integer | the server Port |

GetQueryPort
Returns the server QueryPort
local ret = Server.GetQueryPort()
Returns
| Type | Description |
|---|---|
| integer | the server QueryPort |

GetTickRate
Returns the Configured Tick Rate
local ret = Server.GetTickRate()
Returns
| Type | Description |
|---|---|
| integer | the server Tick Rate |

GetTime
Gets the Unix Epoch Time in milliseconds
local ret = Server.GetTime()
Returns
| Type | Description |
|---|---|
| integer | the unix timestamp |

GetValue
Gets a value given a key
local ret = Server.GetValue(key, fallback)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | key | Required parameter | Key |
| any | fallback | Required parameter | Fallback Value if key doesn't exist |
Returns
| Type | Description |
|---|---|
| any | Value at key or fallback if key doesn't exist |
See also GetAllValuesKeys, SetValue.

GetVersion
Returns the server version
local ret = Server.GetVersion()
Returns
| Type | Description |
|---|---|
| string | the server version |

IsAnnounced
Returns if the Server is announced in the Master List
local ret = Server.IsAnnounced()
Returns
| Type | Description |
|---|---|
| boolean | if the Server is announced in the Master List |

IsPackageLoaded
Returns if a Package is currently loaded
local ret = Server.IsPackageLoaded(package_name)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | package_name | Required parameter | No description provided |
Returns
| Type | Description |
|---|---|
| boolean | If the package is loaded |

KickByAccountID
Kicks the player from the server by it's Account ID, ideal for kicking from inside PlayerConnect event
Server.KickByAccountID(player_account_id, reason)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | player_account_id | Required parameter | No description provided |
| string | reason | Required parameter | No description provided |

LoadPackage
Loads a Package
local ret = Server.LoadPackage(package_folder_name)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | package_folder_name | Required parameter | The package to load |
Returns
| Type | Description |
|---|---|
| boolean | if the Package was loaded |
See also ReloadPackage, UnloadPackage.

ReloadPackage
Reloads a Package
Note: the package is effectively reloaded in the next server tick
local ret = Server.ReloadPackage(package_folder_name)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | package_folder_name | Required parameter | The package to reload |
Returns
| Type | Description |
|---|---|
| boolean | if the Package was found |
See also LoadPackage, UnloadPackage.

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

SetDefaultEntityDimension
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
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | default_dimension | Required parameter | No description provided |
See also GetDefaultEntityDimension.

SetDefaultPlayerDimension
Sets the default server dimension that players will spawn in
Server.SetDefaultPlayerDimension(default_dimension)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | default_dimension | Required parameter | No description provided |
See also GetDefaultPlayerDimension.

SetDescription
Sets the description of the server, optionally overrides Config.toml
Server.SetDescription(description, persist_to_config_file?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | description | Required parameter | The new description |
| boolean | persist_to_config_file? | false | Persist to config file |
See also GetDescription.

SetLogo
Sets the logo of the server, optionally overrides Config.toml
Server.SetLogo(logo_url, persist_to_config_file?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | logo_url | Required parameter | The new logo |
| boolean | persist_to_config_file? | false | Persist to config file |

SetMaxPlayers
Sets the maximum player slots of the server, optionally overrides Config.toml
Server.SetMaxPlayers(max_players, persist_to_config_file?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | max_players | Required parameter | The maximum players |
| boolean | persist_to_config_file? | false | Persist to config file |
See also GetMaxPlayers.

SetName
Sets the name of the server, optionally overrides Config.toml
Server.SetName(name, persist_to_config_file?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | name | Required parameter | The new name |
| boolean | persist_to_config_file? | false | Persist to config file |
See also GetName.

SetPassword
Sets the password of the server, optionally overrides Config.toml
Server.SetPassword(password, persist_to_config_file?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | password | Required parameter | The new password |
| boolean | persist_to_config_file? | false | Persist to config file |

SetValue
Sets a global value in the Server, which can be accessed from anywhere (server side)
Server.SetValue(key, value, sync_on_client?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | key | Required parameter | Key |
| any | value | Required parameter | Value |
| boolean | sync_on_client? | false | If enabled will sync this value through all clients, accessible through Client.GetValue() static class |
See also GetAllValuesKeys, GetValue, ValueChange.

Stop
Stops the server
Server.Stop()

Subscribe
Subscribes for an Event
local ret = Server.Subscribe(event_name, function)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | event_name | Required parameter | The name of the Event |
| function | function | Required parameter | Callback function |
Returns
| Type | Description |
|---|---|
| function | the function callback itself |

Unban
Unbans a Player by it's account ID
Server.Unban(account_id)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | account_id | Required parameter | nanos account ID |

UnloadPackage
Unloads a Package
Note: the package is effectively unloaded in the next server tick
local ret = Server.UnloadPackage(package_folder_name)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | package_folder_name | Required parameter | The package you want unload |
Returns
| Type | Description |
|---|---|
| boolean | if the Package was found |
See also LoadPackage, ReloadPackage.

Unsubscribe
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, function?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | event_name | Required parameter | The name of the Events |
| function | function? | nil | Callback function |
🚀 Events
| Name | Description | |
|---|---|---|
ChangeMap | Called when the map changes | |
PlayerConnect | Called when a player is attempting to connect to the server | |
PlayerDisconnect | Called when a player is disconnecting from the server | |
Restart | Server has been restarted | |
Start | Server has been started | |
Stop | Server has been stopped | |
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)
Arguments
| Type | Argument | Description |
|---|---|---|
| string | old_map | No description provided |
| string | new_map | No description provided |

PlayerConnect
Called when a player is attempting to connect to the server
Use Server.KickByAccountID() or Server.BanByAccountID() to kick or ban the player from inside this event.
Server.Subscribe("PlayerConnect", function(IP, player_account_ID, player_name, player_steam_ID)
-- PlayerConnect was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| string | IP | IP of the player |
| string | player_account_ID | Account ID of the player |
| string | player_name | Player name |
| string | player_steam_ID | SteamID of the player |
See also KickByAccountID, BanByAccountID, PlayerDisconnect.

PlayerDisconnect
Called when a player is disconnecting from the server
Server.Subscribe("PlayerDisconnect", function(IP, player_account_ID, player_name, player_steam_ID, disconnect_reason)
-- PlayerDisconnect was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| string | IP | IP of the player |
| string | player_account_ID | Account ID of the player |
| string | player_name | Player name |
| string | player_steam_ID | SteamID of the player |
| string | disconnect_reason | Reason for disconnection |
See also PlayerConnect.

Restart
Server has been restarted
Server.Subscribe("Restart", function()
-- Restart was called
end)

Start
Server has been started
Server.Subscribe("Start", function()
-- Start was called
end)

Stop
Server has been stopped
Server.Subscribe("Stop", function()
-- Stop was called
end)

Tick
Triggered every 33ms by default
Caution: Only small operations should be performed here, otherwise this can lead to server lag and delays
Server.Subscribe("Tick", function(delta_time)
-- Tick was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| float | delta_time | No description provided |

ValueChange
Triggered when a Value is changed with Server.SetValue()Server.Subscribe("ValueChange", function(key, value)
-- ValueChange was called
end)
See also SetValue.