GM gamemode
Gamemode hooks
Summary
Hooks
#Hint_ hint.GM:CalcView; does nothing by default.true to suppress it.GM:Initialize.cw.core:CreateConVar has changed.GM:Initialize.GM:InitPostEntity; does nothing by default.cw.bans:Load.cw.database:Error.Clockwork skin.use_free_aiming it follows where the weapon actually aims.cw.class:GetAppropriateModel for their team.cw.class:GetAppropriateModel for their team.enable_gravgun_punt is set.OnNetworkDataUpdated.OnMenuClosed on each menu panel and closes tooltips and Derma menus.OnMenuOpened on each menu panel that has it.GM:PlayerThink.cw.OneSecondTimer timer.false to stop the default draw.cw_hands, to adjust the delay before the next punch; does nothing by default./OrderShipment, to adjust the ordered item; does nothing by default.Player:Give; return false to block it./SetClass; refuses during the class change cooldown.false delays the shot./CharGetUp; always allows it.player.cwNextOrderTime has not passed.cw_hands hits an entity, to check whether it damages it; never does by default.cw_hands hits a player, to check whether it knocks them out.cwAdminESP ConVar.cwStatus, to get the status line shown for them.cw_hands; always allows it.+zoom; always allows it.cw.storage:SyncCash.true to mute it, Catwork plays its own.cw.player:HasDoorAccess to check whether a player has an access level on a door.cw.player:HasFlags to check whether a player has a flag they do not hold themselves./player/ models) so they sit correctly.true to suppress every footstep.Player:GetHoldingEntity to get the entity a player is holding.false to keep the cash from being given.lenses in their inventory.cw.storage:SyncItem.Player:SetModel, on both realms.Whitelisted exists.Whitelisted table.use or delete; does nothing by default.entRelationship to it.e flag and a living, standing player.r flag, admin rights and a living, standing player.gmod_tool and the spawn menu.GM:PlayerSpawn.CanShowTabMenu allows.PreSaveData, SaveData and PostSaveData.true to hide the default chat box.GM:Tick.Hooks
Implements hook AddEntityOutlines
Called when entity outlines should be added; outlines the entity whose entity menu is open.
Parameters
- outlines Map The
cw.outlinelibrary; calloutlines:Add(entity, color)
Called when GMod shows a hint; shows it as a Catwork top hint once a character is loaded.
Parameters
- name String The hint name, looked up as the
#Hint_<name>phrase - delay Number How long the hint stays
Implements hook AddNotify
Called when GMod shows a notification; passes it to the base gamemode unless it is a #Hint_ hint.
Parameters
- text String The notification text
- class Number The notification type (
NOTIFY_*) - length Number How long it stays
Implements hook AdjustAmmoTypes
Called to add ammo types that are saved with the character; adds the HL2 ammo types.
Parameters
- ammoTable Map Ammo types to check, as
{ [ammoType] = true }, modified in place
Called when a player attempts to pick up an entity with use; always refuses, Catwork handles picking up itself.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean Always
false
Called to pick the main activity and sequence a player should be playing.
Runs the base gamemode's noclip, driving, vaulting, jumping, swimming and ducking handlers,
otherwise chooses idle, walk (above 0.5 units/s) or run (above 150 units/s). A forced
animation set with Player:SetForcedAnimation overrides the result and has its OnAnimate
callback run once.
Parameters
- player Player The player being animated
- velocity Vector The player's current velocity
Returns
- Number The ideal activity (
ACT_*) - Number The sequence override, or -1 for none
Called when the view should be calculated.
While ragdolled the view is from the ragdoll's eyes (or blacked out at full fade), dead players
see nothing, and with enable_headbob the view sways while walking, scaled by
cwHeadbobScale and adjustable through PlayerAdjustHeadbobInfo. The final view table is
passed to CalcViewAdjustTable.
Parameters
- player Player The local player
- origin Vector The view origin
- angles Angle The view angles
- fov Number The field of view
Returns
- Map The view table
Implements hook CalcViewAdjustTable
Called to adjust the final view table from GM:CalcView; does nothing by default.
Parameters
- view Map The view table, with
origin,anglesandfov, modified in place
GM:CalcViewModelView(weapon, viewModel, oldEyePos, oldEyeAngles, eyePos, eyeAngles)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:686Called to position the view model; tilts it into the lowered pose while the weapon is lowered.
The lowered offset comes from the item's loweredAngles/loweredOrigin, then the weapon's
LoweredAngles/LoweredOrigin, and can be changed through GetWeaponLoweredViewInfo.
Parameters
- weapon Weapon The active weapon
- viewModel Entity The view model
- oldEyePos Vector The original eye position
- oldEyeAngles Angle The original eye angles
- eyePos Vector The eye position
- eyeAngles Angle The eye angles
Returns
- Vector The view model position
- Angle The view model angles
Implements hook CanDrawCrosshair
Called to check whether the Catwork crosshair is drawn; never by default.
Parameters
- weapon Weapon The local player's active weapon
Returns
- Boolean Whether the crosshair is drawn
On the server
Called when a player attempts to drive an entity; only living, standing admins can.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean Whether the entity can be driven
On the client
Called to check whether a player can drive an entity; only living, standing admins can.
Parameters
- player Player The player trying to drive
- entity Entity The entity the player is trying to drive
Returns
- Boolean Whether the player can drive the entity
Defined in
Called when a player attempts to exit a vehicle.
Refuses during player.cwNextExitVehicle and while the player looks at an entity they can
use from the vehicle. For chairs without a parent the player exits where they look, if that
is within 192 units; otherwise they cannot get out.
Parameters
- vehicle Vehicle The vehicle
- player Player The player
Returns
- Boolean Whether the player can exit
GM:CanPlayerEnterVehicle(player, vehicle, role)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2560Called when a player attempts to enter a vehicle; always allows it.
Parameters
- player Player The player
- vehicle Vehicle The vehicle
- role Number The seat role
Returns
- Boolean Whether the player can enter
Called when a player attempts to suicide; always refuses.
Parameters
- player Player The player
Returns
- Boolean Always
false
GM:CanPlayerUnfreeze(player, entity, physicsObject)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2748Called when a player attempts to unfreeze an entity.
Non-admins cannot unfreeze another character's props when prop protection is enabled, nor non-interactable entities. Nobody can unfreeze a vehicle with a driver.
Parameters
- player Player The player
- entity Entity The entity
- physicsObject PhysObj The physics object
Returns
- Boolean Whether the entity can be unfrozen
On the server
Called when a player attempts to use the property menu; only living, standing admins can.
Parameters
- player Player The player
- property String The property name
- entity Entity The entity
Returns
- Boolean Whether the property can be used
On the client
Called to check whether a player can use a property on an entity; only living, standing admins can.
Parameters
- player Player The player trying to use the property
- property String The property name
- entity Entity The entity the property is used on
Returns
- Boolean Whether the player can use the property
Defined in
Implements hook CanShowTabMenu
Called before the main menu is opened or closed with the scoreboard key; always allows it.
Returns
- Boolean Whether the menu opens or closes
GM:CanTool(player, trace, tool, toolTable, button)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3339Called when a player attempts to use a tool.
Admins can always use tools. Others cannot target non-interactable entities, player ragdolls
or (under prop protection) other characters' props, cannot nail into such entities, cannot
remove map entities or contraptions containing them, and cannot use dynamite or
duplicator; the base gamemode decides the rest.
Parameters
- player Player The player
- trace Map The tool trace result
- tool String The tool mode
- toolTable Map The tool object
- button Number The mouse button used
Returns
- Boolean Whether the tool can be used
GM:CharacterScreenSortFactionCharacters(faction, a, b)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:819Implements hook CharacterScreenSortFactionCharacters
Called to sort the characters within a faction on the character screen; sorts them by name.
Parameters
- faction String The faction name
- a Map The first character's screen info
- b Map The second character's screen info
Returns
- Boolean Whether
acomes beforeb
On the server
Called when chat box info should be adjusted; logs in-character and LOOC messages.
Parameters
- info Map The message info, with
class,speakerandtext
On the client
Called when chat box info should be adjusted; does nothing by default.
Parameters
- info Map The message info
Defined in
Implements hook ChatBoxClosed
Called when the chat box is closed; does nothing by default.
Parameters
- textTyped String The text left in the chat box
Implements hook ChatBoxKeyCodeTyped
Called when a key is typed in the chat box; up and down cycle through the remembered messages.
Parameters
- code Number The key code (
KEY_*) - text String The current chat box text
Returns
- String Text to replace the chat box contents with, or
nil
Called when the chat box is opened; does nothing by default.
GM:ChatBoxTextChanged(previousText, newText)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2398Implements hook ChatBoxTextChanged
Called when the chat box text has changed; does nothing by default.
Parameters
- previousText String The previous text
- newText String The new text
Implements hook ChatBoxTextTyped
Called when chat box text has been sent; remembers the last 25 messages for the up and down keys.
Parameters
- text String The text sent
Called when engine chat text is received from the server; returns true to suppress it.
Parameters
- index Number The player index
- name String The player name
- text String The text
- class String The message type
Returns
- Boolean Always
true
GM:CheckPassword(steamID64, ipAddress, svPassword, clPassword, name)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1209Called when a player attempts to connect; refuses banned players.
Looks the player up by IP (with and without the port) and Steam ID in cw.bans.stored.
Temporary bans show the banned_message config with !t/!f replaced by the time left,
permanent bans show the reason, and expired bans are removed. Everyone else is checked
against the server password by the base gamemode.
Parameters
- steamID64 String The connecting player's 64-bit Steam ID
- ipAddress String The player's IP address and port
- svPassword String The server password
- clPassword String The password the client sent
- name String The player's Steam name
Returns
- Boolean Whether the player may join
- String The kick message when banned
GM:ClockworkConfigChanged(key, data, previousValue, newValue)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:799Implements hook ClockworkConfigChanged
Called when a config value has changed.
Applies the change to connected players: gives or takes the physgun and toolgun when the
p/t default flags change, shows or hides the group commands for use_own_group_system,
resets OOC cooldowns for ooc_interval and updates movement for crouched_speed,
jump_power, walk_speed and run_speed.
Parameters
- key String The config key
- data Map The config entry
- previousValue Any The previous value
- newValue Any The new value
Implements hook ClockworkConfigInitialized
On the server
Called for each config key once the config has initialized, from GM:Initialize.
Zeroes every item's cost when cash_enabled is off and turns off sv_alltalk when
local_voice is on.
Parameters
- key String The config key
- value Any The config value
On the client
Called for each config key once the config has been received; zeroes every item's cost when cash_enabled is off.
Parameters
- key String The config key
- value Any The config value
Defined in
GM:ClockworkConVarChanged(name, previousValue, newValue)
shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:783Implements hook ClockworkConVarChanged
On the server
Called when a ConVar created with cw.core:CreateConVar has changed.
Sets sv_alltalk to 1 when the changed ConVar is local_voice and the new value is truthy.
Parameters
- name String The ConVar name
- previousValue String The previous value
- newValue String The new value
On the client
Called when one of the client's Catwork ConVars has changed.
The cwTextColor ConVars update the information colour unless the theme is fixed, and
cwActiveTheme switches the theme when modify_themes is enabled.
Parameters
- name String The ConVar name
- previousValue String The previous value
- newValue String The new value
Defined in
Implements hook ClockworkDirectoryRebuilt
Called when the directory is rebuilt; lists help only for the commands the local player has the flags for.
Parameters
- panel Panel The directory panel
Implements hook ClockworkInitialized
On the server
Called when Catwork has initialized, at the end of GM:Initialize.
Hides the cash commands and zeroes prop and door costs when cash is disabled, hides the group
commands when use_own_group_system is set, adds the gradient, schema logo and intro image
materials to the download list, registers Catwork tools with gmod_tool and sets sv_maxrate
to 80000.
On the client
Called when Catwork has initialized on the client.
Loads the shared materials and gradient textures, adds the settings and sets up the directory's categories, icons and tips.
Defined in
Implements hook ClockworkInitPostEntity
Called after Catwork has processed the map entities in GM:InitPostEntity; does nothing by default.
Called when the local player's move data is created; turns mouse movement into ragdoll eye angles while ragdolled.
Sensitivity follows AdjustMouseSensitivity, and the look range is clamped to 48 degrees while
ragdolled and 90 otherwise.
Parameters
- userCmd CUserCmd The user command
Called when the scoreboard should be created; overridden to do nothing, the scoreboard is part of the main menu.
Implements hook DatabaseConnected
Called when the Catwork database has connected; loads the ban list with cw.bans:Load.
Implements hook DatabaseConnectionFailed
Called when the Catwork database connection fails; reports it with cw.database:Error.
Parameters
- errText String The error message from the database module
Implements hook DestroyBars
Called after the HUD bars are collected, so bars can be removed; does nothing by default.
Parameters
- bars Map The
cw.barslibrary
Implements hook DestroyPlayerInfoText
Called after the player info text is collected, so lines can be removed; does nothing by default.
Parameters
- playerInfoText Map
cw.PlayerInfoText
GM:DestroyTargetPlayerText(player, targetPlayerText)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1877Implements hook DestroyTargetPlayerText
Called after the target player text is collected, so lines can be removed; does nothing by default.
Parameters
- player Player The player looked at
- targetPlayerText Map
cw.TargetPlayerText
Called when an animation event such as an attack, reload or jump should be played.
Models under /player/ use the base gamemode. Other models play the attack or reload
gesture that cw.animation:GetForModel gives for the weapon's hold type, falling back to the
SMG1 gestures. Jumps set the standard GMod jump variables. Nothing happens without a valid
active weapon. The approach is a hybrid of NutScript's and Clockwork's.
Parameters
- player Player The player the event is for
- event Number The event (
PLAYERANIMEVENT_*) - data Number Extra event data
Returns
- Number The activity to play, or
nil
GM:DoPlayerDeath(player, attacker, damageInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3859Implements hook DoPlayerDeath
Called just before a player dies.
Drops the player's weapons, clears action and drunkenness, turns the body into a knocked out
ragdoll that decays after body_decay_time (600 seconds when that is 0), clears recognised
names and the name when the death hooks allow, plays the death sound, strips weapons and ammo,
adds a death and gives the killer a frag when PlayerCanGainFrag allows.
Parameters
- player Player The player
- attacker Entity The killer
- damageInfo CTakeDamageInfo The fatal damage
Implements hook DrawPlayerCrosshair
Called when the local player's crosshair should be drawn; draws five small dots.
Parameters
- x Number The crosshair x position
- y Number The crosshair y position
- color Color The crosshair colour
Returns
- Boolean Stored in
cw.CustomCrosshair;truewhen a custom crosshair was drawn
Called when the local player's screen damage should be drawn; draws the damage overlay.
Parameters
- damageFraction Number How damaged the player is, from 0 to 1
Implements hook DrawPlayerVignette
Called when the local player's vignette should be drawn.
The vignette darkens when something is above the player, checked once a second.
GM:DrawTargetPlayerStatus(target, alpha, x, y)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1644Implements hook DrawTargetPlayerStatus
Called to draw a looked at player's status below their target ID; shows that they are deceased.
Parameters
- target Player The player looked at
- alpha Number The text alpha
- x Number The text x position
- y Number The text y position
Returns
- Number The y position below what was drawn
Implements hook EntityFireBullets
Called when an entity fires bullets; overridden to do nothing.
Parameters
- entity Entity The entity firing
- bulletInfo Map The
Bulletstructure
GM:EntityHandleMenuOption(player, entity, option, arguments)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3020Implements hook EntityHandleMenuOption
Called when a player picks an option from an entity's menu.
Handles taking, using, examining and unloading ammo from cw_item entities (refusing to
take, use or unload items dropped by another character, and running PlayerPickupItem),
forwards other item options to the item's EntityHandleMenuOption, opens cw_belongings and
cw_shipment storage, and takes cw_cash.
Parameters
- player Player The player
- entity Entity The entity
- option String The option's display name
- arguments String The option's argument, such as
cw.itemTake
Called when an entity is removed, except while the server shuts down.
A belongings ragdoll with items or cash spawns a cw_belongings entity with them. Props
removed within their refund window refund their cost to the character that spawned them, and
the entity is removed from the property lists.
Parameters
- entity Entity The entity
Implements hook EntityTakeDamage
Called when an entity takes damage; Catwork's central damage handler.
Lets cw.core:DoEntityTakeDamageHook handle it first. With prop_kill_protection, damage from
immune or held props is cancelled. Damage to players and player ragdolls is scaled by
GM:ScaleDamageByHitGroup and applied through cw.core:CalculatePlayerDamage; fatal damage
runs DoPlayerDeath and PlayerDeath, other damage runs PlayerTakeDamage, plays
PlayerPlayPainSound and is logged. Ragdoll damage is filtered by
PlayerRagdollCanTakeDamage. Plain ragdolls bleed and are disintegrated by combine balls, and
crowbar damage to NPCs is quartered.
Parameters
- entity Entity The damaged entity
- damageInfo CTakeDamageInfo The damage
Called when the Derma skin's name is needed; forces the Clockwork skin.
Returns
- String The skin name
Implements hook GetBars
Called each tick when the HUD bars are collected; does nothing by default.
Parameters
- bars Map The
cw.barslibrary; add bars with its functions
Implements hook GetCharacterLoadingTime
Called to get how long the character loading screen lasts; 8 seconds.
Returns
- Number The loading time in seconds
GM:GetCharacterPanelToolTip(panel, character)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1666Implements hook GetCharacterPanelToolTip
Called to get the tooltip of a character in the character menu.
When there is more than one faction it shows how many players are in the character's faction and the faction's limit.
Parameters
- panel Panel The character panel
- character Map The character's screen info
Returns
- String The tooltip, or
nilfor none
Implements hook GetCinematicIntroInfo
Called when the cinematic intro info is needed; uses the schema's author, name and description.
Returns
- Map
credits,titleandtextof the intro
Implements hook GetDoorInfo
Called when a piece of information about a door is needed for its 3D2D text.
For DOOR_INFO_NAME it returns the door's name or a default; for DOOR_INFO_TEXT its text,
or whether it is unownable, can be bought or owned, or has been bought or owned (depending on
door_cost). Hidden and false doors show nothing.
Parameters
- door Entity The door
- information Number What is needed,
DOOR_INFO_NAMEorDOOR_INFO_TEXT
Returns
- String The text, or
falseto show nothing
Implements hook GetEntityBeingHeld
Called to get who is holding an entity.
Parameters
- entity Entity The entity
Returns
- Any The player holding it with a gravity or physics gun, or whether a player holds it with use
Implements hook GetEntityMenuOptions
Called when an entity's menu options are needed.
Adds use (when the item has OnUse), take and examine options for cw_item entities plus the
item's own GetEntityMenuOptions, open for cw_belongings and cw_shipment, and take for
cw_cash. The values are sent to the server's GM:EntityHandleMenuOption.
Parameters
- entity Entity The entity
- options Map Option names mapped to their argument strings, modified in place
Implements hook GetFallDamage
Called to get the fall damage a player takes.
Damage grows above 464 units/s and is scaled by scale_fall_damage. With wood_breaks_fall,
landing on a wooden physics prop breaks it and cuts the damage to a quarter. Falls dealing more
than 30 damage make the player fall over.
Parameters
- player Player The falling player
- velocity Number The fall speed
Returns
- Number The damage to deal
Called by the engine to get the gamemode name shown in the server browser.
Catwork returns NS - followed by the schema's gamemode name from cw.core:GetSchemaGamemodeName.
Returns
- String The game description
GM:GetPlayerCharacterScreenFaction(character)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1917Implements hook GetPlayerCharacterScreenFaction
Called to get which faction group a character is shown under on the character screen; uses its faction.
Parameters
- character Map The character's screen info
Returns
- String The faction name
Implements hook GetPlayerCharacterScreenVisible
Called each frame to check whether the character screen is visible.
When the quiz is enabled, it stays hidden until the quiz is completed.
Parameters
- panel Panel The character menu
Returns
- Boolean Whether the character screen is visible
Implements hook GetPlayerCrosshairInfo
Called to position the local player's crosshair; with use_free_aiming it follows where the weapon actually aims.
Parameters
- info Map
color,xandyof the crosshair, modified in place
GM:GetPlayerDefaultInventory(player, character, inventory)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:585Implements hook GetPlayerDefaultInventory
Called to fill a new character's starting inventory.
Adds the items in the character's faction startingInv table ({ [uniqueID] = amount }).
Parameters
- player Player The player creating the character
- character Character The character being created
- inventory Inventory The inventory to add items to
Implements hook GetPlayerDefaultModel
Called to get a player's default model, from cw.class:GetAppropriateModel for their team.
Parameters
- player Player The player to get the model for
Returns
- String The default model path
Implements hook GetPlayerDefaultSkin
Called to get a player's default skin, from cw.class:GetAppropriateModel for their team.
Parameters
- player Player The player to get the skin for
Returns
- Number The default skin
GM:GetPlayerDoorAccessName(player, door, owner)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:417Implements hook GetPlayerDoorAccessName
Called to get the name a player is listed under in the door access menu; uses their name.
Parameters
- player Player The player listed
- door Entity The door
- owner Player The door's owner
Returns
- String The name shown
Implements hook GetPlayerInfoText
Called when the local player's info text (shown in the F1 menu) is needed.
Adds cash and wages when cash is enabled, and the player's name and class as sub text.
Parameters
- playerInfoText Map
cw.PlayerInfoText; call itsAdd(id, text)andAddSub(id, text, priority)
Implements hook GetPlayerScoreboardClass
Called to get the scoreboard group a player is listed under; uses their team name.
Parameters
- player Player The player
Returns
- String The group name
GM:GetPlayerScoreboardOptions(player, options, menu)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1969Implements hook GetPlayerScoreboardOptions
Called when the admin options for a player on the scoreboard are needed.
Adds ban, kick, flag, name, item, user group, demote and whitelist options for the commands the local player has access to. Each option runs the matching command, asking for text first where the command needs it.
Parameters
- player Player The player the options act on
- options Map Option names mapped to callbacks, or to nested option maps for submenus
- menu Panel Unused; the callers do not pass it
Implements hook GetPlayerScoreboardText
Called to get the text under a player's name on the scoreboard.
Shows the physical description (cut to 64 characters) of recognised players and a generic line for others.
Parameters
- player Player The player
Returns
- String The text
GM:GetPlayerWeaponRaised(player, class, weapon)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:608Called to get whether a player's weapon is raised.
Default weapons and zoomed or scoped weapons are always raised and sprinting lowers weapons
when sprint_lowers_weapon is set. With raised_weapon_system enabled, a weapon is only
raised if the player raised it (player.cwWeaponRaiseClass) or it was raised automatically
(player.cwAutoWepRaised); otherwise every weapon is raised.
Parameters
- player Player The player holding the weapon
- class String The weapon's class
- weapon Weapon The weapon
Returns
- Boolean Whether the weapon is raised
Implements hook GetProgressBarInfo
Called to get the progress bar shown in the middle of the screen.
Shows locking and unlocking progress, getting up progress while ragdolled, and the get up
prompt while fallen over when PlayerCanGetUp allows. Nothing is shown while waiting to
respawn.
Returns
- Map
text,percentage,flash,isBlockyandblocksAmtof the bar, ornilfor no bar
Implements hook GetScreenTextInfo
Called to get the text shown in the middle of the screen; shows a notice while the character is banned.
Returns
- Map
title,textandalphaof the text, ornilto show nothing
Implements hook GetStatusInfo
Called to get a player's status lines for the admin ESP.
Adds the player's current action (locking, unlocking, getting up, dead or another action) and whether they have fallen over.
Parameters
- player Player The player
- text List<String> The status lines, added to in place
Implements hook GetTargetPlayerFadeDistance
Called to get how far away a player's target ID text stays visible; 4096 units by default.
Parameters
- player Player The player looked at
Returns
- Number The fade distance
Implements hook GetTargetPlayerName
Called to get the name drawn on a recognised player's target ID; uses their name.
Parameters
- player Player The player looked at
Returns
- String The name, which may contain newlines
GM:GetTargetPlayerText(player, targetPlayerText)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1854Implements hook GetTargetPlayerText
Called when the text below a looked at player's name is needed.
Adds the wrapped physical description of recognised players, or a prompt to look at them for unrecognised living players.
Parameters
- player Player The player looked at
- targetPlayerText Map
cw.TargetPlayerText; call itsAdd(id, text)
GM:GetWeaponLoweredViewInfo(itemTable, weapon, viewInfo)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:762Implements hook GetWeaponLoweredViewInfo
Called to adjust a weapon's lowered view model pose; does nothing by default.
Parameters
- itemTable Item The weapon's item, or
nil - weapon Weapon The weapon
- viewInfo Map
origin(Vector) andangles(Angle) of the lowered pose, which can be changed
Called to play GMod's "grab ear" animation while typing; overridden to do nothing.
Parameters
- player Player The player
Called when a player drops an entity with the gravity gun; clears who holds what.
Parameters
- player Player The player
- entity Entity The entity
Called when a player picks up an entity with the gravity gun; records who holds what.
Parameters
- player Player The player
- entity Entity The entity
Called when a player attempts to pick up an entity with the gravity gun.
Non-admins can only pick up interactable entities (see cw.entity:IsInteractable); the base
gamemode decides the rest.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean Whether the pickup is allowed
Called when a player attempts to punt an entity with the gravity gun; allowed when enable_gravgun_punt is set.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean Whether the punt is allowed
Called when the GUI mouse has been released.
Unless use_opens_entity_menus is set, clicking an entity within 80 units while the cursor is
visible opens its entity menu at the cursor.
Parameters
- code Number The mouse button (
MOUSE_*)
Implements hook HalfSecond
Called every half second; every 3 seconds it fades timed attribute boosts and removes expired ones.
Called to display a HUD notification when ammo has been picked up; overridden to show nothing.
Parameters
- ... Any The engine's arguments, ignored
Called every frame to draw the full screen layers above the HUD.
Draws the character selection background and HUDPaintCharacterSelection, then for a loaded
character runs HUDPaintForeground and HUDPaintImportant, the cinematic intro, background
blurs (when ShouldDrawBackgroundBlurs allows), the Catwork intro splash, the loading and
no-database screens and HUDPaintCharacterLoading, then PostDrawBackgroundBlurs.
Called when the target ID HUD should be drawn.
For a player within GetTargetPlayerFadeDistance (and allowed by ShouldDrawPlayerTargetID)
it draws their name from GetTargetPlayerName if recognised, or their unrecognised name and
PlayerCanShowUnrecognised otherwise, then GetTargetPlayerText, DrawPlayerStatusExtra and
DrawTargetPlayerStatus, and asks the server whether the target recognises the local player.
Dropped weapons get a pickup hint, entities with HUDPaintTargetID draw themselves and other
entities go through HUDPaintEntityTargetID. The text fades in after target_id_delay.
Called to display a HUD notification when an item has been picked up; overridden to show nothing.
Parameters
- ... Any The engine's arguments, ignored
Called when the HUD should be painted.
Outside character selection and cameras it draws the vignette (when enabled by the event,
enable_vignette and cwShowVignette), the base HUD and the hints, and a crosshair when
CanDrawCrosshair allows, positioned by GetPlayerCrosshairInfo and drawn by
DrawPlayerCrosshair.
Implements hook HUDPaintForeground
Called when the foreground HUD should be painted.
Draws the hook error notice, the fallen over and underwater blur, the progress bar from
GetProgressBarInfo (or GetPostProgressBarInfo), the admin ESP when PlayerCanSeeAdminESP
allows, the GetScreenTextInfo text, the top bars and the death screen with the respawn
countdown, then runs HUDPaintTopScreen.
Called when a player's HUD should be painted; does nothing by default.
Parameters
- player Player The player
Called to check whether a HUD element should be drawn.
Only CHudGMod is drawn before a character is loaded or while choosing one, and the default
health, armor, ammo, crosshair, chat and voice elements are always hidden.
Parameters
- name String The HUD element name
Returns
- Boolean Whether the element is drawn
Called to display a HUD notification when a weapon has been picked up; overridden to show nothing.
Parameters
- ... Any The engine's arguments, ignored
On the server
Called when the server has initialized.
Initializes the item system, imports gamemodes/catwork/clockwork.cfg, connects to the
database (SQLite when mysql_host is empty, sqlite or a placeholder, MySQLOO otherwise),
restores or derives the in-game date and time (from the machine clock when
use_local_machine_date/use_local_machine_time are set) and creates the cwLog ConVar.
Finally runs ClockworkConfigInitialized for every config key and then ClockworkInitialized.
On the client
Called when the client initializes.
Creates the client ConVars (clock, headbob, HUD, ESP and theme options), creates the chatbox,
initializes items, runs ClockworkInitialized, then initializes the theme, settings and limb
textures.
Defined in
On the server
Called when the map entities are initialized.
Marks every map entity with a model as a map entity and records its start position and
angles, makes chairs non-colliding and frozen, collects doors into cw.entity.DoorEntities,
networks NoMySQL and runs ClockworkInitPostEntity. Finally sets the negated key value
on wooden and furniture-like props.
On the client
Called when the map entities are initialized on the client.
Sets cw.client, runs LocalPlayerCreated, runs PlayerModelChanged for every player and
then ClockworkInitPostEntity.
Defined in
GM:ItemEntityDestroyed(itemEntity, itemTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3990Implements hook ItemEntityDestroyed
Called when an item entity has been destroyed by damage, before it explodes; does nothing by default.
Parameters
- itemEntity Entity The
cw_itementity - itemTable Item The item
GM:ItemEntityTakeDamage(itemEntity, itemTable, damageInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3983Implements hook ItemEntityTakeDamage
Called when an item entity has taken damage, before its health drops; does nothing by default.
Parameters
- itemEntity Entity The
cw_itementity - itemTable Item The item
- damageInfo CTakeDamageInfo The damage, which can be changed
Returns
- Boolean The return value is ignored
GM:ItemGetNetworkObservers(itemTable, info)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3999Implements hook ItemGetNetworkObservers
Called when an item's data changes, to pick who receives the update.
Items with a world entity are sent to everyone; otherwise the players who carry the item, hold it as a weapon or have it in their open storage are added as observers.
Parameters
- itemTable Item The item
- info Map
observers(aMapof player to player) andsendToAll, which can be changed
Returns
- Boolean
trueto send the update to everyone
GM:ItemNetworkDataUpdated(itemTable, newData)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1302Implements hook ItemNetworkDataUpdated
Called when an item's network data has been updated; runs the item's OnNetworkDataUpdated.
Parameters
- itemTable Item The item
- newData Map The updated data fields
Called when a player presses a key.
Use within 192 units opens doors (running PlayerCanUseDoor and PlayerUseDoor) and uses
UsableInVehicle entities from vehicles. Pressing walk while standing still and holding
sprint toggles crouching.
Parameters
- player Player The player
- key Number The key (
IN_*)
On the server
Called when a player releases a key; overridden to do nothing.
Parameters
- player Player The player
- key Number The key (
IN_*)
On the client
Called when a key has been released.
With use_opens_entity_menus set, releasing use on an entity within 80 units opens its entity
menu, unless the player is holding an object with the physics gun.
Parameters
- player Player The player releasing the key
- key Number The key released (
IN_*)
Defined in
Implements hook LocalPlayerCreated
Called when the local player entity has been created.
Watches the Clothes network variable to keep cw.ClothesData and the inventory up to date,
and tells the server a second later with the LocalPlayerCreated message.
Implements hook MenuClosed
Called when the main menu is closed; runs OnMenuClosed on each menu panel and closes tooltips and Derma menus.
Implements hook MenuItemsAdd
Called when the main menu's items should be added.
Adds the settings, system, scoreboard, inventory, directory and attributes tabs, named by the
schema's name_* options.
Parameters
- menuItems Map The
cw.menuitemslibrary; call itsAdd(name, panel, tip, icon)
Implements hook MenuItemsDestroy
Called after the main menu's items are added, so they can be removed; does nothing by default.
Parameters
- menuItems Map The
cw.menuitemslibrary
Implements hook MenuOpened
Called when the main menu is opened; runs OnMenuOpened on each menu panel that has it.
Implements hook ModifyWagesInterval
Called when the next wages payout is scheduled, to change the interval; does nothing by default.
Parameters
- info Map Has
interval, the seconds until the next payout, which can be changed
Called to move a player's mouth while they speak.
Only uses the base gamemode's mouth movement when the enable_mouth_move config is enabled.
Parameters
- player Player The player speaking
Implements hook NotificationAdjustInfo
Called before a notification from the server is shown, to adjust it; shows every notification.
Parameters
- info Map
text,classandsoundof the notification, which can be changed
Returns
- Boolean Whether the notification is shown
GM:OnAttributeProgress(player, attribute, amount)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4571Implements hook OnAttributeProgress
Called when an attribute is progressed, before the amount is applied.
Catwork multiplies amount by the scale_attribute_progress config.
Parameters
- player Player The player who progressed the attribute
- attribute String The attribute's unique ID
- amount Number The amount it is progressed by
Returns
- Number The amount to progress the attribute by instead
Called when the context menu is closed.
Closes the normal context menu while a tool is in use, otherwise only hides the cursor.
Called when the context menu is opened.
Opens the normal context menu while a tool is in use, otherwise only shows the cursor.
GM:OnePlayerSecond(player, curTime, infoTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:135Implements hook OnePlayerSecond
Called about once a second for every initialized player, after GM:PlayerThink.
Handles attribute progress and boosts, networks the player's flags, model, name, cash and
drunk level, networks or removes clothes, runs PlayerHealthRegenerate when health
regeneration is enabled and PlayerShouldHealthRegenerate allows it and expires drunk
entries. When cash is disabled it zeroes the character's cash and wages.
Parameters
- player Player The player being updated
- curTime Number The current
CurTime() - infoTable Map The player's per-think info table (
player.cwInfoTable); fields such aswages,runSpeedandinventoryWeightcan be changed to affect the player
Implements hook OneSecond
Called once a second on the server, from the cw.OneSecondTimer timer.
Distributes hints every hint_interval and wages every wages_interval (adjustable through
ModifyWagesInterval), advances the in-game clock every minute_time, runs PreSaveData,
SaveData and PostSaveData every save_data_interval, and changes to the same map after
20 minutes with no players.
Implements hook OnHookError
Called when a hook errors; shows the hook error notice on the HUD for 3 seconds.
Parameters
- name String The hook name
- isGM Boolean Whether the error was in a gamemode hook
- message String The error message
GM:OnNPCKilled(entity, attacker, inflictor)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2960Called when an NPC has been killed; overridden to do nothing (no kill notice).
Parameters
- entity NPC The NPC
- attacker Entity The attacker
- inflictor Entity The inflictor
GM:OnPhysgunFreeze(weapon, physicsObject, entity, player)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2782Called when a player attempts to freeze an entity with the physics gun.
Players with the o flag can always freeze persistent entities. Otherwise non-admins cannot
freeze other characters' props under prop protection, chairs near doors, entities with
PhysgunDisabled or non-interactable entities, and nobody can freeze a penetrating entity.
Parameters
- weapon Weapon The physics gun
- physicsObject PhysObj The physics object
- entity Entity The entity
- player Player The player
Returns
- Boolean Whether the entity is frozen
GM:OnPlayerChat(player, text, teamOnly, playerIsDead)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2998Called when a player says something; suppresses the default chat.
Console messages are added to the Catwork chatbox.
Parameters
- player Player The player, or an invalid entity for the console
- text String The message
- teamOnly Boolean Whether it was team only
- playerIsDead Boolean Whether the player is dead
Returns
- Boolean Always
true
Called when the gamemode has been reloaded by AutoRefresh.
Sets cw.Reloaded. On the server it re-runs cw.database:OnConnected when SQLite is used (a
MySQL connection survives the reload). On the client it recreates the theme's fonts and skin
and re-initializes the theme.
GM:PaintItemTargetID(x, y, alpha, itemTable)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:3055Implements hook PaintItemTargetID
Called before an item entity's target ID is drawn; return false to stop the default draw.
Parameters
- x Number The text x position
- y Number The text y position
- alpha Number The text alpha
- itemTable Item The item
Returns
- Boolean Whether the default target ID is drawn
Called when a player drops an entity with the physics gun.
Restores the prop's collision group or the player's movement and gives the entity 60 seconds of damage immunity.
Parameters
- player Player The player
- entity Entity The entity
Called when a player attempts to pick up an entity with the physics gun.
Non-admins cannot pick up non-interactable entities, player ragdolls, other characters'
ragdolls or (under prop protection) props, chairs near doors, or map props unless
enable_map_props_physgrab is set, and nobody can grab players in vehicles or observers. On
pickup props lose collision while held when prop_kill_protection is set and get 60 seconds
of damage immunity; picked up players are switched to noclip movement.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean Whether the pickup is allowed
GM:PlayerAddToSavedInventory(player, character, Callback)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:356Implements hook PlayerAddToSavedInventory
Called when a player's inventory is being saved, to add items that are not in it.
Catwork adds the item of every weapon the player is holding, so equipped weapons are saved.
Parameters
- player Player The player whose inventory is saved
- character Character The character being saved
- Callback Function Call with an
Itemto add it to the saved inventory
GM:PlayerAdjustBulletInfo(player, bulletInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1461Implements hook PlayerAdjustBulletInfo
Called when a player fires bullets, to adjust the bullet table in place; does nothing by default.
Parameters
- player Player The player firing
- bulletInfo Map The
Bulletstructure passed toEntity:FireBullets
GM:PlayerAdjustBusinessItemTable(itemTable)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2441Implements hook PlayerAdjustBusinessItemTable
Called to adjust an item shown in the business menu; does nothing by default.
Parameters
- itemTable Item The item, which can be changed
GM:PlayerAdjustCharacterCreationInfo(player, info, data)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3713Implements hook PlayerAdjustCharacterCreationInfo
Called when a player creates a character, to adjust or refuse the new character; does nothing by default.
Parameters
- player Player The player
- info Map The new character, which can be changed
- data Map The data the client sent
Returns
- Any
falseto refuse with a generic fault, or a fault string to refuse with that message
GM:PlayerAdjustCharacterScreenInfo(player, character, info)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3743Implements hook PlayerAdjustCharacterScreenInfo
Called before a character is sent to the character menu, to adjust how it is shown.
Catwork uses the faction rank's model if it has one.
Parameters
- player Player The player
- character Character The character
- info Map What the menu shows:
name,model,banned,faction,characterID,detailsand so on
GM:PlayerAdjustCharacterTable(player, character)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3735Implements hook PlayerAdjustCharacterTable
Called for each of a player's characters as they are loaded into the character menu; does nothing by default.
Parameters
- player Player The player
- character Character The character, which can be changed
Returns
- Boolean
trueto delete the character instead of listing it
GM:PlayerAdjustClassModelInfo(class, info)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2446Implements hook PlayerAdjustClassModelInfo
Called to adjust the model shown for a class in the classes menu; does nothing by default.
Parameters
- class Number The class index
- info Map
modelandskin, which can be changed
Implements hook PlayerAdjustColorModify
Called to adjust the local player's colour modification; does nothing by default.
Parameters
- colorModify Map The
$pp_colour_*values, modified in place
Implements hook PlayerAdjustDeathInfo
Called when a player dies, to adjust their respawn time; does nothing by default.
Parameters
- player Player The player
- info Map
attacker,inflictor,damageInfoandspawnTime, which can be changed
GM:PlayerAdjustDropWeaponInfo(player, info)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3704Implements hook PlayerAdjustDropWeaponInfo
Called for each weapon a dead player drops, to adjust how it is dropped.
Parameters
- player Player The player
- info Map
itemTable,positionandanglesof the dropped item, which can be changed
Returns
- Boolean Whether the weapon item entity is created
Implements hook PlayerAdjustHeadbobInfo
Called to adjust the local player's headbob.
Speeds up and strengthens the bob while walking and running, scaled by cwHeadbobScale, and
sways it further the more drunk the player is.
Parameters
- info Map
speed,yawandrollof the headbob, modified in place
GM:PlayerAdjustItemFunctions(itemTable, itemFunctions)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2492Implements hook PlayerAdjustItemFunctions
Called to adjust the functions offered for an item in the inventory; does nothing by default.
Parameters
- itemTable Item The item
- itemFunctions List<Map> The functions, as
{ title = ..., name = ... }entries, modified in place
GM:PlayerAdjustMenuFunctions(itemTable, menuPanel, itemFunctions)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2487Called when the local player's item menu should be adjusted; does nothing by default.
Parameters
- itemTable Item The item
- menuPanel Panel The menu
- itemFunctions List The item's functions
Implements hook PlayerAdjustMotionBlurs
Called to adjust the local player's motion blur; does nothing by default.
Parameters
- motionBlurs Map
enabledandblurTable(blur amounts by name, the lowest is used), modified in place
GM:PlayerAdjustNextPunchInfo(player, info)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3723Implements hook PlayerAdjustNextPunchInfo
Called after a player punches with cw_hands, to adjust the delay before the next punch; does nothing by default.
Parameters
- player Player The player
- info Map
primaryFireandsecondaryFire, the delays in seconds, which can be changed
GM:PlayerAdjustOrderItemTable(player, itemTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3718Called when a player orders a shipment with /OrderShipment, to adjust the ordered item; does nothing by default.
Parameters
- player Player The player
- itemTable Item The item being ordered
GM:PlayerAdjustPropCostInfo(player, entity, info)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3755Implements hook PlayerAdjustPropCostInfo
Called when a player spawns a prop that costs cash, to adjust the cost; does nothing by default.
Parameters
- player Player The player
- entity Entity The prop
- info Map
costandname(the reason shown for the payment), which can be changed
Implements hook PlayerAdjustRadioInfo
Called when a player speaks on the radio, to choose who hears it; does nothing by default.
Parameters
- player Player The player
- info Map
text,noEavesdropandlisteners; add players tolistenersto let them hear it
GM:PlayerArmorSet(player, newArmor, oldArmor)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2104Implements hook PlayerArmorSet
Called when a player's armor is set; keeps a ragdolled player's stored armor in sync.
Parameters
- player Player The player
- newArmor Number The new armor
- oldArmor Number The previous armor
GM:PlayerBindPress(player, bind, bPress, break_cycle)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:461Called when the local player presses a bind.
Jumping while fallen over runs /CharGetUp. Blocks toggle_zoom, +zoom when
PlayerCanZoom refuses, jumping without stamina (unless noclipping or with the B flag),
attacking while storage is open, and inventory, cash and fall over binds when the matching
block_*_binds config is set. Then runs TopLevelPlayerBindPress and falls back to the base
gamemode.
Parameters
- player Player The local player
- bind String The bind
- bPress Boolean Whether the bind is pressed rather than released
- break_cycle Any
truewhen called back from the base gamemode, to stop recursion; the engine passes the button code here
Returns
- Boolean
trueto block the bind
Called when a player presses a button down.
B toggles the weapon raise when quick_raise_enabled is set and PlayerCanQuickRaise allows.
Parameters
- player Player The player pressing the button
- button Number The button pressed (
KEY_*)
GM:PlayerCanBeGivenWeapon(player, class, itemTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1413Implements hook PlayerCanBeGivenWeapon
Called before a player is given a weapon with Player:Give; return false to block it.
Parameters
- player Player The player receiving the weapon
- class String The weapon class
- itemTable Item The weapon's item, or
nil
Returns
- Boolean Whether the weapon can be given
GM:PlayerCanBypassClassLimit(player, class)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:973Implements hook PlayerCanBypassClassLimit
Called to check whether a player can join a class that is at its player limit; never by default.
Parameters
- player Player The player joining
- class Number The class index
Returns
- Boolean
trueto ignore the class limit
GM:PlayerCanBypassFactionLimit(player, character)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:967Implements hook PlayerCanBypassFactionLimit
Called to check whether a player can use a character in a faction that is at its player limit; never by default.
Parameters
- player Player The player choosing the character
- character Character The character being used
Returns
- Boolean
trueto ignore the faction limit
Implements hook PlayerCanChangeClass
Called when a player attempts to change class with /SetClass; refuses during the class change cooldown.
Parameters
- player Player The player
- class Class The class
Returns
- Boolean Whether the class can be changed
GM:PlayerCanCreateCharacter(player, character, characterID)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1450Implements hook PlayerCanCreateCharacter
Called when a player attempts to create a character.
Catwork refuses while the quiz is enabled and not completed.
Parameters
- player Player The player creating the character
- character Character The new character's data
- characterID Number The ID the character will get
Returns
- Any
falseto refuse with a generic fault, a fault string to refuse with that message, ortrueto allow
GM:PlayerCanDeathClearName(player, attacker, damageInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2282Implements hook PlayerCanDeathClearName
Called when a player dies, to check whether everyone forgets their name; never by default.
Parameters
- player Player The player who died
- attacker Entity The killer
- damageInfo CTakeDamageInfo The fatal damage
Returns
- Boolean
trueto clear the name withcw.player:ClearName
GM:PlayerCanDeathClearRecognisedNames(player, attacker, damageInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2289Implements hook PlayerCanDeathClearRecognisedNames
Called when a player dies, to check whether they forget everyone they recognised; never by default.
Parameters
- player Player The player who died
- attacker Entity The killer
- damageInfo CTakeDamageInfo The fatal damage
Returns
- Boolean
trueto clear the player's recognised names
GM:PlayerCanDeleteCharacter(player, character)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2017Implements hook PlayerCanDeleteCharacter
Called when a player attempts to delete a character; allows it by default.
Parameters
- player Player The player
- character Character The character to delete
Returns
- Any
nilortrueto allow; anything else refuses, and a string is shown as the reason
GM:PlayerCanDestroyItem(player, itemTable, bNoMsg)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2258Implements hook PlayerCanDestroyItem
Called when a player attempts to destroy an item; always allows it.
Return false to block it.
Parameters
- player Player The player
- itemTable Item The item
- bNoMsg Boolean Whether to skip notifying the player
Returns
- Boolean Whether the item can be destroyed
GM:PlayerCanDropItem(player, itemTable, bNoMsg)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2248Implements hook PlayerCanDropItem
Called when a player attempts to drop an item; always allows it.
Return false to block the drop.
Parameters
- player Player The player
- itemTable Item The item
- bNoMsg Any Whether to skip notifying the player; the inventory command passes the drop position here
Returns
- Boolean Whether the item can be dropped
GM:PlayerCanDropWeapon(player, itemTable, weapon, bNoMsg)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2197Implements hook PlayerCanDropWeapon
Called when a player attempts to drop a weapon.
Spawn weapons cannot be dropped; otherwise the item's own CanDropWeapon decides when it has
one.
Parameters
- player Player The player
- itemTable Item The weapon's item
- weapon Weapon The weapon
- bNoMsg Boolean Whether to skip notifying the player
Returns
- Boolean Whether the weapon can be dropped
Implements hook PlayerCanEarnWagesCash
Called on each wages payout, to check whether a player earns wages; always allows it.
Parameters
- player Player The player
- cash Number The wages amount
Returns
- Boolean Whether the player earns wages;
PlayerEarnWagesCashonly runs when allowed
GM:PlayerCanFireWeapon(player, bIsRaised, weapon, bIsSecondary)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:453Implements hook PlayerCanFireWeapon
Called to check whether a player can fire their weapon; returning false delays the shot.
Catwork blocks firing when the player lacks the stamina a melee weapon needs, is sprinting with
sprint_lowers_weapon set, holds the weapon lowered and PlayerCanUseLoweredWeapon refuses,
or is still on player.cwNextShootTime. With limb damage enabled, arm damage randomly stops
the player from firing for a while.
Parameters
- player Player The player firing
- bIsRaised Boolean Whether the weapon is raised
- weapon Weapon The weapon being fired
- bIsSecondary Boolean optional, defaults to
nilWhether this is the secondary attack
Returns
- Boolean Whether the weapon can fire
Implements hook PlayerCanGainFrag
Called when a player kills another player, to check whether the killer gains a frag; always allows it.
Parameters
- player Player The killer
- victim Player The victim
Returns
- Boolean Whether a frag is added
Implements hook PlayerCanGetUp
On the server
Called when a player who has fallen over attempts to get up with /CharGetUp; always allows it.
On the client it is called without a player to decide whether to show the get up hint.
Parameters
- player Player The player getting up
Returns
- Boolean Whether the player can get up
On the client
Called to check whether the local player can get up while fallen over, to show the get up hint; always allows it.
Parameters
- player
Returns
- Boolean Whether the hint is shown
Defined in
GM:PlayerCanGiveToStorage(player, storageTable, itemTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:652Implements hook PlayerCanGiveToStorage
Called to check whether a player can put an item in storage.
Catwork always allows it and tags the item with the character's key and unique ID so other characters cannot take it back out.
Parameters
- player Player The player storing the item
- storageTable Map The open storage
- itemTable Item The item being stored
Returns
- Boolean Return
falseto block storing the item
GM:PlayerCanHearPlayersVoice(listener, speaker)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1988Called when a player attempts to hear another player's voice.
Refuses when voice is disabled, the speaker is voice banned or lacks the x flag. With
local_voice, both players must also be alive, conscious and within talk_radius.
Parameters
- listener Player The player listening
- speaker Player The player talking
Returns
- Boolean Whether the listener hears the speaker
- Boolean Whether the voice is 3D
GM:PlayerCanHolsterWeapon(player, itemTable, weapon, bForce, bNoMsg)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2174Implements hook PlayerCanHolsterWeapon
Called when a player attempts to holster a weapon back into their inventory.
Spawn weapons (from the faction or rank) cannot be holstered; otherwise the item's own
CanHolsterWeapon decides when it has one.
Parameters
- player Player The player
- itemTable Item The weapon's item
- weapon Weapon The weapon
- bForce Boolean Whether the holster is forced
- bNoMsg Boolean Whether to skip notifying the player
Returns
- Boolean Whether the weapon can be holstered
GM:PlayerCanInteractCharacter(player, action, character)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1280Implements hook PlayerCanInteractCharacter
Called when a player attempts to use, delete or otherwise act on one of their characters from the menu.
Catwork refuses while the quiz is enabled and the player has not completed it.
The caller only reads the first return value, so return the fault string itself to show it;
false shows the generic CharFault_CannotInteract fault.
Parameters
- player Player The player acting
- action String The action, such as
useordelete - character Character The character acted on
Returns
- Any
falseor a fault string to refuse, anything else to allow
Called when a player attempts to knock out another player; always allows it.
Parameters
- player Player The player
- target Player The target
Returns
- Boolean Whether the knockout is allowed
Called when a player attempts to lock an entity with the keys; doors need door access, other entities are allowed.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean Whether the entity can be locked
GM:PlayerCanOrderShipment(player, itemTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:921Called when a player attempts to order an item shipment; refuses while player.cwNextOrderTime has not passed.
Parameters
- player Player The player ordering
- itemTable Item The item being ordered
Returns
- Boolean Whether the order is allowed
Implements hook PlayerCanOwnDoor
Called when a player attempts to own a door; refuses doors marked unownable.
Parameters
- player Player The player
- door Entity The door
Returns
- Boolean Whether the door can be owned
Called when a player attempts to pick up a weapon.
Only allowed when the weapon is being given (player.cwForceGive) or the player is looking at
it and holding use.
Parameters
- player Player The player picking up
- weapon Weapon The weapon
Returns
- Boolean Whether the weapon can be picked up
Implements hook PlayerCanPunchEntity
Called when a punch with cw_hands hits an entity, to check whether it damages it; never does by default.
Parameters
- player Player The player punching
- entity Entity The entity hit
Returns
- Boolean Whether the punch damages the entity
GM:PlayerCanPunchKnockout(player, target, trace)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:957Implements hook PlayerCanPunchKnockout
Called when a punch with cw_hands hits a player, to check whether it knocks them out.
Catwork allows it on head hits. A knockout ragdolls the target for 15 seconds and runs
PlayerPunchKnockout.
Parameters
- player Player The player punching
- target Player The player hit
- trace Map The punch trace result
Returns
- Boolean
trueto knock the target out
Implements hook PlayerCanQuickRaise
Called when a player presses the quick raise key, to check whether they can toggle their weapon; always allows it.
Parameters
- player Player The player raising their weapon
- weapon Weapon The player's active weapon
Returns
- Boolean Whether the weapon raise toggles
GM:PlayerCanRadio(player, text, listeners, eavesdroppers)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2275Implements hook PlayerCanRadio
Called when a player attempts to speak on the radio; always allows it.
Return false to block the message.
Parameters
- player Player The player speaking
- text String The message
- listeners List<Player> Players who will hear it over the radio, can be changed
- eavesdroppers List<Player> Players nearby who will overhear it, can be changed
Returns
- Boolean Whether the message is sent
GM:PlayerCanRagdoll(player, state, delay, decay, ragdoll)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2318Implements hook PlayerCanRagdoll
Called when a player attempts to be ragdolled; always allows it.
Parameters
- player Player The player
- state Number The ragdoll state (
RAGDOLL_*) - delay Number Seconds until the player gets up, or
nil - decay Number Seconds until the ragdoll decays, or
nil - ragdoll Map The existing ragdoll table when changing state while ragdolled, otherwise
nil
Returns
- Boolean Whether the player is ragdolled
GM:PlayerCanRagdollDecay(player, ragdoll, seconds)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2483Implements hook PlayerCanRagdollDecay
Called when a dead player's ragdoll is about to be set to decay; always allows it.
Parameters
- player Player The player
- ragdoll Entity The ragdoll
- seconds Number The decay time
Returns
- Boolean Whether the ragdoll decays
GM:PlayerCanRestoreRecognisedName(player, target)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:913Implements hook PlayerCanRestoreRecognisedName
Called to check whether a saved recognised name is restored when both players are on.
When it does not return true the saved name is forgotten. Catwork allows it for anyone but
the player themselves.
Parameters
- player Player The player who recognised the target
- target Player The player who was recognised
Returns
- Boolean
trueto restore the name
GM:PlayerCanSaveRecognisedName(player, target)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:902Implements hook PlayerCanSaveRecognisedName
Called to check whether a recognised name may be saved with the character.
Only asked when save_recognised_names is enabled and a player recognises someone with
RECOGNISE_SAVE; when it does not return true the recognition only lasts for the session
(RECOGNISE_TOTAL). Catwork allows it for anyone but the player themselves.
Parameters
- player Player The player recognising
- target Player The player being recognised
Returns
- Boolean
trueto save the name
Implements hook PlayerCanSayIC
Called when a player attempts to say something in character.
Dead or fallen over players cannot talk, unless they have a death code (for the death code
prompt). Return false to block the message.
Parameters
- player Player The player
- text String The message
Returns
- Boolean Whether the message is sent
Implements hook PlayerCanSayLOOC
Called when a player attempts to say something local out of character; always allows it.
Parameters
- player Player The player
- text String The message
Returns
- Boolean Whether the message is sent
Implements hook PlayerCanSayOOC
Called when a player attempts to say something out of character; always allows it.
Parameters
- player Player The player
- text String The message
Returns
- Boolean Whether the message is sent
Implements hook PlayerCanSeeAdminESP
Called to check whether an admin local player sees the admin ESP; follows the cwAdminESP ConVar.
Returns
- Boolean Whether the ESP is drawn
Implements hook PlayerCanSeeBars
Called to check whether the local player sees a group of HUD bars.
tab bars show in the info menu (when cwTopBars is off), top bars show while alive (when
cwTopBars is on), and other groups always show.
Parameters
- class String The bar group, such as
toportab
Returns
- Boolean Whether the bars are drawn
Implements hook PlayerCanSeeBusinessItem
Called to check whether an item is listed in the business menu; always lists it.
Parameters
- itemTable Item The item
Returns
- Boolean Whether the item is listed
Implements hook PlayerCanSeeCenterHints
Called to check whether the local player sees the center hints; always shows them.
Returns
- Boolean Whether the hints are drawn
Implements hook PlayerCanSeeClass
Called to check whether a class is listed in the classes menu; always lists it.
Parameters
- class Class The class
Returns
- Boolean Whether the class is listed
Implements hook PlayerCanSeeDateTime
Called to check whether the local player sees the date and time; shown in the info menu.
Returns
- Boolean Whether the date and time are drawn
Implements hook PlayerCanSeeHints
Called to check whether the local player sees the top hints; always shows them.
Returns
- Boolean Whether the hints are drawn
Implements hook PlayerCanSeeLimbDamage
Called to check whether the local player sees their limb damage.
It is shown in the info menu when limb_damage_system is enabled.
Returns
- Boolean Whether the limb damage is drawn
Implements hook PlayerCanSeePlayerInfo
Called to check whether the local player sees their player info text; shown in the info menu.
Returns
- Boolean Whether the player info is drawn
GM:PlayerCanSeePlayersChat(text, teamOnly, listener, speaker)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1977Called when a player attempts to see another player's chat; always allows it.
Parameters
- text String The message
- teamOnly Boolean Whether it was sent to the team only
- listener Player The player receiving the message
- speaker Player The player who sent it
Returns
- Boolean Whether the listener sees the message
Implements hook PlayerCanSeeStatus
Called for every initialized player when an admin runs cwStatus, to get the status line shown for them.
Parameters
- player Player The admin running the command
- target Player The player listed
Returns
- String The line to print (user ID, name
- Steam name
- Steam ID and IP), or
nilto hide the player
Implements hook PlayerCanSeeUnconscious
Called to check whether the local player can see while unconscious; never by default, so the screen goes black.
Returns
- Boolean Whether the player can see
GM:PlayerCanShowUnrecognised(player, x, y, color, alpha, flashAlpha)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2972Implements hook PlayerCanShowUnrecognised
Called when the target ID of an unrecognised player is drawn; draws the unrecognised name.
GM:HUDDrawTargetID passes the arguments as (player, x, y, unrecognisedName, teamColor, alpha, flashAlpha), so from color onwards they are shifted by one compared to these names.
Parameters
- player Player The player looked at
- x Number The text x position
- y Number The text y position
- color String The unrecognised name (see above)
- alpha Color The team colour (see above)
- flashAlpha Number The text alpha (see above)
Returns
- Any
trueto draw the unrecognised name, a string to draw that text instead, a number to draw nothing and continue at that y position
GM:PlayerCanSwitchCharacter(player, character)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2026Implements hook PlayerCanSwitchCharacter
Called when a player who already has a character loaded attempts to switch to another.
Refuses while dead (unless the character menu was reset or the character is banned) and while knocked out.
Parameters
- player Player The player
- character Character The character to switch to
Returns
- Any
nilortrueto allow; anything else refuses, and a string is shown as the reason
GM:PlayerCanTakeFromStorage(player, storageTable, itemTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:668Implements hook PlayerCanTakeFromStorage
Called to check whether a player can take an item out of storage.
Refuses, with a notification and a log entry, when the item was stored by another character
(see cw.entity:BelongsToAnotherCharacter); otherwise clears the item's owner tag.
Parameters
- player Player The player taking the item
- storageTable Map The open storage
- itemTable Item The item being taken
Returns
- Boolean Whether the item can be taken
Implements hook PlayerCanThrowPunch
Called when a player attempts to throw a punch with cw_hands; always allows it.
Parameters
- player Player The player punching
Returns
- Boolean Whether the punch is thrown
Implements hook PlayerCanUnlockEntity
Called when a player attempts to unlock an entity with the keys; doors need door access, other entities are allowed.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean Whether the entity can be unlocked
GM:PlayerCanUnragdoll(player, state, ragdoll)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2327Implements hook PlayerCanUnragdoll
Called when a player attempts to be unragdolled; always allows it.
Parameters
- player Player The player
- state Number The ragdoll state (
RAGDOLL_*) - ragdoll Map The player's ragdoll table
Returns
- Boolean Whether the player gets up
GM:PlayerCanUseCharacter(player, character)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2043Implements hook PlayerCanUseCharacter
Called when a player attempts to use a character.
Refuses banned characters and characters whose faction or faction rank is at its
playerLimit.
Parameters
- player Player The player
- character Character The character to use
Returns
- Any
nilortrueto allow; anything else refuses, and a string is shown as the reason
GM:PlayerCanUseCommand(player, commandTable, arguments)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2666Implements hook PlayerCanUseCommand
Called when a player attempts to use a command, before argument and access checks; always allows it.
Parameters
- player Player The player
- commandTable Command The command
- arguments List<String> The command arguments
Returns
- Boolean Whether the command runs
Implements hook PlayerCanUseDoor
Called when a player presses use on a door, to check whether they can open it.
Owned doors need door access and false doors cannot be used. When allowed, PlayerUseDoor
runs and the door is opened.
Parameters
- player Player The player
- door Entity The door
Returns
- Boolean Whether the door opens
GM:PlayerCanUseEntityInVehicle(player, entity, vehicle)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2472Implements hook PlayerCanUseEntityInVehicle
Called to check whether a player in a vehicle can use the entity they look at.
Allowed for doors and entities with UsableInVehicle set; while it returns true for the
looked at entity, the use key does not exit the vehicle.
Parameters
- player Player The player
- entity Entity The entity looked at
- vehicle Vehicle The player's vehicle
Returns
- Boolean Whether the entity can be used
GM:PlayerCanUseItem(player, itemTable, bNoMsg)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2219Implements hook PlayerCanUseItem
Called when a player attempts to use an item from their inventory.
Catwork refuses, with a notification unless bNoMsg is set, when the item is a weapon the
player already has as a spawn weapon. Return false to block the use.
Parameters
- player Player The player
- itemTable Item The item
- bNoMsg Boolean optional, defaults to
nilWhether to skip notifying the player
Returns
- Boolean Whether the item can be used
GM:PlayerCanUseLoweredWeapon(player, weapon, secondary)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:515Implements hook PlayerCanUseLoweredWeapon
Called to check whether a player can fire a weapon while it is lowered.
Allowed when the weapon, or its Primary/Secondary table, has NeverRaised set.
Parameters
- player Player The player firing
- weapon Weapon The lowered weapon
- secondary Boolean Whether this is the secondary attack
Returns
- Boolean Whether the lowered weapon can fire
Implements hook PlayerCanViewDoor
Called when a player attempts to view a door's menu; refuses doors marked unownable.
Parameters
- player Player The player
- door Entity The door
Returns
- Boolean Whether the door menu opens
Implements hook PlayerCanZoom
Called when the local player attempts to zoom with +zoom; always allows it.
Returns
- Boolean Whether the zoom bind runs
GM:PlayerCashUpdated(player, amount, reason, bNoMsg)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:728Implements hook PlayerCashUpdated
Called after a player's cash has changed; syncs it with their open storage via cw.storage:SyncCash.
Parameters
- player Player The player whose cash changed
- amount Number The amount given (negative when taken)
- reason String Why the cash changed, or
nil - bNoMsg Boolean Whether the change should be silent
GM:PlayerCharacterCreated(player, character)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3564Implements hook PlayerCharacterCreated
Called after a player has created a character, before it is added to the character menu; does nothing by default.
Parameters
- player Player The player
- character Character The new character
Implements hook PlayerCharacterInitialized
Called when a player's character has initialized, while it loads.
Clears and resends the player's inventory, attributes and limb damage, assigns the default
class when needed, queues the starter hints, sends CharacterInit to the client, and sets the
faction rank (the default or lowest one, or SCN when the name contains SCN), applying the
rank's class and model.
Parameters
- player Player The player
Implements hook PlayerCharacterLoaded
Called when a player's character has loaded.
Resets the player's per-character state and movement values, runs
PlayerRestoreCharacterData and PlayerCharacterInitialized, restores recognised names and
property, and marks the player initialized. Clears any stored OnNextLoad payload without
running it, runs each item's OnRestorePlayerGear, gives the saved player flags and restores
the saved class.
Parameters
- player Player The player
Implements hook PlayerCharacterScreenCreated
Called when the local player's character screen is created; asks the server for the quiz status.
The status is only requested when the quiz is enabled.
Parameters
- panel Panel The character menu
Implements hook PlayerCharacterUnloaded
Called when a player's character has unloaded.
Schedules the character's property for removal, disables it, resets the ragdoll, closes
storage and unassigns the team. When called by GM:PlayerDisconnected, returning true
keeps the character from being saved.
Parameters
- player Player The player
GM:PlayerClassSet(player, newClass, oldClass, noRespawn, addDelay, noModelChange)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2424Implements hook PlayerClassSet
Called after a player's class has been set; saves the class name in the character data.
Parameters
- player Player The player
- newClass Class The new class
- oldClass Class The previous class
- noRespawn Boolean Whether the player is not respawned
- addDelay Boolean Whether a class change delay is added
- noModelChange Boolean Whether the model is kept
Implements hook PlayerConfigInitialized
Called when the config has been sent to a player.
Runs PlayerSendDataStreamInfo, then tells clients to start data streaming; bots skip
straight to PlayerDataStreamInfoSent.
Parameters
- player Player The player
Implements hook PlayerDataLoaded
Called when a player's data has loaded.
Shows the Catwork intro once per player when clockwork_intro_enabled is set.
Parameters
- player Player The player whose data loaded
Implements hook PlayerDataStreamInfoSent
Called after a player's initial data stream info has been sent.
Bots get a random faction, gender and model and load a character straight away. Real players
have their data loaded (running PlayerDataLoaded), their whitelists sent and their characters
added to the character menu. A character for which PlayerAdjustCharacterTable returns true
is deleted instead.
Parameters
- player Player The player the data was sent to
GM:PlayerDeath(player, inflictor, attacker, damageInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3927Implements hook PlayerDeath
Called when a player dies.
Starts the respawn timer with cw.core:CalculateSpawnTime, disintegrates the ragdoll when
killed by a combine ball, and logs the kill.
Parameters
- player Player The player
- inflictor Entity The inflictor
- attacker Entity The killer
- damageInfo CTakeDamageInfo The fatal damage, or
nil
GM:PlayerDeathCodeUsed(player, commandTable, arguments)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3559Implements hook PlayerDeathCodeUsed
Called when a player has used their death code, before it is taken; does nothing by default.
Parameters
- player Player The player
- commandTable Command The command that used the death code
- arguments List<String> The command arguments
Called when the default death sound for a player should be played; returns true to mute it, Catwork plays its own.
Parameters
- player Player The player
Returns
- Boolean Always
true
Called every frame while a player is dead.
Respawns the player as soon as they have a usable character, unless their character is banned,
the character menu has been reset, or a spawn action (the respawn timer) is running.
Parameters
- player Player The dead player
Returns
- Boolean
trueto keep the player dead this frame
GM:PlayerDeleteCharacter(player, character)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2098Implements hook PlayerDeleteCharacter
Called after a player deletes a character; does nothing by default.
Parameters
- player Player The player
- character Character The deleted character
Implements hook PlayerDestroyItem
Called after a player destroys an item; does nothing by default.
Parameters
- player Player The player who destroyed it
- itemTable Item The item
Called when a player has disconnected.
For initialized players, saves the character unless PlayerCharacterUnloaded returns true,
then logs the disconnect and announces it in the chatbox.
Parameters
- player Player The player who disconnected
GM:PlayerDoesHaveDoorAccess(player, door, access, isAccurate)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2374Implements hook PlayerDoesHaveDoorAccess
Called by cw.player:HasDoorAccess to check whether a player has an access level on a door.
The door's owner always has access; other characters need an entry in door.accessList.
Parameters
- player Player The player
- door Entity The door, or the door's parent when it has one
- access Number The access level required (
DOOR_ACCESS_*) - isAccurate Boolean
trueto require exactly that level instead of at least it
Returns
- Boolean Whether the player has the access
Implements hook PlayerDoesHaveFlag
On the server
Called by cw.player:HasFlags to check whether a player has a flag they do not hold themselves.
Catwork grants the flags in the default_flags config to everyone.
Parameters
- player Player The player
- flag String A single flag
Returns
- Boolean
trueto grant the flag,falseto deny it,nilto fall through
On the client
Called to check whether a player has a flag they do not hold themselves; grants the default_flags config flags.
Parameters
- player Player The player
- flag String A single flag
Returns
- Boolean
trueto grant the flag,falseto deny it,nilto fall through
Defined in
GM:PlayerDoesRecognisePlayer(player, target, status, isAccurate, realValue)
shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2401Implements hook PlayerDoesRecognisePlayer
On the server
Called after recognition is worked out, to override whether a player recognises another.
Catwork returns the computed value unchanged.
Parameters
- player Player The player who may recognise the target
- target Player The player who may be recognised
- status Number The recognition level asked about (
RECOGNISE_*) - isAccurate Boolean Whether the level must match exactly
- realValue Boolean Whether the player recognises the target according to the saved names
Returns
- Boolean Whether the player recognises the target
On the client
Called after recognition is worked out, to override whether the local player recognises another.
Catwork returns the computed value unchanged.
Parameters
- player Player The player who may be recognised
- status Number The recognition level asked about (
RECOGNISE_*) - isAccurate Boolean Whether the level must match exactly
- realValue Boolean Whether the local player recognises the player according to their recognised names
Returns
- Boolean Whether the local player recognises the player
Defined in
GM:PlayerDropItem(player, itemTable, position, entity)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1909Implements hook PlayerDropItem
Called after a player drops an item; does nothing by default.
Parameters
- player Player The player who dropped it
- itemTable Item The item
- position Vector Where it was dropped
- entity Entity The spawned item entity
GM:PlayerDropWeapon(player, itemTable, entity, weapon)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1921Implements hook PlayerDropWeapon
Called after a player drops a weapon; saves the weapon's clip ammo on its item.
Parameters
- player Player The player who dropped it
- itemTable Item The weapon's item
- entity Entity The spawned item entity
- weapon Weapon The weapon that was dropped
Implements hook PlayerEarnWagesCash
Called after a player has earned wages; does nothing by default.
Parameters
- player Player The player
- cash Number The wages amount
GM:PlayerEnteredVehicle(player, vehicle, class)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2568Called when a player enters a vehicle; offsets human models (not /player/ models) so they sit correctly.
Parameters
- player Player The player
- vehicle Vehicle The vehicle
- class Number The seat role
Implements hook PlayerFlagsGiven
Called when a player has been given flags.
Gives the physgun for p and the toolgun for t if the player is alive, and networks the
player's flags.
Parameters
- player Player The player given the flags
- flags String The flags that were given
Implements hook PlayerFlagsTaken
Called when a player has had flags taken.
Takes the physgun for p and the toolgun for t unless the player still has the flag (for
example from the default flags), and networks the player's flags.
Parameters
- player Player The player whose flags were taken
- flags String The flags that were taken
GM:PlayerFootstep(player, position, foot, sound, volume, recipientFilter)
shared gamemodes/catwork/gamemode/hooks/sh_hooks.lua:260Called when a player's footstep sound should be played; returns true to suppress every footstep.
Parameters
- player Player The player stepping
- position Vector Where the footstep happens
- foot Number 0 for the left foot, 1 for the right
- sound String The footstep sound path
- volume Number The footstep volume
- recipientFilter CRecipientFilter Who would hear the sound
Returns
- Boolean Always
true, so the default sound is not played
Implements hook PlayerGetHoldingEntity
Called by Player:GetHoldingEntity to get the entity a player is holding.
Return an entity to override player.cwIsHoldingEnt.
Parameters
- player Player The player
Returns
- Entity The held entity, or
nilto use the default
Called when a player tries to lock an entity with the keys, to get how it is locked.
For doors the time is the lock_time config, multiplied by 1 + arm damage when limb damage
is enabled, and the callback fires the door's lock input.
Parameters
- player Player The player locking
- entity Entity The entity being locked
Returns
- Map
durationin seconds andCallback(player, entity)run when it finishes, ornilif the entity cannot be locked
Called when a player tries to unlock an entity with the keys, to get how it is unlocked.
For doors the time is the unlock_time config, multiplied by 1 + arm damage when limb
damage is enabled, and the callback fires the door's unlock input.
Parameters
- player Player The player unlocking
- entity Entity The entity being unlocked
Returns
- Map
durationin seconds andCallback(player, entity)run when it finishes, ornilif the entity cannot be unlocked
GM:PlayerGivenWeapon(player, class, itemTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1424Implements hook PlayerGivenWeapon
Called after a player has been given a weapon.
Rebuilds the inventory menu and attaches visible gear for weapon items: Throwable, Melee,
Secondary (weight 2 or less) or Primary.
Parameters
- player Player The player given the weapon
- class String The weapon class
- itemTable Item The weapon's item, or
nil
Called when a player attempts to give themselves a SWEP; only super admins can.
Parameters
- player Player The player
- class String The weapon class
- weapon Map The weapon's table
Returns
- Boolean Whether the SWEP is given
GM:PlayerGiveToStorage(player, storageTable, itemTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:687Implements hook PlayerGiveToStorage
Called after a player has put an item in storage; takes it off if it was worn as clothes or an accessory.
Parameters
- player Player The player who stored the item
- storageTable Map The open storage
- itemTable Item The stored item
GM:PlayerGiveWagesCash(player, cash, wagesName)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2620Implements hook PlayerGiveWagesCash
Called before positive wages are given to a player; return false to keep the cash from being given.
Parameters
- player Player The player
- cash Number The wages amount
- wagesName String The name the wages are given under
Returns
- Boolean Whether the cash is given
Implements hook PlayerGiveWeapons
Called when a player's spawn weapons should be given; gives the weapons listed by their faction rank and faction.
Parameters
- player Player The player
Called to check whether the local player has lenses, an item with the unique ID lenses in their inventory.
Returns
- Boolean Whether the player has lenses
GM:PlayerHealthRegenerate(player, health, maxHealth)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1871Implements hook PlayerHealthRegenerate
Called once a second to regenerate a living player's health.
Heals 2 health every 5 seconds while above half health, otherwise every 10 seconds.
Parameters
- player Player The player to heal
- health Number The player's health
- maxHealth Number The player's maximum health
GM:PlayerHealthSet(player, newHealth, oldHealth)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2118Implements hook PlayerHealthSet
Called when a player's health is set.
Healing also heals limb damage by half the amount gained; reaching full health heals every limb and removes decals from the player and their ragdoll. Keeps a ragdolled player's stored health in sync.
Parameters
- player Player The player
- newHealth Number The new health
- oldHealth Number The previous health
Called when a player initially spawns.
Sets up the player's character list and shared variables, kills them silently until a character is loaded, sends the config to bots, and logs and announces the connection unless the player is being kicked.
Parameters
- player Player The player who joined
GM:PlayerItemGiven(player, itemTable, bForce)
shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:701Implements hook PlayerItemGiven
On the server
Called after a player is given an item; syncs it with their open storage via cw.storage:SyncItem.
Parameters
- player Player The player given the item
- itemTable Item The item given
- bForce Boolean Whether the item was forced into the inventory regardless of weight
On the client
Called when the local player is given an item; rebuilds the open storage panel.
Parameters
- itemTable Item The item that was given
Defined in
Implements hook PlayerItemTaken
On the server
Called after a player has an item taken.
Syncs the item with their open storage and takes it off if it was worn as clothes or an accessory.
Parameters
- player Player The player the item was taken from
- itemTable Item The item taken
On the client
Called when the local player has an item taken from them; rebuilds the open storage panel.
Parameters
- itemTable Item The item that was taken
Defined in
Called when a player leaves a vehicle; moves players leaving a chair to a safe position near where they looked.
Parameters
- player Player The player
- vehicle Vehicle The vehicle left
GM:PlayerLimbDamageHealed(player, hitGroup, amount)
shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1657Implements hook PlayerLimbDamageHealed
On the server
Called when a player's limb damage is healed; does nothing by default.
Parameters
- player Player The healed player
- hitGroup Number The hit group (
HITGROUP_*) - amount Number The limb's new damage amount
On the client
Called when the local player's limb damage is healed; does nothing by default.
Parameters
- hitGroup Number The hit group (
HITGROUP_*) - amount Number The amount healed
Defined in
Implements hook PlayerLimbDamageReceived
Called when the local player's limb damage is received from the server; does nothing by default.
Implements hook PlayerLimbDamageReset
On the server
Called when a player's limb damage is reset; does nothing by default.
Parameters
- player Player The player whose limb damage was reset
On the client
Called when the local player's limb damage is reset; does nothing by default.
Parameters
- player
Defined in
GM:PlayerLimbTakeDamage(player, hitGroup, damage)
shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1663Implements hook PlayerLimbTakeDamage
On the server
Called when a player's limb takes damage; does nothing by default.
Parameters
- player Player The hurt player
- hitGroup Number The hit group (
HITGROUP_*) - damage Number The damage taken
On the client
Called when the local player's limb takes damage; does nothing by default.
Parameters
- hitGroup Number The hit group (
HITGROUP_*) - damage Number The damage taken
Defined in
Implements hook PlayerLoadout
Called when a player's spawn weapons should be given.
Gives the toolgun and physgun for the t and p flags (with the player's weapon colour when
custom_weapon_color is set), the gravity gun, cw_hands and cw_keys when configured, and
the class's weapons and ammo, then runs PlayerGiveWeapons and selects the hands.
Parameters
- player Player The player
GM:PlayerModelChanged(player, strNewModel, strOldModel)
shared gamemodes/catwork/gamemode/hooks/sh_hooks.lua:52Implements hook PlayerModelChanged
Called after a player's model is changed with Player:SetModel, on both realms.
Catwork caches the model's animation table from cw.animation:GetTable and stores it as
player.cwAnimTable, which GM:TranslateActivity uses. On the client it also disables IK.
Parameters
- player Player The player whose model changed
- strNewModel String Path of the new model
- strOldModel String Path of the previous model
Defined in
Implements hook PlayerModifyWagesInfo
Called before a player is paid wages, to change the amount; does nothing by default.
Parameters
- player Player The player being paid
- info Map Has
wages, the amount to pay, which can be changed
Called when a player attempts to noclip; only super admins who are not ragdolled can.
Parameters
- player Player The player
Returns
- Boolean Whether noclip toggles
GM:PlayerPickupItem(player, itemTable, itemEntity, bQuickUse)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1896Implements hook PlayerPickupItem
Called after a player picks up an item entity; does nothing by default.
Parameters
- player Player The player who picked it up
- itemTable Item The item
- itemEntity Entity The item entity that was picked up
- bQuickUse Boolean Whether the item was used straight away instead of taken
Implements hook PlayerPlayDeathSound
Called to choose the sound a player makes when they die; returns a random HL2 citizen pain line.
Parameters
- player Player The dying player
- gender String The player's gender
Returns
- String The sound path, or
nilfor no sound
GM:PlayerPlayPainSound(player, gender, damageInfo, hitGroup)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:984Implements hook PlayerPlayPainSound
Called to choose the pain sound a player makes when hurt.
Half of bullet hits play a hit group specific HL2 citizen line (head, gut, leg, arm, gear);
everything else plays a random pain line.
Parameters
- player Player The hurt player
- gender String The player's gender,
maleorfemale - damageInfo CTakeDamageInfo The damage taken
- hitGroup Number The hit group (
HITGROUP_*)
Returns
- String The sound path, or
nilfor no sound
GM:PlayerRadioUsed(player, text, listeners, eavesdroppers)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3698Implements hook PlayerRadioUsed
Called after a player has spoken on the radio; does nothing by default.
Parameters
- player Player The player
- text String The message
- listeners List<Player> Players who heard it over the radio
- eavesdroppers List<Player> Players nearby who overheard it
GM:PlayerRagdollCanTakeDamage(player, ragdoll, inflictor, attacker, hitGroup, damageInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2301Implements hook PlayerRagdollCanTakeDamage
Called when a ragdolled player's ragdoll attempts to take damage.
Damage from non-players is ignored while the ragdoll's immunity time has not passed.
Parameters
- player Player The ragdolled player
- ragdoll Entity The ragdoll
- inflictor Entity The inflictor
- attacker Entity The attacker
- hitGroup Number The hit group (
HITGROUP_*) - damageInfo CTakeDamageInfo The damage
Returns
- Boolean Whether the damage is applied to the player
GM:PlayerRagdolled(player, state, ragdoll)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2335Implements hook PlayerRagdolled
Called after a player has been ragdolled; clears the fallen over flag.
Parameters
- player Player The player
- state Number The ragdoll state (
RAGDOLL_*) - ragdoll Map The player's ragdoll table
GM:PlayerRestoreCharacterData(player, data)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1633Implements hook PlayerRestoreCharacterData
Called when a player's character data is restored as the character loads.
Cleans up the physical description and makes sure LimbData, Clothes and Accessories
exist before passing the data to cw.player:RestoreCharacterData.
Parameters
- player Player The player loading the character
- data Map The character's saved data, modified in place
Implements hook PlayerRestoreData
Called when a player's (not character's) data is restored; makes sure Whitelisted exists.
Parameters
- player Player The player
- data Map The player's saved data, modified in place
Implements hook PlayerReturnProperty
Called after a player's property has been returned to their character; does nothing by default.
Parameters
- player Player The player
Implements hook PlayerSaveCharacterData
Called when a player's character data is about to be saved.
Saves attribute boosts when save_attribute_boosts is set, and health and armor when they are
above 1.
Parameters
- player Player The player whose character is saved
- data Map The character data to save, modified in place
Implements hook PlayerSaveData
Called when a player's (not character's) data is about to be saved; drops an empty Whitelisted table.
Parameters
- player Player The player whose data is saved
- data Map The player data to save, modified in place
Called when a player sends a chat message; replaces a command alias after the prefix with the real command.
Parameters
- player Player The player
- text String The message
- bPublic Boolean Whether the message is not team only
Returns
- String The rewritten message, or
nilto leave it unchanged
GM:PlayerScaleDamageByHitGroup(player, attacker, hitGroup, damageInfo, baseDamage)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:740Implements hook PlayerScaleDamageByHitGroup
Called to scale damage a player takes by hit group.
Catwork cuts damage from vehicles and from players in vehicles to a quarter.
Parameters
- player Player The player taking damage
- attacker Entity The attacker
- hitGroup Number The hit group (
HITGROUP_*) - damageInfo CTakeDamageInfo The damage to scale in place
- baseDamage Number The damage before scaling
GM:PlayerSelectCharacterOption(player, character, option)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1960Called when a player selects a custom character option; does nothing by default.
The character menu actually runs PlayerSelectCustomCharacterOption for options other than
use and delete.
Parameters
- player Player The player
- character Character The character
- option String The option
GM:PlayerSelectCustomCharacterOption(player, action, character)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4165Implements hook PlayerSelectCustomCharacterOption
Called when a player picks a character menu action other than use or delete; does nothing by default.
Parameters
- player Player The player
- action String The action
- character Character The character
Implements hook PlayerSendDataStreamInfo
Called when a player's initial data stream info should be sent; sends the shared tables and any colour mod override.
Parameters
- player Player The player to send the data to
GM:PlayerSetDefaultColorModify(colorModify)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2496Implements hook PlayerSetDefaultColorModify
Called to set the local player's default colour modification when no override is active; does nothing by default.
Parameters
- colorModify Map The
$pp_colour_*values, modified in place
Called to choose the hands model for a player's player model.
Uses cw.animation:GetHandsInfo, falling back to GMod's player hands, sets the model, skin and
bodygroups, then runs PostCModelHandsSet.
Parameters
- player Player The player whose hands are set
- entity Entity The hands entity
Implements hook PlayerSetModel
Called when a player's model should be set; applies their default model and skin.
Parameters
- player Player The player
Implements hook PlayerShouldHealthRegenerate
Called once a second, when health regeneration is enabled, to check whether a player regenerates.
Always allows it.
Parameters
- player Player The player
Returns
- Boolean Whether
PlayerHealthRegenerateruns for the player
GM:PlayerShouldShowOnDoorAccessList(player, door, owner)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:426Implements hook PlayerShouldShowOnDoorAccessList
Called to check whether a player appears in the door access menu; always shows them.
Parameters
- player Player The player
- door Entity The door
- owner Player The door's owner
Returns
- Boolean Whether the player is listed
Implements hook PlayerShouldShowOnScoreboard
Called to check whether a player appears on the scoreboard; always shows them.
Parameters
- player Player The player
Returns
- Boolean Whether the player is listed
GM:PlayerShouldTakeDamage(player, attacker, inflictor, damageInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3835Implements hook PlayerShouldTakeDamage
Called when a player would take damage; players in noclip take none.
Parameters
- player Player The player
- attacker Entity The attacker
- inflictor Entity The inflictor
- damageInfo CTakeDamageInfo The damage
Returns
- Boolean Whether the damage is applied
Called when a player has spawned.
Uninitialized players are killed silently. For a full spawn (not a light spawn from
cw.player:LightSpawn) Catwork resets ragdoll, action, drunk, boosts and limb damage, sets
the model and loadout, applies config movement speeds and the faction or rank's health and
armor, gives the faction's respawnInv items, applies the faction's NPC relationships and
restores saved ammo on the first spawn. It then runs the light spawn callback, runs
PostPlayerSpawn, and re-applies clothes and accessories.
Parameters
- player Player The player who spawned
Called after a player has spawned an NPC; applies every player's faction entRelationship to it.
Parameters
- player Player The player who spawned the NPC
- npc NPC The NPC
GM:PlayerSpawnedProp(player, model, entity)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3199Called after a player has spawned a prop.
When scale_prop_cost is above zero (and the player is not observing), charges a cost based
on the prop's size, adjustable through PlayerAdjustPropCostInfo, and removes the prop if the
player cannot afford it. The cost is refunded if the prop is removed within 10 seconds. Sets
the prop's owner key, logs the spawn and gives prop kill protection immunity.
Parameters
- player Player The player
- model String The prop model
- entity Entity The prop
Called when a player attempts to spawn an effect; requires a living, standing player and admin rights.
Parameters
- player Player The player
- model String The effect model
Returns
- Boolean Whether the effect can be spawned
Called when a player attempts to spawn an NPC.
Requires the n flag, a living, standing player, and admin rights.
Parameters
- player Player The player
- model String The NPC class
Returns
- Boolean Whether the NPC can be spawned
Called when a player attempts to spawn a prop; requires the e flag and a living, standing player.
Parameters
- player Player The player
- model String The prop model
Returns
- Boolean Whether the prop can be spawned
Called when a player attempts to spawn a ragdoll; requires the r flag, admin rights and a living, standing player.
Parameters
- player Player The player
- model String The ragdoll model
Returns
- Boolean Whether the ragdoll can be spawned
Called when a player attempts to spawn a scripted entity; only super admins can.
Parameters
- player Player The player
- class String The entity class
Returns
- Boolean Whether the entity can be spawned
Called when a player attempts to spawn a SWEP; only super admins can.
Parameters
- player Player The player
- class String The weapon class
- weapon Map The weapon's table
Returns
- Boolean Whether the SWEP can be spawned
Called when a player attempts to spawn a vehicle.
Chairs and seats need the c flag, other vehicles the C flag, and the player must be alive
and standing. Admins can always spawn; others are subject to the base gamemode's limits.
Parameters
- player Player The player
- model String The vehicle model
Returns
- Boolean Whether the vehicle can be spawned
Called when a player attempts to spray their tag.
Dead and ragdolled players cannot spray; otherwise the disable_sprays config decides, unless
the config/player_spray event is disabled.
Parameters
- player Player The player spraying
Returns
- Boolean
trueto block the spray
Called when a player starts using voice.
With local_voice, no voice indicator is shown for players who have fallen over, are dead or
lack the x flag.
Parameters
- player Player The talking player
GM:PlayerStorageShouldClose(player, storageTable)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1708Implements hook PlayerStorageShouldClose
Called every player think while a player has storage open, to check whether it should close.
Closes it when the player is ragdolled or dead, the storage entity is gone or out of
storageTable.distance, or the storage's own ShouldClose callback returns true.
Parameters
- player Player The player with storage open
- storageTable Map The open storage
Returns
- Boolean
trueto close the storage
Called when a player switches their flashlight on or off; ragdolled players cannot turn it on.
Parameters
- player Player The player toggling the flashlight
- bIsOn Boolean Whether the flashlight is being turned on
Returns
- Boolean Whether the switch is allowed
GM:PlayerTakeDamage(player, inflictor, attacker, hitGroup, damageInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4177Implements hook PlayerTakeDamage
Called when a player (or their ragdoll) takes damage that does not kill them.
With limb damage stumbling enabled, a bullet to the legs while both legs are above 50 damage makes the player fall over for 8 seconds.
Parameters
- player Player The player
- inflictor Entity The inflictor
- attacker Entity The attacker
- hitGroup Number The hit group (
HITGROUP_*) - damageInfo CTakeDamageInfo The damage
Returns
- Boolean
trueto suppress the pain sound
Implements hook PlayerThink
Called every 0.15 seconds for every initialized player.
GM:Tick resets infoTable to the defaults before calling this, so plugins can adjust it
here. Catwork tracks how long the player has been underwater, keeps ragdolled players in
observer movement, closes storage when PlayerStorageShouldClose says so, networks inventory
weight, space and wages, slows the player for leg damage and when walking backwards, updates
weapon raising and saves the active weapon item's clip ammo.
Parameters
- player Player The player being updated
- curTime Number The current
CurTime() - infoTable Map The player's info table with
inventoryWeight,inventorySpace,crouchedSpeed,jumpPower,walkSpeed,runSpeed,isRunning,isJumpingandwages
GM:PlayerTraceAttack(player, damageInfo, direction, trace)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3845Called when a player is hit by a trace attack; remembers the hit group for limb damage and pain sounds.
Parameters
- player Player The player
- damageInfo CTakeDamageInfo The damage
- direction Vector The attack direction
- trace Map The trace result
Returns
- Boolean Always
false
GM:PlayerUnragdolled(player, state, ragdoll)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2343Implements hook PlayerUnragdolled
Called after a player has been unragdolled; clears the fallen over flag.
Parameters
- player Player The player
- state Number The ragdoll state (
RAGDOLL_*) - ragdoll Map The player's ragdoll table
Implements hook PlayerUse
Called when a player attempts to use an entity; players who have fallen over cannot use anything.
Parameters
- player Player The player using the entity
- entity Entity The entity being used
Returns
- Boolean Whether the use is allowed
Implements hook PlayerUseDoor
Called when a player opens a door with use, just before it opens; does nothing by default.
Parameters
- player Player The player
- door Entity The door
GM:PlayerUseItem(player, itemTable, itemEntity)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1902Implements hook PlayerUseItem
Called after a player uses an item; does nothing by default.
Parameters
- player Player The player who used it
- itemTable Item The item
- itemEntity Entity The item entity it was used from, or
nilwhen used from the inventory
GM:PlayerUseUnknownItemFunction(player, itemTable, itemFunction)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3729Implements hook PlayerUseUnknownItemFunction
Called when a player runs an inventory action that Catwork does not handle; does nothing by default.
Parameters
- player Player The player
- itemTable Item The item
- itemFunction String The action name
Called when the tool menu needs to be populated; registers Catwork tools with gmod_tool and the spawn menu.
GM:PostCommandUsed(player, command, arguments)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4605Implements hook PostCommandUsed
Called after a player uses a command; does nothing by default.
Parameters
- player Player The player who used the command
- command Command The command used
- arguments List<String> The arguments given with the command, if any
Implements hook PostDrawBackgroundBlurs
Called just after the background blurs have been drawn.
Draws the selected faction's image on the character screen, the title box of a titled menu and the date and time.
Implements hook PostDrawBar
Called just after a HUD bar is drawn; does nothing by default.
Parameters
- barInfo Map The bar's position, size, colour, text and progress
Returns
- Boolean
trueto skip drawing the bar's text
Implements hook PostDrawDateTimeBox
Called just after the date and time box is drawn in the info menu; does nothing by default.
Parameters
- info Map The box's
x,yandwidth
GM:PostDrawPlayerInfo(boxInfo, information, subInformation)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1788Implements hook PostDrawPlayerInfo
Called just after the local player's information box is drawn; does nothing by default.
Parameters
- boxInfo Map The box position and size
- information Map The player info text lines
- subInformation Map The player info sub text lines
GM:PostDrawTranslucentRenderables(bDrawingDepth, bDrawingSkybox, bDrawing3DSkybox)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2214Called after translucent renderables are drawn; draws the 3D2D text of doors within 256 units.
Parameters
- bDrawingDepth Boolean Whether this is a depth pass, skipped
- bDrawingSkybox Boolean Whether the skybox is being drawn
- bDrawing3DSkybox Boolean Whether the 3D skybox is being drawn, skipped
GM:PostPlayerSpawn(player, lightSpawn, changeClass, firstSpawn)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3792Implements hook PostPlayerSpawn
Called just after a player spawns, from GM:PlayerSpawn.
On the first spawn of a character it restores saved health, armor and attribute boosts; later spawns clear them from the character data. Sets the player's target name to their faction.
Parameters
- player Player The player
- lightSpawn Boolean Whether this was a light spawn
- changeClass Boolean Whether the spawn is from a class change
- firstSpawn Boolean Whether this is the character's first spawn
Called to check whether a sandbox post process is permitted; never.
Parameters
- class String The post process name
Returns
- Boolean Always
false
Called after the VGUI has been rendered; draws the current cinematic and the active markup tooltip.
Implements hook PreDrawBar
Called just before a HUD bar is drawn; does nothing by default.
Parameters
- barInfo Map The bar's position, size, colour, text and progress
Returns
- Boolean
trueto skip drawing the bar's background and fill
Called before halos are drawn; outlines the entity whose entity menu is open.
GM:PreDrawPlayerInfo(boxInfo, information, subInformation)
client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1782Implements hook PreDrawPlayerInfo
Called just before the local player's information box is drawn in the info menu; does nothing by default.
Parameters
- boxInfo Map The box position and size
- information Map The player info text lines
- subInformation Map The player info sub text lines
Returns
- Boolean
trueto skip drawing the box
GM:PrePlayerTakeDamage(player, attacker, inflictor, damageInfo)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3827Implements hook PrePlayerTakeDamage
Called just before a player would take damage; does nothing by default.
Parameters
- player Player The player
- attacker Entity The attacker
- inflictor Entity The inflictor
- damageInfo CTakeDamageInfo The damage
Called when screen space effects should be rendered.
Blurs the screen for head damage or low health, drains colour with lost health, draws the
underwater fish eye effect and applies colour modification: the Color Modify system's override
when enabled, otherwise PlayerSetDefaultColorModify. PlayerAdjustColorModify and
PlayerAdjustMotionBlurs can adjust the result. The colour pass is skipped while its values are neutral.
Implements hook SaveData
Called when Catwork data is saved.
Saves every initialized player's character and, unless they follow the machine clock, the in-game time and date.
GM:ScaleDamageByHitGroup(player, attacker, hitGroup, damageInfo, baseDamage)
server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4617Called to scale damage a player takes by hit group.
Except for fall and crush damage, head, chest and limb hits are scaled by scale_head_dmg,
scale_chest_dmg and scale_limb_dmg; head hits also punch the view and muffle the sound.
Then runs PlayerScaleDamageByHitGroup.
Parameters
- player Player The player taking damage
- attacker Entity The attacker
- hitGroup Number The hit group (
HITGROUP_*) - damageInfo CTakeDamageInfo The damage to scale in place
- baseDamage Number The damage before scaling
Implements hook ScoreboardAdjustPlayerInfo
Called to adjust a player's scoreboard entry; does nothing by default.
Parameters
- info Map The entry, with
player,textand the other fields the scoreboard shows
Called when the scoreboard key is released; closes the main menu if it was held for at least half a second.
Called when the scoreboard key is pressed; opens the main menu when CanShowTabMenu allows.
Implements hook ScoreboardSortClassPlayers
Called to sort the players within a class on the scoreboard.
Players the local player recognises come first, and recognised players are sorted by team.
Parameters
- class String The class name
- a Player The first player
- b Player The second player
Returns
- Boolean Whether
acomes beforeb
Called when a player's move data is set up; overridden to do nothing.
Parameters
- player Player The player moving
- moveData CMoveData The move data
Called to set up a player's visibility; adds their ragdoll's position to the PVS so it keeps being networked.
Parameters
- player Player The player
Implements hook ShouldCharacterMenuBeCreated
Called to check whether the character menu can be created yet; waits while the intro is fading out.
Returns
- Boolean Whether the character menu is created
Implements hook ShouldDrawBackgroundBlurs
Called to check whether the background blurs are drawn; always draws them.
Returns
- Boolean Whether the blurs are drawn
Implements hook ShouldDrawCharacterBackground
Called to check whether the black character menu background is drawn; always draws it.
Returns
- Boolean Whether the background is drawn
Implements hook ShouldDrawCharacterBackgroundBlur
Called to check whether the character menu background blur is drawn; always draws it.
Returns
- Boolean Whether the blur is drawn
Called to check whether a character creation fault is drawn; always draws it.
Parameters
- fault String The fault
Returns
- Boolean Whether the fault is drawn
Called to check whether the menu background blur is drawn; always draws it.
Returns
- Boolean Whether the blur is drawn
Implements hook ShouldDrawPlayerTargetID
Called to check whether a looked at player's target ID is drawn; always draws it.
Parameters
- player Player The player looked at
Returns
- Boolean Whether the target ID is drawn
Implements hook ShouldPlayerScreenFadeBlack
Called to check whether the local player's screen fades to black.
Fades while dead or fallen over, unless PlayerCanSeeUnconscious allows seeing.
Returns
- Boolean Whether the screen fades to black
Called when a player presses F1; toggles their information menu.
Parameters
- player Player The player
Called when a player presses F2.
Looking at a door within 192 units that they can view and use, the player gets the door
management menu (with complete access to an owned door) or the purchase prompt (for an unowned
door). Otherwise the recognise menu opens when recognise_system is enabled. Does nothing in
noclip.
Parameters
- ply Player The player
Called when the server shuts down; saves all data through PreSaveData, SaveData and PostSaveData.
Called when the local player begins typing; returns true to hide the default chat box.
Parameters
- team Boolean Whether team chat is being opened
Returns
- Boolean Always
true
On the server
Called every frame; overridden to do nothing, Catwork's periodic work runs from GM:Tick.
On the client
Called each frame; calculates hints and shows or hides the character screen.
The character screen's visibility comes from GetPlayerCharacterScreenVisible.
Defined in
On the server
Called each tick; drives the per-player think hooks.
Every 0.15 seconds it resets each initialized player's cwInfoTable (the default_inv_weight
and default_inv_space configs, the player's base speeds, running and jumping state and class
wages) and runs PlayerThink; once a second it also runs OnePlayerSecond.
On the client
Called each tick on the client.
Creates the character menu when polling and ShouldCharacterMenuBeCreated allows, rebuilds the
HUD bars and player info text through GetBars, DestroyBars, GetPlayerInfoText and
DestroyPlayerInfoText, fades dead NPCs, plays the low health heartbeat, closes the info menu
once F1 is released, plays or fades the menu music and runs network proxy callbacks.
Defined in
Called to translate a player activity into the one their model should play.
Uses the player's cached animation table (player.cwAnimTable) and the hold type from
cw.animation:GetWeaponHoldType, picking the lowered or raised variant depending on
Player:IsWeaponRaised (the cw_keys weapon is always lowered). In vehicles the sitchair1
sequence is used. Falls back to the base gamemode when the model has no animation table.
String animations are applied as a sequence override instead of being returned.
Parameters
- player Player The player being animated
- act Number The activity to translate (
ACT_*)
Returns
- Number The translated activity, or
nilwhen a sequence override was set instead