Server¶
Tip
This is a Static Class named Server
. You can access it’s methods directly with :
. It is not possible to initialize or create new instances.
Note
This is a Server only Class.
Functions¶
Name |
Description |
BroadcastChatMessage(string Message) |
Sends a chat message to everyone |
ChangeMap(string MapPath) |
Restarts the server in a new Map, restarts all packages and reconnects all players |
HTTPRequest(string URI, string Endpoint = “”, string Method = “GET”, string Data = “”, table[string] Headers = {}, function Callback = nil) |
Makes a HTTP Request, the result will be returned in the provided Callback function in the format (Status, Response) |
ReloadPackage(string PackageFolderName) |
Reloads a Package |
Sends a chat message to Player only |
|
UnloadPackage(string PackageFolderName) |
Unloads a Package |
Events¶
Name |
Parameters |
Description |
Chat |
Called when a player types something in the chat - return false to do not send the message |
|
Console |
string Text |
Called when a console command is submitted |
Start |
Server has been started. |
|
Stop |
Server has been stopped. |
|
Tick |
number DeltaTime |
Is called every 30 ms by default. Only small operations should be performed here, otherwise this can lead the server to delays. |
Examples¶
-- prints "Server started" when the server is starting
Server:on("Start", function()
Package:Log("Server started")
end)
-- prints "Server stopped" when the server stops / shutdown
Server:on("Stop", function()
Package:Log("Server stopped")
end)
-- prints the tick-delta time about every 30 ms
Server:on("Tick", function(ticktime)
Package:Log("Tick: " .. ticktime)
end)
-- sends a chat message to everyone
Server:BroadcastChatMessage("Welcome to the server!")
-- makes a HTTP Request
Server:HTTPRequest("localhost:7777", "/fetch", "GET", "", {}, function(status, data)
Package:Log(status) -- 200
Package:Log(data)
local json_ret = JSON.parse(data)
-- ...
end)