OnGameModeInit
The script is loaded and the API is ready - the place to create zones, HUD texts, timers and actors.
Called once when the server starts and again after every hot reload. Everything the mode
creates - zones, HUD texts, props, actors, timers, state - is gone before it runs again, so this is where it is (re)made.
The players are told to the mode afterwards: OnPlayerConnect for everyone on, then OnPlayerSpawn for those already in
the world. The one place the mode’s database answers synchronously (QuerySync, ExecuteSync): the
tables a mode makes and the rules it loads before the first player.
Syntax
Section titled “Syntax”function OnGameModeInit() -- ...endReturns
Section titled “Returns”nothing
Example
Section titled “Example”local clock
function OnGameModeInit() Log("hello on " .. GetLevel() .. ", " .. GetMaxPlayers() .. " slots") clock = CreateHudText(0.99, 0.02, FormatWorldTime(), COLOR_YELLOW, 1.0, HUD_ALIGN_RIGHT) SetTimer(function() SetHudText(clock, FormatWorldTime()) end, 2000, true)endSee also
Section titled “See also”OnGameModeExit · SetTimer · ReloadGameMode · the Server and timers group of the index
