Custom and modified event hooks available within the defined realm. A list of default TTT hooks is available here but note that they may have been modified (see below).
NOTE: When using a hook with multiple return values, you must return a non-nil
value for all properties up to the one(s) you are modifying or the hook results will be ignored entirely.
For example, if there is a hook that returns three parameters: first
, second
, and third
and you want to modify the second
parameter you must return the first
parameter as non-nil
as well, like this: return first, newSecond
. Any return parameters after second
can be omitted and the default value will be used.
NOTE: Be careful that you only return from a hook when you absolutely want to change something. Due to the way GMod hooks work, whichever hook instance returns first causes the remaining hook instances to be completely skipped. This is useful for certain hooks when you want to stop a behavior from happening, but it can also accidentally cause functionality to break because its code is completely ignored.
Called when a player loots credits off of a dead player's body.
Realm: Server
Added in: 2.1.3
Parameters:
Called when a player opens the body search dialog. Used to add new buttons to the dialog.
Realm: Client
Added in: 1.8.3
Parameters:
prop_ragdoll
representing a player's body being searchedtrue
if not provided.
Called when a player searches a body, passing the search info and the equipment found on the body.
Changed eq
parameter to be a table of the body's owned equipment IDs instead of a bitmask.
NOTE: If an error happened while calling this hook, we will call it again and pass 0
for the eq
parameter to at least allow the body search dialog to open.
Realm: Client
Added in: 1.0.0
Parameters:
Called when a player is making a footstep. Used to determine if the player's footstep sound should be stopped.
Realm: Client and Server
Added in: 1.2.7
Parameters:
Return: Whether or not the given player's footstep sounds should be stopped (Defaults to false
).
Modified to allow changing the defusal result via the new return value.
Realm: Server
Added in: 1.5.14
Parameters:
Return:
Changed was_traitor
parameter to be true
for any member of the traitor team, rather than just the regular Traitor role.
Realm: Server
Added in: 1.0.5
Parameters:
Return: Whether or not the given player should be able to identify the given corpse. (Defaults to false
)
Called when someone is attempting to use a cure on a player.
Realm: Server
Added in: 2.1.18
Parameters:
Return: Whether to allow using the cure on this player. (Defaults to false
)
Called to determine if a role can spawn that causes a state that can be cured.
Realm: Client and Server
Added in: 2.1.18
Return: true
if a role can spawn that causes a state that can be cured. Otherwise do not return anything.
Called when a player is attempting to use traitor chat, both speaking and listening. Used to change the default behavior.
Realm: Client and Server
Added in: 2.0.7
Parameters:
Return: Whether to allow this player to use traitor voice chat. (Defaults to checking whether the player is on the traitor team)
Called when a player is using chat. Used to override the name shown.
Realm: Client
Added in: 2.1.4
Parameters:
Return: The player name to show, if it should be overridden. Otherwise do not return anything.
Called before a player is killed because their lover (as set by Cupid's arrows) has been killed. Allows developers to prevent the player from being killed.
Realm: Server
Added in: 1.8.2
Parameters:
Return: If ply
should not be killed, return true
. Otherwise do not return anything.
Called when someone uses a cure on a player.
Realm: Server
Added in: 2.1.18
Parameters:
Called before the name and role of a player's killer is shown to the victim. Used to change the death message reason, killer name, and/or killer role.
Realm: Server
Added in: 1.5.14
Parameters:
water
, suicide
, prop
, burned
, fell
, or ply
)reason
is ply
)reason
is ply
)Return:
ROLE_NONE
to hide the attacker's role from the victim
Called when a detective-like (deputy, impersonator, etc.) player is promoted.
Realm: Server
Added in: 2.0.1
Parameters:
Called when an entity is attacked by a player, before hitmarkers are drawn.
Realm: Server
Added in: 2.1.4
Parameters:
Return:
Called before the event text for the "round finished" event is rendered in the end-of-round summary's Events tab.
Realm: Client
Added in: 1.2.7
Parameters:
id
- The event identifier (always EVENT_FINISH
)t
- The time when this event occurredwin
- The win condition identifierReturn: Text to show in events list at the end of the round
Called before the event icon for the "round finished" event is rendered in the end-of-round summary's Events tab. Used to change the mouseover text for the icon.
Realm: Client
Added in: 1.2.7
Parameters:
id
- The event identifier (always EVENT_FINISH
)t
- The time when this event occurredwin
- The win condition identifierrole
placeholder in the translation stringReturn:
Allows creation of new tabs for the equipment (shop) menu.
Realm: Client
Added in: 1.0.0
Parameters:
Return: If true
, the equipment window will show even if the player doesn't have any of the default tabs. (Added in 1.7.3)
Called when someone uses a fake cure on a player.
Realm: Server
Added in: 2.1.18
Parameters:
Called after player information such as role, health, and ammo and equipment information such as radar cooldown and disguiser activation are drawn on the screen. Used to write additional persistent text on the screen for player reference.
Realm: Client
Added in: 1.3.1
Parameters:
labelY = labelY + (20 * #activeLabels)
. Be sure to insert an entry when you add your own label so other addons can space appropriately. (Added in 1.6.11)
Called when an Informant has scanned additional information from a target player.
Realm: Server
Added in: 1.9.6
Parameters:
Return: The default scan stage to use for this player. If you have no opinion (e.g. let other logic determine this) then don't return anything at all.
Called when an Informant has scanned additional information from a target player.
Realm: Server
Added in: 1.6.16
Parameters:
Called to check whether a player is currently respawning.
Realm: Client and Server
Added in: 2.1.12
Parameters:
Return: true
if the player is currently respawning, false
if they are not. If you have no opinion (e.g. let other logic determine this) then don't return anything at all.
Called before a player is rewarded with karma. Used to block a player's karma reward.
Realm: Server
Added in: 1.2.7
Parameters:
Return: Whether or not the given player should be prevented from being rewarded with karma (Defaults to false
).
Called before a player's karma effect is decided. Used to determine if a player should be penalized or rewarded.
Realm: Server
Added in: 1.2.7
Parameters:
Return: true
if the attacker should be penalized or false
if they should not. If you have no opinion (e.g. let other logic determine this) then don't return anything at all.
Called when a Mad Scientist begins zombifying a target.
Realm: Server
Added in: 1.6.16
Parameters:
Called when a Paladin heals a target.
Realm: Server
Added in: 1.6.16
Parameters:
Called when a Parasite respawns.
Realm: Server
Added in: 1.8.2
Parameters:
Called for each player who is alive during the Think
hook.
Realm: Client
Added in: 1.3.1
Parameters:
Called for each player who is alive during the Tick
hook.
Realm: Server
Added in: 1.2.7
Parameters:
Called when a player opens the equipment window to determine whether the credits transfer tab should show.
Realm: Client
Added in: 2.1.14
Parameters:
Return: true
if the player should be able to send credits. Don't return anything otherwise.
Called on the client when a player opens the equipment window to determine which other players are valid transfer targets.
Called on the server when a player attempts to transfer credits to another player to determine whether the target is valid.
Realm: Client and Server
Added in: 2.1.14
Parameters:
Return: true
if the player should be able to send credits to the target. Don't return anything otherwise.
Called whenever a player's credits are added to or subtracted from.
Realm: Server
Added in: 1.9.7
Parameters:
Called when a player's health changes.
Realm: Client and Server
Added in: 1.9.5
Parameters:
Called after a player's role has changed.
Realm: Client and Server
Added in: 1.2.7
Parameters:
Called after a player's role has been changed by a weapon or item.
Realm: Server
Added in: 1.6.16
Parameters:
Called before a player is spawned for a round. Also used when reviving a player (via a defib, Zombie conversion, etc.).
Realm: Server
Added in: 1.2.7
Parameters:
Called after a player uses a health station. Added should_reduce
parameter which is not present in vanilla TTT.
Realm: Server
Added in: 1.0.0
Parameters:
Called before the round win results message is printed to the top-right corner of the screen. Can be used to print a replacement message for custom win types that this would not normally handle.
Realm: Server
Added in: 1.0.14
Parameters:
Return: true
if the default print messages should be skipped (Defaults to false
).
Called when a player opens a crate from a Quartermaster.
Realm: Server
Added in: 1.9.6
Parameters:
Called before a target's radar ping is rendered, allowing the color and whether the ping should be shown to be changed.
Realm: Client
Added in: 1.2.3
Parameters:
pos
- The target's positionrole
- The target's role, if anywas_beggar
- If the target was a Beggar but was converted to another rolewas_bodysnatcher
- If the target was a Bodysnatcher but was converted to another rolekiller_clown_active
- whether the target is a Clown that has been activatedsid64
- The SteamID64 value of the targettgt
to change what is displayed with the radar ping
nick
- A string value that will be shown under the radar ping circlet
- A time number value that will be calculated as the difference from "now" and shown in the "##:##" formatReturn:
Called after non-player radar points are rendered and before players are rendered. Used for rendering custom non-player radar points.
Realm: Client
Added in: 1.3.1
Parameters:
Called when a player is using the in-game quickchat radio. Used to override the name shown.
Realm: Client and Server
Added in: 2.1.9
Parameters:
Return: The player name to show, if it should be overridden. Otherwise do not return anything.
Called before all detectives are awarded credits for a traitor being killed.
Realm: Server
Added in: 1.4.8
Parameters:
Return:
Called before a player awarded credits for a traitor being killed.
Realm: Server
Added in: 1.4.8
Parameters:
Return: true
to prevent the given player from being awarded credits
Called before a player is awarded credits for killing an opponent.
Realm: Server
Added in: 1.4.8
Parameters:
Return:
Called before all traitors are awarded credits for a non-traitor being killed.
Realm: Server
Added in: 1.4.8
Parameters:
Return:
Called before a player awarded credits for a non-traitor being killed.
Realm: Server
Added in: 1.4.8
Parameters:
Return: true
to prevent the given player from being awarded credits
Called before a player's role start-of-round popup message is displayed, allowing the parameters to be added to.
Realm: Client
Added in: 1.2.7
Parameters:
Return:
Called before a player's role start-of-round popup message is displayed, allowing the target translation string to be changed.
Realm: Client
Added in: 1.5.11
Parameters:
Return:
Called after all roles and role modifications have been loaded.
Realm: Client
Added in: 1.5.3
Called when checking if a role can be spawned artificially. (i.e. Spawned in a way other than naturally spawning when the role is enabled.)
Realm: Client and Server
Added in: 1.9.5
Parameters:
Return: true
when the role could be spawned artificially. Don't return anything otherwise
Called after an external role has been registered.
Realm: Client
Added in: 1.5.3
Parameters:
Called after the role weapons configuration is loaded.
Realm: Client and Server
Added in: 1.6.17
Called after a role weapon configuration is changed for a specific role and weapon.
Realm: Client and Server
Added in: 1.6.17
Parameters:
WEPS.BuyableWeapons
WEPS.ExcludeWeapons
WEPS.BypassRandomWeapons
WEPS.LoadoutWeapons
(Added in 2.1.11)
Called before a player's row in the scoreboard (tab menu) is shown, allowing the name to be changed.
Realm: Client
Added in: 1.1.9
Parameters:
Return:
Called before a player's row in the scoreboard (tab menu) is shown, allowing the colors and icon to be changed.
Realm: Client
Added in: 1.1.9
Parameters:
Return:
false
to not show color at allfalse
to not show an icon at all
Called before each round summary screen is shown with the winning team. Used to add roles to the secondary win display (e.g. AND THE OLD MAN WINS).
Realm: Client
Added in: 1.4.1
Parameters:
Called before the round summary screen is shown. Used to modify the color, position, and icon for a player.
Realm: Client
Added in: 1.1.5
Parameters:
Return:
Called multiple times before the round end screen is shown with the winning team. For each tab of the round end screen that shows the winning team, this hook is first called with WIN_INNOCENT
to get the default value and then called with the actual winning team. Return a new win title object to override what would normally be shown on the round end screen. This should be used by roles to customize what is shown on the round summary screen.
Realm: Client
Added in: 1.0.14
Parameters:
Return:
txt
Called multiple times before the round end screen is shown with the winning team. For each tab of the round end screen that shows the winning team this is called with the winning team. Return a new win title object to override what would normally be shown on the round end screen. This should be used by external addons to change the look of the round summary screen, not by roles to set their custom win titles. For a role's custom win title, use TTTScoringWinTitle
instead.
Realm: Client
Added in: 1.7.3
Parameters:
Return:
txt
Called before players are randomly assigned roles. If a player is assigned a role during this hook, they will not be randomly assigned one later.
Realm: Server
Added in: 1.0.0
Parameters:
Called before players are assigned a detective role, allowing the available roles and their weights (how many times they appear in the table) to be manipulated.
Realm: Server
Added in: 1.2.3
Parameters:
Called before players are assigned a independent role, allowing the available roles and their weights (how many times they appear in the table) to be manipulated.
Realm: Server
Added in: 1.2.3
Parameters:
Called before players are assigned an innocent role, allowing the available roles and their weights (how many times they appear in the table) to be manipulated.
Realm: Server
Added in: 1.2.3
Parameters:
Called before players are assigned a jester role, allowing the available roles and their weights (how many times they appear in the table) to be manipulated.
Realm: Server
Added in: 1.2.3
Parameters:
Called before players are assigned a monster role, allowing the available roles and their weights (how many times they appear in the table) to be manipulated.
Realm: Server
Added in: 1.2.3
Parameters:
Called before players are assigned a traitor role, allowing the available roles and their weights (how many times they appear in the table) to be manipulated.
Realm: Server
Added in: 1.2.3
Parameters:
Called after each section of the help menu's Config tab has been created, allowing developers to add controls to that section.
Realm: Client
Added in: 1.7.3
Parameters:
Called after the Config tab of the help menu has been created, allowing developers to add sections to it.
Realm: Client
Added in: 1.7.3
Parameters:
Called for each role, allowing developers to add a configuration section for it.
Realm: Client
Added in: 1.7.3
Parameters:
Return:
true
to add this role config section to the dialog. If you have no opinion (e.g. let other logic determine this) then don't return anything at all.
Called when a player buys a random item from the shop.
Realm: Client
Added in: 1.6.16
Parameters:
Called when during a player's `Think`, allowing a player to emit smoke with different visual effects.
Realm: Client
Added in: 1.2.7
Parameters:
COLOR_BLACK
).vmt
file for the particle. (Defaults to "particle/snow.vmt"
)Vector(0, 0, 30)
)Return:
Called when a body search screen would be shown.
Realm: Client
Added in: 2.1.10
Parameters:
Called when a smoke grenade extinguishes a fire entity.
Realm: Server
Added in: 1.6.16
Parameters:
Called when a player who is being shown a role-specific spectator HUD presses a button, allowing the hook to intercept that button press and perform specific logic if necessary.
Realm: Server
Added in: 1.3.1
Parameters:
Return:
Called when a player should be shown a role-specific spectator HUD, allowing that role's logic to render the HUD as needed.
Realm: Client
Added in: 1.3.1
Parameters:
Called when determining what speed the player should be moving at.
NOTE: This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.
Realm: Client and Server
Added in: 1.0.0
Parameters:
Called when determining if a player is sprinting. Allows overriding of which directional key needs to be pressed for sprinting to start.
NOTE: This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.
Realm: Client and Server
Added in: 1.0.0 on Client and 1.8.8 on Server
Parameters:
Return: The IN_* enum value representing the key that must be pressed in addition to IN_SPEED
to start sprinting. If none provided, default of IN_FORWARD
will be used.
Called after a player's sprint stamina is reduced. Used to adjust the player's new stamina amount.
NOTE: This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.
Realm: Client and Server
Added in: 1.0.2 on Client and 1.8.8 on Server
Parameters:
Return: The stamina value to assign to the player. If none is provided, the player's stamina will not be changed.
Called before a player's sprint stamina is recovered. Used to adjust how fast the player's stamina will recover.
NOTE: This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.
Realm: Client and Server
Added in: 1.3.6 on Client and 1.8.8 on Server
Parameters:
Return: The stamina recovery rate to assign to the player. If none is provided, the player's default stamina recovery rate will be used.
Called when a player starts or stops sprinting.
NOTE: This represents the change in player speed, not the change in the Sprinting
player variable.
NOTE: This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.
Realm: Client and Server
Added in: 1.8.8
Parameters:
Called when something has requested that a player stop respawning due to a role feature.
Realm: Server
Added in: 2.1.12
Called when the server is syncing generated event IDs to the client.
Realm: Client
Added in: 1.4.6
Called when the server is syncing convars to global variables for client access.
Realm: Server
Added in: 1.2.7
Called when the server is syncing generated win IDs to the client.
Realm: Client
Added in: 1.4.6
Called before a player's overhead icon is shown, allowing you to block it.
Realm: Client
Added in: 1.3.5
Parameters:
Return: true
to stop this information from being rendered
Called before a player's target information (name, health, hint text, karma, and ring) are shown, allowing you to block it.
Realm: Client
Added in: 1.3.5
Parameters:
Return: true
to stop this information from being rendered
Called before a player's heath status (shown when you look at a player) is rendered.
Realm: Client
Added in: 1.2.5
Parameters:
Return:
false
to not show text at all
Called before an entity's hint label (shown when you look at an entity) is rendered.
Realm: Client
Added in: 1.2.5
Parameters:
Return:
false
to not show text at all
Called before an entity's hint text (shown when you look at an entity) is rendered.
Realm: Client
Added in: 1.2.5
Parameters:
ent:IsPlayer()
if neededReturn:
false
to not show text at alltext
. Return false
or nothing to not show secondary text at allsecondary_text
. If not provided, clr
value will be used instead (Added in 1.6.17)
Called before a player's karma status text (shown when you look at a player) is rendered.
Realm: Client
Added in: 1.2.5
Parameters:
Return:
false
to not show text at all
Called before a player's name (shown when you look at a player) is rendered.
Realm: Client
Added in: 1.2.5
Parameters:
Return:
false
to not show text at all
Called before an entity's Target ID ring (shown when you look at an entity) is rendered.
Realm: Client
Added in: 1.2.3
Parameters:
ent:IsPlayer()
if neededReturn:
false
if you don't want to override the color. NOTE: For some reason colors that are near-black do not render so try a lighter color if you are having trouble
Called before player Target ID icon (over their head) is rendered allowing changing the icon and color shown.
Realm: Client
Added in: 1.1.9
Parameters:
Return:
false
to stop the icon from being renderedtrue
, a "sprite_{ROLESHORTNAME}_noz.vmt" file must exist and if noZ is false
, a "sprite_{ROLESHORTNAME}.vmt" file must exist
Called before player Target ID icon (over their head) is rendered allowing adding a secondary icon.
Realm: Client
Added in: 1.9.4
Parameters:
Return:
true
, a "sprite_target_{ICONNAME}_noz.vmt" file must exist and if iconNoZ is false
, a "sprite_target_{ICONNAME}.vmt" file must exist"down"
if you want the icon background to be a downwards pointing triangle, or "up"
for an upwards pointing triangle
Called before player Target ID text (shown when you look at a player) is rendered.
Realm: Client
Added in: 1.1.9
Parameters:
ent:IsPlayer()
if neededReturn:
false
to not show text at allfalse
to not show text at all
Called before a ragdoll's name (shown when you look at a ragdoll) is rendered.
Realm: Client
Added in: 1.2.5
Parameters:
Return:
false
to not show text at all
Called before a team chat message is sent. Used to modify the targets of the team message.
Realm: Server
Added in: 2.0.7
Parameters:
Return: Whether or not this team chat message should be sent (Defaults to true
).
Called before a team voice state message is sent. Used to modify the targets of the team voice state message.
Realm: Server
Added in: 2.0.7
Parameters:
Return: Whether or not this team voice state message should be sent (Defaults to true
).
Called when a Turncoat's team is changed
Realm: Server
Added in: 1.6.16
Parameters:
Called before a role's tutorial page is rendered. This can be used to allow a page to be shown when it normally would not be because the role is disabled. Useful for situations like showing the Zombie tutorial page when the Mad Scientist is enabled (because the Mad Scientist creates Zombies).
Realm: Client
Added in: 1.2.7
Parameters:
Return: true
to show this page when it normally would not be
Called before a role's tutorial page is rendered. This can be used to render a completely custom page with information about a role.
Realm: Client
Added in: 1.2.7
Parameters:
Return: true
to tell the tutorial page to use the content set in this hook rather than calling the TTTTutorialRoleText
hook
Called after a role's tutorial page is rendered. This can be used to provide additional data to show for a role.
Realm: Client
Added in: 1.5.3
Parameters:
Called before a role's tutorial page is rendered. This can be used to provide the text to show for a role.
Realm: Client
Added in: 1.2.7
Parameters:
Return: The string value to show on the tutorial page for this role. Can be HTML and will be rendered within a <div>
Called before a role's tutorial page is rendered but after TTTTutorialRoleText
is called. This can be used to provide additional text to show for a role.
Realm: Client
Added in: 1.5.3
Parameters:
</div>
tag, meaning additional HTML can be appended to the end without worrying about proper structure.
Return: The full string value to show on the tutorial page for this role. Should not include the closing </div>
tag as this is appended automatically.
Called after globals are synced but but before role colors and strings are set. Can be used to update role states (team membership) and role weapon (buyable, loadout, etc.) states based on configurations.
Realm: Client and Server
Added in: 1.2.7
Called after a Vampire eats a body.
Realm: Server
Added in: 1.6.16
Parameters:
Called when a Vampire starts or ends their invisibility.
Realm: Server
Added in: 1.6.16
Parameters:
Called after the TTTCheckForWins
has already been called, allowing for an addon to block a win. Used for roles like the Clown and the Drunk to have them activate when the round would normally end the first time.
Realm: Server
Added in: 1.3.1
Parameters:
Called after a win condition has been set and right before the round eds. Used for roles like the Old Man that perform some logic before the end of the round without changing the outcome.
Realm: Server
Added in: 1.3.1
Parameters: