Skip to content

Round Hooks

Hooks called at different stages of a round's life.

fh_prestartgame() HOOK SHARED

Called before the round type is selected.

Return false — cancel round selection.


fh_startgame(roundType) HOOK SERVER

Called after the round type is selected and basic round functions are executed (role distribution, freeze, Taser giving).

ArgumentTypeDescription
roundTypeintRound type ID

Return false — cancel timer start, music, etc.

Example: unique round with timer replacement. See Bonnie-Tag →

lua
hook.Add("fh_startgame", "AnnounceRound", function(roundType)
    local name = fh.GetRoundTypeNameByNumber(roundType)
    PrintMessage(HUD_PRINTTALK, "Round: " .. name)
end)

fh_poststartgame(roundType, animatronics) HOOK SHARED

Called after animatronics are unfrozen.

ArgumentTypeDescription
roundTypeintRound type ID
animatronicstable[Player]Players who are animatronics in this round
lua
hook.Add("fh_poststartgame", "BuffAnims", function(roundType, anims)
    for ply, _ in ipairs(anims) do
        ply:SetMaxHealth(150000)
        ply:SetHealth(150000)
    end
end)

fh_postendgame(killerVictory, animatronics) HOOK SHARED

Called after the round ends, before the timer to return to the lobby.

ArgumentTypeDescription
killerVictoryboolDid the animatronics win?
animatronicstable[Player]Animatronics from this round
lua
hook.Add("fh_postendgame", "RewardAnims", function(victory, anims)
    if not victory then
        -- Animatronics lost - explode them.
        for ply, _ in ipairs(anims) do
			local effectdata = EffectData()
			effectdata:SetOrigin(ply:GetPos())
			effectdata:SetScale(1)
			util.Effect("Explosion", effectdata)
			ply:Kill()
        end
    end
end)