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.
| Parameter | Type | Description |
|---|---|---|
ply | Player | Who to assign |
killer | string | Name (e.g., "pill_wfreddy2") |
force | bool (opt.) | If true — assigns even if the same one is already present |
giveKiller(ply, "pill_springtrap", true)giveKillerSilent(ply, killer, [force]) SERVER
Same as above, but without a chat notification.
TaseAnimatronic(ply) SERVER
If the player is an animatronic, tases them (like the Taser).
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.
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.
if fh.GetActiveUsedKiller("pill_wbonnie2") then
print("Bonnie is already in the game!")
endNote
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.
| Parameter | Type | Description |
|---|---|---|
ply | Player | The animatronic |
ent | Entity | The animatronic's model (pills.getMappedEnt(ply)) |
target | Player | The victim |
killDelay | float | Kill time |
voiceCharacter | string (opt.) | Technical name of the animatronic (used for playing voicelines) |
jumpscareDistance | float (opt.) | Distance between the animatronic and victim |
wepClass | string (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.
| Parameter | Type | Description |
|---|---|---|
ply | Player | The animatronic |
ent | Entity | The animatronic's model (pills.getMappedEnt(ply)) |
target | Player | The victim |
dist | float (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.
| Parameter | Type | Description |
|---|---|---|
origin | Vector | Search point |
radius | number | Radius |
ignorePlayer | Player | Who to ignore |
fov | number | If 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.
| Parameter | Type | Description |
|---|---|---|
pill | string | Pill name |
name | string | Technical name |
fullname | string | Full name |
color | color | Animatronic's interface color |
category | string | Animatronic 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.
-- 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:
| Parameter | Type | Description |
|---|---|---|
name | string | Ability name |
key | string | Ability keybind |
hidden | bool | Hide while there is no cooldown? |
tokens | int (opt.) | Number of ability tokens |
condition | function (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.
-- 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.
print(killers.GetName("pill_wfreddy2")) -- freddykillers.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.
print(killers.GetFullName("pill_sfreddy2")) -- fazhunt.animatronics.sfreddypill_makePreferable(anim, bool) SHARED
Makes an animatronic playable or removes it from the playable list.
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.
pill_makeSecondary("pill_wbonnie2", true)