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

SendChatMessage(Player Player, string Message)

Sends a chat message to Player only

UnloadPackage(string PackageFolderName)

Unloads a Package

ReloadPackage(string PackageFolderName)

Reloads a Package

LoadPackage(string PackageFolderName)

Loads a Package

Events

Name

Parameters

Description

Chat

Player, string Text

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()
    print("Server started")
end)

-- prints "Server stopped" when the server stops / shutdown
Server:on("Stop", function()
    print("Server stopped")
end)

-- prints the tick-delta time about every 30 ms
Server:on("Tick", function(ticktime)
    print("Tick: " .. ticktime)
end)

-- sends a chat message to everyone
Server:BroadcastChatMessage("Welcome to the server!")