Summary

Hooks

Called when entity outlines should be added; outlines the entity whose entity menu is open.
Called when GMod shows a hint; shows it as a Catwork top hint once a character is loaded.
Called when GMod shows a notification; passes it to the base gamemode unless it is a #Hint_ hint.
Called to add ammo types that are saved with the character; adds the HL2 ammo types.
Called when a player attempts to pick up an entity with use; always refuses, Catwork handles picking up itself.
Called to pick the main activity and sequence a player should be playing.
Called when the view should be calculated.
Called to adjust the final view table from GM:CalcView; does nothing by default.
Called to position the view model; tilts it into the lowered pose while the weapon is lowered.
Called to check whether the Catwork crosshair is drawn; never by default.
Called when a player attempts to drive an entity; only living, standing admins can.
Called when a player attempts to exit a vehicle.
Called when a player attempts to enter a vehicle; always allows it.
Called when a player attempts to suicide; always refuses.
Called when a player attempts to unfreeze an entity.
Called when a player attempts to use the property menu; only living, standing admins can.
Called before the main menu is opened or closed with the scoreboard key; always allows it.
Called when a player attempts to use a tool.
Called to sort the characters within a faction on the character screen; sorts them by name.
Called when chat box info should be adjusted; logs in-character and LOOC messages.
Called when the chat box is closed; does nothing by default.
Called when a key is typed in the chat box; up and down cycle through the remembered messages.
Called when the chat box is opened; does nothing by default.
Called when the chat box text has changed; does nothing by default.
Called when chat box text has been sent; remembers the last 25 messages for the up and down keys.
Called when engine chat text is received from the server; returns true to suppress it.
Called when a player attempts to connect; refuses banned players.
Called when a config value has changed.
Called for each config key once the config has initialized, from GM:Initialize.
Called when a ConVar created with cw.core:CreateConVar has changed.
Called when the directory is rebuilt; lists help only for the commands the local player has the flags for.
Called when Catwork has initialized, at the end of GM:Initialize.
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.
Called when the scoreboard should be created; overridden to do nothing, the scoreboard is part of the main menu.
Called when the Catwork database has connected; loads the ban list with cw.bans:Load.
Called when the Catwork database connection fails; reports it with cw.database:Error.
Called after the HUD bars are collected, so bars can be removed; does nothing by default.
Called after the player info text is collected, so lines can be removed; does nothing by default.
Called after the target player text is collected, so lines can be removed; does nothing by default.
Called when an animation event such as an attack, reload or jump should be played.
Called just before a player dies.
Called when the local player's crosshair should be drawn; draws five small dots.
Called when the local player's screen damage should be drawn; draws the damage overlay.
Called when the local player's vignette should be drawn.
Called to draw a looked at player's status below their target ID; shows that they are deceased.
Called when an entity fires bullets; overridden to do nothing.
Called when a player picks an option from an entity's menu.
Called when an entity is removed, except while the server shuts down.
Called when an entity takes damage; Catwork's central damage handler.
Called when the Derma skin's name is needed; forces the Clockwork skin.
Called each tick when the HUD bars are collected; does nothing by default.
Called to get how long the character loading screen lasts; 8 seconds.
Called to get the tooltip of a character in the character menu.
Called when the cinematic intro info is needed; uses the schema's author, name and description.
Called when a piece of information about a door is needed for its 3D2D text.
Called to get who is holding an entity.
Called when an entity's menu options are needed.
Called to get the fall damage a player takes.
Called by the engine to get the gamemode name shown in the server browser.
Called to get which faction group a character is shown under on the character screen; uses its faction.
Called each frame to check whether the character screen is visible.
Called to position the local player's crosshair; with use_free_aiming it follows where the weapon actually aims.
Called to fill a new character's starting inventory.
Called to get a player's default model, from cw.class:GetAppropriateModel for their team.
Called to get a player's default skin, from cw.class:GetAppropriateModel for their team.
Called to get the name a player is listed under in the door access menu; uses their name.
Called when the local player's info text (shown in the F1 menu) is needed.
Called to get the scoreboard group a player is listed under; uses their team name.
Called when the admin options for a player on the scoreboard are needed.
Called to get the text under a player's name on the scoreboard.
Called to get whether a player's weapon is raised.
Called to get the progress bar shown in the middle of the screen.
Called to get the text shown in the middle of the screen; shows a notice while the character is banned.
Called to get a player's status lines for the admin ESP.
Called to get how far away a player's target ID text stays visible; 4096 units by default.
Called to get the name drawn on a recognised player's target ID; uses their name.
Called when the text below a looked at player's name is needed.
Called to adjust a weapon's lowered view model pose; does nothing by default.
Called to play GMod's "grab ear" animation while typing; overridden to do nothing.
Called when a player drops an entity with the gravity gun; clears who holds what.
Called when a player picks up an entity with the gravity gun; records who holds what.
Called when a player attempts to pick up an entity with the gravity gun.
Called when a player attempts to punt an entity with the gravity gun; allowed when enable_gravgun_punt is set.
Called when the GUI mouse has been released.
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.
Called every frame to draw the full screen layers above the HUD.
Called when the target ID HUD should be drawn.
Called to display a HUD notification when an item has been picked up; overridden to show nothing.
Called when the HUD should be painted.
Called when the foreground HUD should be painted.
Called when a player's HUD should be painted; does nothing by default.
Called to check whether a HUD element should be drawn.
Called to display a HUD notification when a weapon has been picked up; overridden to show nothing.
Called when the server has initialized.
Called when the map entities are initialized.
Called when an item entity has been destroyed by damage, before it explodes; does nothing by default.
Called when an item entity has taken damage, before its health drops; does nothing by default.
Called when an item's data changes, to pick who receives the update.
Called when an item's network data has been updated; runs the item's OnNetworkDataUpdated.
Called when a player presses a key.
Called when a player releases a key; overridden to do nothing.
Called when the local player entity has been created.
Called when the main menu is closed; runs OnMenuClosed on each menu panel and closes tooltips and Derma menus.
Called when the main menu's items should be added.
Called after the main menu's items are added, so they can be removed; does nothing by default.
Called when the main menu is opened; runs OnMenuOpened on each menu panel that has it.
Called when the next wages payout is scheduled, to change the interval; does nothing by default.
Called to move a player's mouth while they speak.
Called before a notification from the server is shown, to adjust it; shows every notification.
Called when an attribute is progressed, before the amount is applied.
Called when the context menu is closed.
Called when the context menu is opened.
Called about once a second for every initialized player, after GM:PlayerThink.
Called once a second on the server, from the cw.OneSecondTimer timer.
Called when a hook errors; shows the hook error notice on the HUD for 3 seconds.
Called when an NPC has been killed; overridden to do nothing (no kill notice).
Called when a player attempts to freeze an entity with the physics gun.
Called when a player says something; suppresses the default chat.
Called when the gamemode has been reloaded by AutoRefresh.
Called before an item entity's target ID is drawn; return false to stop the default draw.
Called when a player drops an entity with the physics gun.
Called when a player attempts to pick up an entity with the physics gun.
Called when a player's inventory is being saved, to add items that are not in it.
Called when a player fires bullets, to adjust the bullet table in place; does nothing by default.
Called to adjust an item shown in the business menu; does nothing by default.
Called when a player creates a character, to adjust or refuse the new character; does nothing by default.
Called before a character is sent to the character menu, to adjust how it is shown.
Called for each of a player's characters as they are loaded into the character menu; does nothing by default.
Called to adjust the model shown for a class in the classes menu; does nothing by default.
Called to adjust the local player's colour modification; does nothing by default.
Called when a player dies, to adjust their respawn time; does nothing by default.
Called for each weapon a dead player drops, to adjust how it is dropped.
Called to adjust the local player's headbob.
Called to adjust the functions offered for an item in the inventory; does nothing by default.
Called when the local player's item menu should be adjusted; does nothing by default.
Called to adjust the local player's motion blur; does nothing by default.
Called after a player punches with cw_hands, to adjust the delay before the next punch; does nothing by default.
Called when a player orders a shipment with /OrderShipment, to adjust the ordered item; does nothing by default.
Called when a player spawns a prop that costs cash, to adjust the cost; does nothing by default.
Called when a player speaks on the radio, to choose who hears it; does nothing by default.
Called when a player's armor is set; keeps a ragdolled player's stored armor in sync.
Called when the local player presses a bind.
Called when a player presses a button down.
Called before a player is given a weapon with Player:Give; return false to block it.
Called to check whether a player can join a class that is at its player limit; never by default.
Called to check whether a player can use a character in a faction that is at its player limit; never by default.
Called when a player attempts to change class with /SetClass; refuses during the class change cooldown.
Called when a player attempts to create a character.
Called when a player dies, to check whether everyone forgets their name; never by default.
Called when a player dies, to check whether they forget everyone they recognised; never by default.
Called when a player attempts to delete a character; allows it by default.
Called when a player attempts to destroy an item; always allows it.
Called when a player attempts to drop an item; always allows it.
Called when a player attempts to drop a weapon.
Called on each wages payout, to check whether a player earns wages; always allows it.
Called to check whether a player can fire their weapon; returning false delays the shot.
Called when a player kills another player, to check whether the killer gains a frag; always allows it.
Called when a player who has fallen over attempts to get up with /CharGetUp; always allows it.
Called to check whether a player can put an item in storage.
Called when a player attempts to hear another player's voice.
Called when a player attempts to holster a weapon back into their inventory.
Called when a player attempts to use, delete or otherwise act on one of their characters from the menu.
Called when a player attempts to knock out another player; always allows it.
Called when a player attempts to lock an entity with the keys; doors need door access, other entities are allowed.
Called when a player attempts to order an item shipment; refuses while player.cwNextOrderTime has not passed.
Called when a player attempts to own a door; refuses doors marked unownable.
Called when a player attempts to pick up a weapon.
Called when a punch with cw_hands hits an entity, to check whether it damages it; never does by default.
Called when a punch with cw_hands hits a player, to check whether it knocks them out.
Called when a player presses the quick raise key, to check whether they can toggle their weapon; always allows it.
Called when a player attempts to speak on the radio; always allows it.
Called when a player attempts to be ragdolled; always allows it.
Called when a dead player's ragdoll is about to be set to decay; always allows it.
Called to check whether a saved recognised name is restored when both players are on.
Called to check whether a recognised name may be saved with the character.
Called when a player attempts to say something in character.
Called when a player attempts to say something local out of character; always allows it.
Called when a player attempts to say something out of character; always allows it.
Called to check whether an admin local player sees the admin ESP; follows the cwAdminESP ConVar.
Called to check whether the local player sees a group of HUD bars.
Called to check whether an item is listed in the business menu; always lists it.
Called to check whether the local player sees the center hints; always shows them.
Called to check whether a class is listed in the classes menu; always lists it.
Called to check whether the local player sees the date and time; shown in the info menu.
Called to check whether the local player sees the top hints; always shows them.
Called to check whether the local player sees their limb damage.
Called to check whether the local player sees their player info text; shown in the info menu.
Called when a player attempts to see another player's chat; always allows it.
Called for every initialized player when an admin runs cwStatus, to get the status line shown for them.
Called to check whether the local player can see while unconscious; never by default, so the screen goes black.
Called when the target ID of an unrecognised player is drawn; draws the unrecognised name.
Called when a player who already has a character loaded attempts to switch to another.
Called to check whether a player can take an item out of storage.
Called when a player attempts to throw a punch with cw_hands; always allows it.
Called when a player attempts to unlock an entity with the keys; doors need door access, other entities are allowed.
Called when a player attempts to be unragdolled; always allows it.
Called when a player attempts to use a character.
Called when a player attempts to use a command, before argument and access checks; always allows it.
Called when a player presses use on a door, to check whether they can open it.
Called to check whether a player in a vehicle can use the entity they look at.
Called when a player attempts to use an item from their inventory.
Called to check whether a player can fire a weapon while it is lowered.
Called when a player attempts to view a door's menu; refuses doors marked unownable.
Called when the local player attempts to zoom with +zoom; always allows it.
Called after a player's cash has changed; syncs it with their open storage via cw.storage:SyncCash.
Called after a player has created a character, before it is added to the character menu; does nothing by default.
Called when a player's character has initialized, while it loads.
Called when a player's character has loaded.
Called when the local player's character screen is created; asks the server for the quiz status.
Called when a player's character has unloaded.
Called after a player's class has been set; saves the class name in the character data.
Called when the config has been sent to a player.
Called when a player's data has loaded.
Called after a player's initial data stream info has been sent.
Called when a player has used their death code, before it is taken; does nothing by default.
Called when the default death sound for a player should be played; returns true to mute it, Catwork plays its own.
Called every frame while a player is dead.
Called after a player deletes a character; does nothing by default.
Called after a player destroys an item; does nothing by default.
Called when a player has disconnected.
Called by cw.player:HasDoorAccess to check whether a player has an access level on a door.
Called by cw.player:HasFlags to check whether a player has a flag they do not hold themselves.
Called after recognition is worked out, to override whether a player recognises another.
Called after a player drops an item; does nothing by default.
Called after a player drops a weapon; saves the weapon's clip ammo on its item.
Called after a player has earned wages; does nothing by default.
Called when a player enters a vehicle; offsets human models (not /player/ models) so they sit correctly.
Called when a player has been given flags.
Called when a player has had flags taken.
Called when a player's footstep sound should be played; returns true to suppress every footstep.
Called by Player:GetHoldingEntity to get the entity a player is holding.
Called when a player tries to lock an entity with the keys, to get how it is locked.
Called when a player tries to unlock an entity with the keys, to get how it is unlocked.
Called after a player has been given a weapon.
Called when a player attempts to give themselves a SWEP; only super admins can.
Called after a player has put an item in storage; takes it off if it was worn as clothes or an accessory.
Called before positive wages are given to a player; return false to keep the cash from being given.
Called when a player's spawn weapons should be given; gives the weapons listed by their faction rank and faction.
Called to check whether the local player has lenses, an item with the unique ID lenses in their inventory.
Called once a second to regenerate a living player's health.
Called when a player's health is set.
Called when a player initially spawns.
Called after a player is given an item; syncs it with their open storage via cw.storage:SyncItem.
Called after a player has an item taken.
Called when a player leaves a vehicle; moves players leaving a chair to a safe position near where they looked.
Called when a player's limb damage is healed; does nothing by default.
Called when the local player's limb damage is received from the server; does nothing by default.
Called when a player's limb damage is reset; does nothing by default.
Called when a player's limb takes damage; does nothing by default.
Called when a player's spawn weapons should be given.
Called after a player's model is changed with Player:SetModel, on both realms.
Called before a player is paid wages, to change the amount; does nothing by default.
Called when a player attempts to noclip; only super admins who are not ragdolled can.
Called after a player picks up an item entity; does nothing by default.
Called to choose the sound a player makes when they die; returns a random HL2 citizen pain line.
Called to choose the pain sound a player makes when hurt.
Called after a player has spoken on the radio; does nothing by default.
Called when a ragdolled player's ragdoll attempts to take damage.
Called after a player has been ragdolled; clears the fallen over flag.
Called when a player's character data is restored as the character loads.
Called when a player's (not character's) data is restored; makes sure Whitelisted exists.
Called after a player's property has been returned to their character; does nothing by default.
Called when a player's character data is about to be saved.
Called when a player's (not character's) data is about to be saved; drops an empty Whitelisted table.
Called when a player sends a chat message; replaces a command alias after the prefix with the real command.
Called to scale damage a player takes by hit group.
Called when a player selects a custom character option; does nothing by default.
Called when a player picks a character menu action other than use or delete; does nothing by default.
Called when a player's initial data stream info should be sent; sends the shared tables and any colour mod override.
Called to set the local player's default colour modification when no override is active; does nothing by default.
Called to choose the hands model for a player's player model.
Called when a player's model should be set; applies their default model and skin.
Called once a second, when health regeneration is enabled, to check whether a player regenerates.
Called to check whether a player appears in the door access menu; always shows them.
Called to check whether a player appears on the scoreboard; always shows them.
Called when a player would take damage; players in noclip take none.
Called when a player has spawned.
Called after a player has spawned an NPC; applies every player's faction entRelationship to it.
Called after a player has spawned a prop.
Called when a player attempts to spawn an effect; requires a living, standing player and admin rights.
Called when a player attempts to spawn an NPC.
Called when a player attempts to spawn a prop; requires the e flag and a living, standing player.
Called when a player attempts to spawn a ragdoll; requires the r flag, admin rights and a living, standing player.
Called when a player attempts to spawn a scripted entity; only super admins can.
Called when a player attempts to spawn a SWEP; only super admins can.
Called when a player attempts to spawn a vehicle.
Called when a player attempts to spray their tag.
Called when a player starts using voice.
Called every player think while a player has storage open, to check whether it should close.
Called when a player switches their flashlight on or off; ragdolled players cannot turn it on.
Called when a player (or their ragdoll) takes damage that does not kill them.
Called every 0.15 seconds for every initialized player.
Called when a player is hit by a trace attack; remembers the hit group for limb damage and pain sounds.
Called after a player has been unragdolled; clears the fallen over flag.
Called when a player attempts to use an entity; players who have fallen over cannot use anything.
Called when a player opens a door with use, just before it opens; does nothing by default.
Called after a player uses an item; does nothing by default.
Called when a player runs an inventory action that Catwork does not handle; does nothing by default.
Called when the tool menu needs to be populated; registers Catwork tools with gmod_tool and the spawn menu.
Called after a player uses a command; does nothing by default.
Called just after the background blurs have been drawn.
Called just after a HUD bar is drawn; does nothing by default.
Called just after the date and time box is drawn in the info menu; does nothing by default.
Called just after the local player's information box is drawn; does nothing by default.
Called after translucent renderables are drawn; draws the 3D2D text of doors within 256 units.
Called to check whether a sandbox post process is permitted; never.
Called after the VGUI has been rendered; draws the current cinematic and the active markup tooltip.
Called just before a HUD bar is drawn; does nothing by default.
Called before halos are drawn; outlines the entity whose entity menu is open.
Called just before the local player's information box is drawn in the info menu; does nothing by default.
Called just before a player would take damage; does nothing by default.
Called when screen space effects should be rendered.
Called when Catwork data is saved.
Called to scale damage a player takes by hit group.
Called to adjust a player's scoreboard entry; does nothing by default.
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.
Called to sort the players within a class on the scoreboard.
Called when a player's move data is set up; overridden to do nothing.
Called to set up a player's visibility; adds their ragdoll's position to the PVS so it keeps being networked.
Called to check whether the character menu can be created yet; waits while the intro is fading out.
Called to check whether the background blurs are drawn; always draws them.
Called to check whether the black character menu background is drawn; always draws it.
Called to check whether the character menu background blur is drawn; always draws it.
Called to check whether a character creation fault is drawn; always draws it.
Called to check whether the menu background blur is drawn; always draws it.
Called to check whether a looked at player's target ID is drawn; always draws it.
Called to check whether the local player's screen fades to black.
Called when a player presses F1; toggles their information menu.
Called when a player presses F2.
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.
Think()shared
Called every frame; overridden to do nothing, Catwork's periodic work runs from GM:Tick.
Tick()shared
Called each tick; drives the per-player think hooks.
Called to translate a player activity into the one their model should play.

Hooks

GM:AddEntityOutlines(outlines)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1117

Implements hook AddEntityOutlines

Called when entity outlines should be added; outlines the entity whose entity menu is open.

Parameters

  • outlines Map The cw.outline library; call outlines: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

GM:AddNotify(text, class, length)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1435

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

GM:AdjustAmmoTypes(ammoTable)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4577

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

GM:AllowPlayerPickup(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1949

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

GM:CalcMainActivity(player, velocity)

shared gamemodes/catwork/gamemode/hooks/sh_hooks.lua:76

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

GM:CalcView(player, origin, angles, fov)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:569

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

GM:CalcViewAdjustTable(view)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2389

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, angles and fov, modified in place

GM:CalcViewModelView(weapon, viewModel, oldEyePos, oldEyeAngles, eyePos, eyeAngles)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:686

Called 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

GM:CanDrawCrosshair(weapon)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2879

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

GM:CanDrive(player, entity)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3439

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

GM:CanExitVehicle(vehicle, player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2495

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:2560

Called 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

GM:CanPlayerSuicide(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2695

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:2748

Called 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

GM:CanProperty(player, property, entity)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3425

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:3339

Called 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:819

Implements 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 a comes before b

GM:ChatBoxAdjustInfo(info)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3764

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, speaker and text

On the client

Called when chat box info should be adjusted; does nothing by default.

Parameters

  • info Map The message info

Defined in

GM:ChatBoxClosed(textTyped)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2367

Implements hook ChatBoxClosed

Called when the chat box is closed; does nothing by default.

Parameters

  • textTyped String The text left in the chat box

GM:ChatBoxKeyCodeTyped(code, text)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2404

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:2398

Implements 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

GM:ChatBoxTextTyped(text)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2371

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

GM:ChatText(index, name, text, class)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:3012

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:1209

Called 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:799

Implements 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

GM:ClockworkConfigInitialized(key, value)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:765

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:783

Implements 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

GM:ClockworkDirectoryRebuilt(panel)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:98

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

GM:ClockworkInitialized()

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:287

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

GM:ClockworkInitPostEntity()

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2630

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.

GM:DatabaseConnectionFailed(errText)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:333

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

GM:DestroyPlayerInfoText(playerInfoText)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1846

Implements hook DestroyPlayerInfoText

Called after the player info text is collected, so lines can be removed; does nothing by default.

Parameters

GM:DestroyTargetPlayerText(player, targetPlayerText)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1877

Implements hook DestroyTargetPlayerText

Called after the target player text is collected, so lines can be removed; does nothing by default.

Parameters

GM:DoAnimationEvent(player, event, data)

shared gamemodes/catwork/gamemode/hooks/sh_hooks.lua:193

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:3859

Implements 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

GM:DrawPlayerCrosshair(x, y, color)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2908

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; true when a custom crosshair was drawn

GM:DrawPlayerScreenDamage(damageFraction)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1109

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:1644

Implements 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

GM:EntityFireBullets(entity, bulletInfo)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1466

Implements hook EntityFireBullets

Called when an entity fires bullets; overridden to do nothing.

Parameters

  • entity Entity The entity firing
  • bulletInfo Map The Bullet structure

GM:EntityHandleMenuOption(player, entity, option, arguments)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3020

Implements 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

GM:EntityRemoved(entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2975

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

GM:EntityTakeDamage(entity, damageInfo)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4204

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.bars library; add bars with its functions

GM:GetCharacterLoadingTime()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2833

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:1666

Implements 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 nil for none

GM:GetCinematicIntroInfo()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2823

Implements hook GetCinematicIntroInfo

Called when the cinematic intro info is needed; uses the schema's author, name and description.

Returns

  • Map credits, title and text of the intro

GM:GetDoorInfo(door, information)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2120

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_NAME or DOOR_INFO_TEXT

Returns

  • String The text, or false to show nothing

GM:GetEntityBeingHeld(entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2965

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

GM:GetEntityMenuOptions(entity, options)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:178

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

GM:GetFallDamage(player, velocity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1476

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

GM:GetGameDescription()

shared gamemodes/catwork/gamemode/shared.lua:67

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:1917

Implements 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

GM:GetPlayerCharacterScreenVisible(panel)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1926

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

GM:GetPlayerCrosshairInfo(info)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2885

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, x and y of the crosshair, modified in place

GM:GetPlayerDefaultInventory(player, character, inventory)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:585

Implements 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

GM:GetPlayerDefaultModel(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:574

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

GM:GetPlayerDefaultSkin(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:566

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:417

Implements 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

GM:GetPlayerInfoText(playerInfoText)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1816

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 its Add(id, text) and AddSub(id, text, priority)

GM:GetPlayerScoreboardClass(player)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1957

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:1969

Implements 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

GM:GetPlayerScoreboardText(player)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1885

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:608

Called 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, isBlocky and blocksAmt of the bar, or nil for 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, text and alpha of the text, or nil to show nothing

GM:GetStatusInfo(player, text)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1680

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

GM:GetTargetPlayerFadeDistance(player)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1840

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

GM:GetTargetPlayerName(player)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2979

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:1854

Implements 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 its Add(id, text)

GM:GetWeaponLoweredViewInfo(itemTable, weapon, viewInfo)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:762

Implements 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) and angles (Angle) of the lowered pose, which can be changed

GM:GrabEarAnimation(player)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:3047

Called to play GMod's "grab ear" animation while typing; overridden to do nothing.

Parameters

  • player Player The player

GM:GravGunOnDropped(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2735

Called when a player drops an entity with the gravity gun; clears who holds what.

Parameters

  • player Player The player
  • entity Entity The entity

GM:GravGunOnPickedUp(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2727

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

GM:GravGunPickupAllowed(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2712

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

GM:GravGunPunt(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2701

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

GM:GUIMouseReleased(code)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:212

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.

GM:HUDAmmoPickedUp(...)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:37

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.

GM:HUDItemPickedUp(...)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:33

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.

GM:HUDPaintPlayer(player)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2837

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

GM:HUDWeaponPickedUp(...)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:29

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:3990

Implements hook ItemEntityDestroyed

Called when an item entity has been destroyed by damage, before it explodes; does nothing by default.

Parameters

  • itemEntity Entity The cw_item entity
  • itemTable Item The item

GM:ItemEntityTakeDamage(itemEntity, itemTable, damageInfo)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3983

Implements hook ItemEntityTakeDamage

Called when an item entity has taken damage, before its health drops; does nothing by default.

Parameters

  • itemEntity Entity The cw_item entity
  • 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:3999

Implements 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 (a Map of player to player) and sendToAll, which can be changed

Returns

  • Boolean true to send the update to everyone

GM:ItemNetworkDataUpdated(itemTable, newData)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1302

Implements 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

GM:KeyPress(player, key)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4458

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_*)

GM:KeyRelease(player, key)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4520

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

GM:LocalPlayerCreated()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:274

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.

GM:ModifyWagesInterval(info)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1737

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

GM:MouthMoveAnimation(player)

shared gamemodes/catwork/gamemode/hooks/sh_hooks.lua:244

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

GM:NotificationAdjustInfo(info)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2435

Implements hook NotificationAdjustInfo

Called before a notification from the server is shown, to adjust it; shows every notification.

Parameters

  • info Map text, class and sound of 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:4571

Implements 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

GM:OnContextMenuClose()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:53

Called when the context menu is closed.

Closes the normal context menu while a tool is in use, otherwise only hides the cursor.

GM:OnContextMenuOpen()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:42

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:135

Implements 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 as wages, runSpeed and inventoryWeight can 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.

GM:OnHookError(name, isGM, message)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:3061

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:2960

Called 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:2782

Called 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:2998

Called 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:3055

Implements 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

GM:PhysgunDrop(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2915

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

GM:PhysgunPickup(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2833

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:356

Implements 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 Item to add it to the saved inventory

GM:PlayerAdjustBulletInfo(player, bulletInfo)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1461

Implements 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 Bullet structure passed to Entity:FireBullets

GM:PlayerAdjustBusinessItemTable(itemTable)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2441

Implements 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:3713

Implements 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 false to 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:3743

Implements 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, details and so on

GM:PlayerAdjustCharacterTable(player, character)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3735

Implements 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 true to delete the character instead of listing it

GM:PlayerAdjustClassModelInfo(class, info)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2446

Implements 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 model and skin, which can be changed

GM:PlayerAdjustColorModify(colorModify)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2500

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

GM:PlayerAdjustDeathInfo(player, info)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3760

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, damageInfo and spawnTime, which can be changed

GM:PlayerAdjustDropWeaponInfo(player, info)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3704

Implements hook PlayerAdjustDropWeaponInfo

Called for each weapon a dead player drops, to adjust how it is dropped.

Parameters

  • player Player The player
  • info Map itemTable, position and angles of the dropped item, which can be changed

Returns

  • Boolean Whether the weapon item entity is created

GM:PlayerAdjustHeadbobInfo(info)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2453

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, yaw and roll of the headbob, modified in place

GM:PlayerAdjustItemFunctions(itemTable, itemFunctions)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2492

Implements 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:2487

Called 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

GM:PlayerAdjustMotionBlurs(motionBlurs)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2481

Implements hook PlayerAdjustMotionBlurs

Called to adjust the local player's motion blur; does nothing by default.

Parameters

  • motionBlurs Map enabled and blurTable (blur amounts by name, the lowest is used), modified in place

GM:PlayerAdjustNextPunchInfo(player, info)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3723

Implements 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 primaryFire and secondaryFire, the delays in seconds, which can be changed

GM:PlayerAdjustOrderItemTable(player, itemTable)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3718

Called 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:3755

Implements 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 cost and name (the reason shown for the payment), which can be changed

GM:PlayerAdjustRadioInfo(player, info)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3775

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, noEavesdrop and listeners; add players to listeners to let them hear it

GM:PlayerArmorSet(player, newArmor, oldArmor)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2104

Implements 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:461

Called 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 true when called back from the base gamemode, to stop recursion; the engine passes the button code here

Returns

  • Boolean true to block the bind

GM:PlayerButtonDown(player, button)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4499

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:1413

Implements 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:973

Implements 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 true to ignore the class limit

GM:PlayerCanBypassFactionLimit(player, character)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:967

Implements 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 true to ignore the faction limit

GM:PlayerCanChangeClass(player, class)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2593

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:1450

Implements 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 false to refuse with a generic fault, a fault string to refuse with that message, or true to allow

GM:PlayerCanDeathClearName(player, attacker, damageInfo)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2282

Implements 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

GM:PlayerCanDeathClearRecognisedNames(player, attacker, damageInfo)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2289

Implements 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 true to clear the player's recognised names

GM:PlayerCanDeleteCharacter(player, character)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2017

Implements 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 nil or true to 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:2258

Implements 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:2248

Implements 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:2197

Implements 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

GM:PlayerCanEarnWagesCash(player, cash)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2611

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; PlayerEarnWagesCash only runs when allowed

GM:PlayerCanFireWeapon(player, bIsRaised, weapon, bIsSecondary)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:453

Implements 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 nil Whether this is the secondary attack

Returns

  • Boolean Whether the weapon can fire

GM:PlayerCanGainFrag(player, victim)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3781

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

GM:PlayerCanGetUp(player)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:936

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:652

Implements 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 false to block storing the item

GM:PlayerCanHearPlayersVoice(listener, speaker)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1988

Called 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:2174

Implements 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:1280

Implements 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 use or delete
  • character Character The character acted on

Returns

  • Any false or a fault string to refuse, anything else to allow

GM:PlayerCanKnockout(player, target)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2264

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

GM:PlayerCanLockEntity(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2409

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:921

Called 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

GM:PlayerCanOwnDoor(player, door)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2144

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

GM:PlayerCanPickupWeapon(player, weapon)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1727

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

GM:PlayerCanPunchEntity(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:947

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:957

Implements 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 true to knock the target out

GM:PlayerCanQuickRaise(player, weapon)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4515

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:2275

Implements 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:2318

Implements 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:2483

Implements 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:913

Implements 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 true to restore the name

GM:PlayerCanSaveRecognisedName(player, target)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:902

Implements 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 true to save the name

GM:PlayerCanSayIC(player, text)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2639

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

GM:PlayerCanSayLOOC(player, text)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2659

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

GM:PlayerCanSayOOC(player, text)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2653

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

GM:PlayerCanSeeAdminESP()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1345

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

GM:PlayerCanSeeBars(class)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1361

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 top or tab

Returns

  • Boolean Whether the bars are drawn

GM:PlayerCanSeeBusinessItem(itemTable)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:446

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

GM:PlayerCanSeeCenterHints()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1389

Implements hook PlayerCanSeeCenterHints

Called to check whether the local player sees the center hints; always shows them.

Returns

  • Boolean Whether the hints are drawn

GM:PlayerCanSeeClass(class)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1410

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

GM:PlayerCanSeeDateTime()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1403

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

GM:PlayerCanSeeLimbDamage()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1397

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

GM:PlayerCanSeePlayerInfo()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1416

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:1977

Called 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

GM:PlayerCanSeeStatus(player, target)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1966

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 nil to hide the player

GM:PlayerCanSeeUnconscious()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:527

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:2972

Implements 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 true to 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:2026

Implements 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 nil or true to 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:668

Implements 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

GM:PlayerCanThrowPunch(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:941

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

GM:PlayerCanUnlockEntity(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2432

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:2327

Implements 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:2043

Implements 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 nil or true to 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:2666

Implements 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

GM:PlayerCanUseDoor(player, door)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2447

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:2472

Implements 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:2219

Implements 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 nil Whether 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:515

Implements 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

GM:PlayerCanViewDoor(player, door)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2156

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:728

Implements 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:3564

Implements 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

GM:PlayerCharacterInitialized(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3469

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

GM:PlayerCharacterLoaded(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3588

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

GM:PlayerCharacterScreenCreated(panel)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1948

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

GM:PlayerCharacterUnloaded(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3572

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:2424

Implements 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

GM:PlayerConfigInitialized(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3679

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

GM:PlayerDataLoaded(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1398

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

GM:PlayerDataStreamInfoSent(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1524

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:3927

Implements 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:3559

Implements 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

GM:PlayerDeathSound(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4411

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

GM:PlayerDeathThink(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1378

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 true to keep the player dead this frame

GM:PlayerDeleteCharacter(player, character)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2098

Implements hook PlayerDeleteCharacter

Called after a player deletes a character; does nothing by default.

Parameters

  • player Player The player
  • character Character The deleted character

GM:PlayerDestroyItem(player, itemTable)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1914

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

GM:PlayerDisconnected(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:263

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:2374

Implements 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 true to require exactly that level instead of at least it

Returns

  • Boolean Whether the player has the access

GM:PlayerDoesHaveFlag(player, flag)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2353

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 true to grant the flag, false to deny it, nil to 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 true to grant the flag, false to deny it, nil to fall through

Defined in

GM:PlayerDoesRecognisePlayer(player, target, status, isAccurate, realValue)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2401

Implements 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:1909

Implements 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:1921

Implements 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

GM:PlayerEarnWagesCash(player, cash)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2627

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:2568

Called 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

GM:PlayerFlagsGiven(player, flags)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:529

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

GM:PlayerFlagsTaken(player, flags)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:547

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:260

Called 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

GM:PlayerGetHoldingEntity(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1863

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 nil to use the default

GM:PlayerGetLockInfo(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:405

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 duration in seconds and Callback(player, entity) run when it finishes, or nil if the entity cannot be locked

GM:PlayerGetUnlockInfo(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:374

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 duration in seconds and Callback(player, entity) run when it finishes, or nil if the entity cannot be unlocked

GM:PlayerGivenWeapon(player, class, itemTable)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1424

Implements 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

GM:PlayerGiveSWEP(player, class, weapon)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4431

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:687

Implements 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:2620

Implements 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

GM:PlayerGiveWeapons(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2078

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:1871

Implements 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:2118

Implements 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

GM:PlayerInitialSpawn(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1346

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:701

Implements 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

GM:PlayerItemTaken(player, itemTable)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:711

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

GM:PlayerLeaveVehicle(player, vehicle)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2534

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:1657

Implements 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

GM:PlayerLimbDamageReceived()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:743

Implements hook PlayerLimbDamageReceived

Called when the local player's limb damage is received from the server; does nothing by default.

GM:PlayerLimbDamageReset(player)

shared gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1667

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:1663

Implements 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

GM:PlayerLoadout(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4029

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:52

Implements 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

GM:PlayerModifyWagesInfo(player, info)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1742

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:1896

Implements 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

GM:PlayerPlayDeathSound(player, gender)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1623

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 nil for no sound

GM:PlayerPlayPainSound(player, gender, damageInfo, hitGroup)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:984

Implements 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, male or female
  • damageInfo CTakeDamageInfo The damage taken
  • hitGroup Number The hit group (HITGROUP_*)

Returns

  • String The sound path, or nil for no sound

GM:PlayerRadioUsed(player, text, listeners, eavesdroppers)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3698

Implements 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:2301

Implements 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:2335

Implements 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:1633

Implements 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

GM:PlayerRestoreData(player, data)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1939

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

GM:PlayerReturnProperty(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3672

Implements hook PlayerReturnProperty

Called after a player's property has been returned to their character; does nothing by default.

Parameters

  • player Player The player

GM:PlayerSaveCharacterData(player, data)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1675

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

GM:PlayerSaveData(player, data)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1695

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

GM:PlayerSay(player, text, bPublic)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2675

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 nil to leave it unchanged

GM:PlayerScaleDamageByHitGroup(player, attacker, hitGroup, damageInfo, baseDamage)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:740

Implements 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:1960

Called 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:4165

Implements 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

GM:PlayerSendDataStreamInfo(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1611

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:2496

Implements 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

GM:PlayerSetHandsModel(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1170

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

GM:PlayerSetModel(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2361

Implements hook PlayerSetModel

Called when a player's model should be set; applies their default model and skin.

Parameters

  • player Player The player

GM:PlayerShouldHealthRegenerate(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:1854

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 PlayerHealthRegenerate runs for the player

GM:PlayerShouldShowOnDoorAccessList(player, door, owner)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:426

Implements 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

GM:PlayerShouldShowOnScoreboard(player)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:433

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:3835

Implements 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

GM:PlayerSpawnedNPC(player, npc)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4535

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:3199

Called 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

GM:PlayerSpawnEffect(player, model)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3284

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

GM:PlayerSpawnNPC(player, model)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2938

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

GM:PlayerSpawnProp(player, model)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3243

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

GM:PlayerSpawnRagdoll(player, model)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3264

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

GM:PlayerSpawnSENT(player, class)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4443

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

GM:PlayerSpawnSWEP(player, class, weapon)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4418

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

GM:PlayerSpawnVehicle(player, model)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3305

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 true to block the spray

GM:PlayerStartVoice(player)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2924

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:1708

Implements 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 true to close the storage

GM:PlayerSwitchFlashlight(player, bIsOn)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:750

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:4177

Implements 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 true to suppress the pain sound

GM:PlayerThink(player, curTime, infoTable)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:191

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, isJumping and wages

GM:PlayerTraceAttack(player, damageInfo, direction, trace)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3845

Called 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:2343

Implements 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

GM:PlayerUse(player, entity)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:881

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

GM:PlayerUseDoor(player, door)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:2462

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:1902

Implements 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 nil when used from the inventory

GM:PlayerUseUnknownItemFunction(player, itemTable, itemFunction)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3729

Implements 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:4605

Implements 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

GM:PostDrawBackgroundBlurs()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2751

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 true to skip drawing the bar's text

GM:PostDrawDateTimeBox(info)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1792

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, y and width

GM:PostDrawPlayerInfo(boxInfo, information, subInformation)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1788

Implements 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:2214

Called 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:3792

Implements 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

GM:PostProcessPermitted(class)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2174

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 true to 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:1782

Implements 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 true to skip drawing the box

GM:PrePlayerTakeDamage(player, attacker, inflictor, damageInfo)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:3827

Implements 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

GM:RenderScreenspaceEffects()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2260

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:4617

Called 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

GM:ScoreboardAdjustPlayerInfo(info)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:845

Implements hook ScoreboardAdjustPlayerInfo

Called to adjust a player's scoreboard entry; does nothing by default.

Parameters

  • info Map The entry, with player, text and 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.

GM:ScoreboardSortClassPlayers(class, a, b)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:830

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 a comes before b

GM:SetupMove(player, moveData)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:892

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

GM:SetupPlayerVisibility(player)

server gamemodes/catwork/gamemode/hooks/sv_hooks.lua:4524

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

GM:ShouldCharacterMenuBeCreated()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:1936

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

GM:ShouldDrawBackgroundBlurs()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2736

Implements hook ShouldDrawBackgroundBlurs

Called to check whether the background blurs are drawn; always draws them.

Returns

  • Boolean Whether the blurs are drawn

GM:ShouldDrawCharacterBackground()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2537

Implements hook ShouldDrawCharacterBackground

Called to check whether the black character menu background is drawn; always draws it.

Returns

  • Boolean Whether the background is drawn

GM:ShouldDrawCharacterBackgroundBlur()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2531

Implements hook ShouldDrawCharacterBackgroundBlur

Called to check whether the character menu background blur is drawn; always draws it.

Returns

  • Boolean Whether the blur is drawn

GM:ShouldDrawCharacterFault(fault)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2544

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

GM:ShouldDrawMenuBackgroundBlur()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2525

Called to check whether the menu background blur is drawn; always draws it.

Returns

  • Boolean Whether the blur is drawn

GM:ShouldDrawPlayerTargetID(player)

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2505

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

GM:ShouldPlayerScreenFadeBlack()

client gamemodes/catwork/gamemode/hooks/cl_hooks.lua:2513

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

GM:TranslateActivity(player, act)

shared gamemodes/catwork/gamemode/hooks/sh_hooks.lua:137

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 nil when a sequence override was set instead

Defined in