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 OnPlayerLogin for the logged-in and
OnPlayerSpawn for those already in the world.
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(), COLOUR_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
