Gamemode
The base class for a gamemode. The server creates one instance and calls its events on the main thread.
Base class for a gamemode. The server creates one instance and calls its events on the main thread, one at a time. An exception in an event is written to the server log and doesn't stop the server.
Attribute#
[Gamemode(string id, Version = "x.y.z", Description = "...")]#
Marks the class the server loads. The id is lower-case, is what server.json names in "gameMode", and is shown in the server's status (and so in the launcher's server list).
Events#
virtual void OnServerStart()#
Called once after the world has loaded, before any player is handed to the gamemode. Players who connected during loading arrive right after it.
virtual void OnPlayerJoined(Player player)#
Called when a player has connected. Their character isn't in the world yet unless SpawnOnJoin is true. See Player.
virtual void OnPlayerLeft(Player player)#
Called when a player disconnects. The player object is still readable during the call; IsConnected is false afterwards.
virtual void OnTick(float deltaSeconds)#
Called every server frame. Keep it light.
virtual void OnServerStop()#
Called before shutdown. Storage is flushed after it returns.
Properties#
virtual bool SpawnOnJoin#
true (the default): the engine spawns players as soon as they join and respawns them after death, as in freeroam. false: players stay out of the world until the gamemode calls player.Spawn(...); after that the engine respawns them as usual.
IReadOnlyList<Player> Players#
Everyone currently connected.