π» Server
Server represents all Server controls in the Server side
info
π¦ Authority: This can be accessed only on Server.
πΏ Static Class: This is a Static Class. You can access itβs methods directly with .
. It is not possible to initialize or create new instances.
Usageβ
-- prints "Server started" when the server is starting
Server.Subscribe("Start", function()
Package.Log("Server started")
end)
-- prints "Server stopped" when the server stops / shutdown
Server.Subscribe("Stop", function()
Package.Log("Server stopped")
end)
-- prints the delta time about every 30 ms
Server.Subscribe("Tick", function(delta_time)
Package.Log("Tick: " .. delta_time)
end)
-- sends a chat message to everyone
Server.BroadcastChatMessage("Welcome to the server!")
Functionsβ
Returns | Name | Description |
---|---|---|
BroadcastChatMessage | Sends a chat message to everyone | |
ChangeMap | Restarts the server in a new Map, restarts all packages and reconnects all players | |
ReloadPackage | Reloads a Package | |
SendChatMessage | Sends a chat message to Player only | |
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) | |
GetValue | Gets a value given a key | |
Stop | Stops the server | |
function | Subscribe | Subscribes for an Event |
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 | |
string | GetMap | Returns the current Map |
table | GetMapConfig | Returns a list of the Custom Config of the current map (stored in the MAP_NAME.toml) |
table | GetMaps | Returns a list of all Maps installed on the server |
table | GetPackages | Returns a list of Packages folder names available in the server, optionally returns only loaded and running packages |
string | GetVersion | Returns the server version |
string | GetIP | Returns the server Public IP |
number | GetPort | Returns the server Port |
number | GetQueryPort | Returns the server QueryPort |
number | GetMaxPlayers | Returns the Max Players configured |
number | GetDescription | Returns the Server Description |
number | GetTickRate | Returns the Configured Tick Rate |
number | IsAnnounced | Returns if the Server is announced in the Master List |
Eventsβ
Name | Description |
---|---|
Chat | Called when a player types something in the chat - return false to do not send the message |
Console | Called when a console command is submitted |
LogEntry | Called when a Server log is received |
Start | Server has been started. |
PlayerConnect | Called when a player is attempting to connect to the server - return false to do not allow it |
Stop | Server has been stopped. |
Tick | Is called every 30 ms by default. Only small operations should be performed here, otherwise this can lead the server to delays. |
Functions Detailedβ
BroadcastChatMessage
β
Sends a chat message to everyone
Server.BroadcastChatMessage(message)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | message |
ChangeMap
β
Restarts the server in a new Map, restarts all packages and reconnects all players
Server.ChangeMap(map_path)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | map_path |
ReloadPackage
β
Reloads a Package
Server.ReloadPackage(package_folder_name)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | package_folder_name |
SendChatMessage
β
Sends a chat message to Player only
Server.SendChatMessage(player, message)
Type | Parameter | Default Value | Description |
---|---|---|---|
Player | player | ||
string | message |
SetDescription
β
Sets the description of the server, optionally overrides Config.toml
Server.SetDescription(description, persist_to_config_file)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | description | ||
boolean | persist_to_config_file | false |
SetLogo
β
Sets the logo of the server, optionally overrides Config.toml
Server.SetLogo(logo_url, persist_to_config_file)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | logo_url | ||
boolean | persist_to_config_file | false |
SetMaxPlayers
β
Sets the maximum player slots of the server, optionally overrides Config.toml
Server.SetMaxPlayers(max_players, persist_to_config_file)
Type | Parameter | Default Value | Description |
---|---|---|---|
number | max_players | ||
boolean | persist_to_config_file | false |
SetName
β
Sets the name of the server, optionally overrides Config.toml
Server.SetName(name, persist_to_config_file)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | name | ||
boolean | persist_to_config_file | false |
SetPassword
β
Sets the password of the server, optionally overrides Config.toml
Server.SetPassword(password, persist_to_config_file)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | password | ||
boolean | persist_to_config_file | false |
SetValue
β
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)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | key | Key | |
any | value | Value |
GetValue
β
Gets a value given a key. Please refer to Entity Values for more information
Returns any
Server.GetValue(key, fallback)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | key | Key | |
any | fallback | Fallback Value if key doesn't exist |
Stop
β
Stops the server
Server.Stop()
Subscribe
β
Subscribes for an Event
Returns the function callback itself
Server.Subscribe(event_name, callback)
Type | Parameter | Description |
---|---|---|
string | event_name | |
function | function |
UnloadPackage
β
Unloads a Package
Server.UnloadPackage(package_folder_name)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | package_folder_name |
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, callback)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | event_name | ||
function | function | nil |
GetMap
β
Returns the current Map
Returns string
Server.GetMap()
GetMapConfig
β
Returns a list of the Custom Config of the current map (stored in the MAP_NAME.toml)
Returns table
Server.GetMapConfig()
GetMaps
β
Returns a list of all Maps installed on the server
Returns a table in the format
{{ key, author, compatible_game_modes }, ...}
Server.GetPackages(only_loaded)
Type | Parameter | Default Value | Description |
---|---|---|---|
boolean | only_loaded | true |
GetPackages
β
Returns a list of Packages folder names available in the server, optionally returns only loaded and running packages
Returns table
Server.GetPackages(only_loaded)
Type | Parameter | Default Value | Description |
---|---|---|---|
boolean | only_loaded | true |
GetVersion
β
Gets the server Version
Returns string
Server.GetVersion()
GetIP
β
Gets the server IP
Returns string
Server.GetIP()
GetPort
β
Gets the server Port
Returns number
Server.GetPort()
GetQueryPort
β
Gets the server QueryPort
Returns number
Server.GetQueryPort()
GetMaxPlayers
β
Gets the server Max Players allowed
Returns number
Server.GetMaxPlayers()
GetDescription
β
Gets the server Description
Returns string
Server.GetDescription()
GetTickRate
β
Gets the configured Tick Rate
Returns number
Server.GetTickRate()
IsAnnounced
β
Gets if the server is announced in the Master List
Returns boolean
Server.IsAnnounced()
Events Detailedβ
Chat
β
Called when a player types something in the chat - return false to do not send the message
Type | Parameter | Description |
---|---|---|
string | text | |
Player | sender |
Server.Subscribe("Chat", function(text, sender)
end)
Console
β
Called when a console command is submitted
Type | Parameter | Description |
---|---|---|
string | text |
Server.Subscribe("Console", function(text)
end)
LogEntry
β
Called when a Server log is received
Type | Parameter | Description |
---|---|---|
string | text | |
LogType | type |
Server.Subscribe("LogEntry", function(text, type)
end)
Start
β
Server has been started.
Server.Subscribe("Start", function()
end)
PlayerConnect
β
Called when a player is attempting to connect to the server Return false to do not allow it
Type | Parameter | Description |
---|---|---|
string | IP | |
string | player_account_ID | |
string | player_name | |
string | player_steam_ID |
Server.Subscribe("PlayerConnect", function(IP, player_account_ID, player_name, player_steam_ID)
end)
Stop
β
Server has been stopped.
Server.Subscribe("Stop", function()
end)
Tick
β
Is called every 30 ms by default. Only small operations should be performed here, otherwise this can lead the server to delays.
Type | Parameter | Description |
---|---|---|
number | delta_time |
Server.Subscribe("Tick", function(delta_time)
end)