Skip to content

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.

function OnGameModeInit()
-- ...
end

nothing

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)
end

OnGameModeExit · SetTimer · ReloadGameMode · the Server and timers group of the index