Skip to content

FH Functions ​

Global gamemode functions. Use them to modify the behavior of rounds, animatronics, and gifts.

Animatronic management ​

giveKiller(ply, killer, [force]) SERVER ​

Assigns a player as an animatronic.

ParameterTypeDescription
plyPlayerWho to assign
killerstringName (e.g., "pill_wfreddy2")
forcebool (opt.)If true — assigns even if the same one is already present
lua
giveKiller(ply, "pill_springtrap", true)

giveKillerSilent(ply, killer, [force]) SERVER ​

Same as above, but without a chat notification.

Usage example →

TaseAnimatronic(ply) SERVER ​

If the player is an animatronic, tases them (like the Taser).

lua
TaseAnimatronic(ply)

restoreAnimatronics() SERVER ​

Removes the animatronic role from all current animatronics.

restoreAnimatronic(ply) SERVER ​

Removes the animatronic role from a specific player.


Gifts ​

doGiftSpawning() SERVER ​

Enables gift spawning on the map.

disableGiftSpawning() SERVER ​

Disables gift spawning.


Round information ​

fh.GetRoundCount() SERVER ​

Returns the current round number (integer).

fh.GetEarnedKillers(players) SERVER ​

Returns a table of players, sorted first by those who "earned" being an animatronic in this round.

lua
local candidates = fh.GetEarnedKillers(player.GetAll())

-- the first player in the table is often the one who hasn't been an animatronic the longest
giveKiller(candidates[1], "pill_wfreddy2")

fh.GetActiveUsedKiller(killer) SERVER ​

Returns the player who was given the specified animatronic.

lua
if fh.GetActiveUsedKiller("pill_wbonnie2") then
    print("Bonnie is already in the game!")
end

Note

If there is more than one animatronic with the name killer, the function will return the one that was assigned last.


Animatronic abilities ​

Where to use

These functions are intended for use inside animatronic Pill Packs or your own hooks that extend them.

performJumpscare(ply, ent, target, killDelay, [voiceCharacter], [jumpscareDistance], [wepClass]) SERVER ​

Forcefully screamers target for ply. Returns true if the screamer occurred, and false if not.

ParameterTypeDescription
plyPlayerThe animatronic
entEntityThe animatronic's model (pills.getMappedEnt(ply))
targetPlayerThe victim
killDelayfloatKill time
voiceCharacterstring (opt.)Technical name of the animatronic (used for playing voicelines)
jumpscareDistancefloat (opt.)Distance between the animatronic and victim
wepClassstring (opt.)Weapon class of the animatronic's hands, for which the scare animation will play

jumpscareEvent(ply, ent, target, [dist]) SERVER ​

Freezes the player and victim in a screamer. Call after playing the animation.

ParameterTypeDescription
plyPlayerThe animatronic
entEntityThe animatronic's model (pills.getMappedEnt(ply))
targetPlayerThe victim
distfloat (opt.)Distance between the animatronic and victim

endo.grabNeareastPlayer(ply, ent) SERVER ​

Used by the Endoskeleton to capture a player. Automatically finds a nearby target.

endo.endoRelease(ply) SERVER ​

Forces the animatronic to release a previously captured player.

endo.releaseExactPlayer(target) SERVER ​

Attempts to release target if they are being held by an animatronic using one of the above functions.

endo.isGrabbed(target) SERVER ​

Returns whether anyone is holding player target.


Target finding ​

FindNearestPlayer(origin, radius, ignorePlayer, fov) SHARED ​

Finds the nearest survivor within a radius.

ParameterTypeDescription
originVectorSearch point
radiusnumberRadius
ignorePlayerPlayerWho to ignore
fovnumberIf specified together with ignorePlayer — search only within the field of view cone

Perfect for choosing an attack target.

fh_get_nearest_players(origin, radius, ignorePlayer) SHARED ​

Returns a table of survivors within a radius. Used by the Clown when striking with a hammer.

fh_get_nearest_props(origin, radius) SHARED ​

Returns a table of props within a radius.


Animatronic registration ​

killers.Register(pill, name, fullname, color, category) SHARED ​

Registers an animatronic into the gamemode's database. After successful registration, the animatronic will be available in the Admin Panel.

ParameterTypeDescription
pillstringPill name
namestringTechnical name
fullnamestringFull name
colorcolorAnimatronic's interface color
categorystringAnimatronic category (Used for sorting in the Admin Panel)

Important

This is where the gamemode stores the animatronic's icons (for the Tab menu or animatronic selection), as well as the animatronic's portrait used in the player's interface in the bottom left corner.

lua
-- Code from animatronics/bear5.lua
killers.Register("bear5_main", "bear5", "Bear 5", Color(0,120,255), "Freaks")
killers.Register("bear5_clone", "bearling5", "Bearling 5", Color(0,120,255), "Freaks")
killers.Register("fox4", "fox4", "Fox 4", Color(0,255,20), "Freaks")

killers.SetAbilities(name, abilities) SHARED ​

Sets the animatronic's abilities to be displayed in the player's interface.

Each ability in the table must contain the following data:

ParameterTypeDescription
namestringAbility name
keystringAbility keybind
hiddenboolHide while there is no cooldown?
tokensint (opt.)Number of ability tokens
conditionfunction (opt.)Function must return a color to paint the button.

Important

Vanilla FH does not use the abilities table on the server anywhere, but it is still recommended to set abilities on both sides.

lua
-- Code from animatronics/bear5.lua
killers.SetAbilities("bear5", {
	{ name = 'highlight', key = 'R' },
	{ name = 'death', key = 'RMB' },
})

Animatronic list management ​

killers.getAll() SHARED ​

All registered animatronics.

killers.getAllSolos() SHARED ​

All non-secondary animatronics.

Important

Does not check playability

killers.getAllPreferables(secondaries) SHARED ​

All playable animatronics. If secondaries = true — includes secondary ones as well.

killers.getAllNonPreferables() SHARED ​

All non-playable animatronics.

killers.getAllSecondaries() SHARED ​

All secondary animatronics.

killers.GetName(pill) SHARED ​

Returns the animatronic's name.

lua
print(killers.GetName("pill_wfreddy2")) -- freddy

killers.GetFullName(pill) SHARED ​

Returns the animatronic's full name.

Important

The animatronic's full name often stores a translation key, which can only be converted to a normal string on the client. On the server, it is recommended to get the animatronic's full name from the model entity (pills.getMappedEnt(ply)) via the printName value.

lua
print(killers.GetFullName("pill_sfreddy2")) -- fazhunt.animatronics.sfreddy

pill_makePreferable(anim, bool) SHARED ​

Makes an animatronic playable or removes it from the playable list.

lua
pill_makePreferable("pill_wfreddy2", true)

Important

This function is used directly by the Admin Panel when playability is enabled or disabled.

pill_makeSecondary(anim, bool) SHARED ​

Adds/removes an animatronic from the secondary list. Most often used immediately after registering the animatronic.

lua
pill_makeSecondary("pill_wbonnie2", true)