Schema schema
Schema hooks and methods
Schema hooks that register the HL2RP voice groups (Combine, Dispatch and Human) and their voice lines with the
voices library.
Schema:RegisterVoiceGroups and Schema:RegisterVoices are run by cw.voices when it builds its tables. Each line
has a chat command, a phrase and a Half-Life 2 sound, human lines also have a female sound, and the Dispatch phrases
are language phrases.
Summary
Hooks
Schema:SetCP.Schema.customPermits.Schema:SetLP.Schema:SetWorkPoints.w flag.Schema.LoyalistTiers.CitizenStatus net var.Schema.CitizenStates.CriminalPoints net var.Jailed net var.Job net var.LoyaltyPoints net var.Residence net var.scanner net var.WorkPoints net var.Schema:SaveNPCs.objectives schema data into Schema.combineObjectives.Schema:SaveRadios.Schema:SaveRationDispensers.Schema:SaveVendingMachines.Schema:IsTextEntryBeingUsed.Schema:OnTextEntryGetFocus.Player:IsCombine.Schema:PostSaveData instead.SetNPCName command) for the current map.PlayerSetCustomIcon Cable message.CitizenStatus net var.CriminalPoints net var.Jailed net var.Job net var.LoyaltyPoints net var.Residence net var.WorkPoints net var.CharSearch command.Schema:AddCP.Schema:AddLP.Hooks
Schema:AddCombineDisplayLine(text, color, player, exclude)
shared gamemodes/cwhl2rp/schema/sv_schema.lua:486On the server
Adds a line to the Combine display of one or all Combine players.
Sent with the CombineDisplayLine Cable message; the client side is
Schema:AddCombineDisplayLine in cl_schema.lua.
Parameters
- text String The text or language key to show
- color Color optional, defaults to
nilColour of the line; white whennil - player Player optional, defaults to
nilOnly send the line to this player - exclude Player optional, defaults to
nilA Combine player who does not receive the line
On the client
Adds a line to the local player's Combine display; does nothing for non-Combine players.
The text is translated and shown for eight seconds by Schema:HUDPaintTopScreen. Uncoloured lines are
suppressed while the player's biosignal is gone, and also refresh the biosignal locations of the
cwCTO plugin. Sent from the server with the CombineDisplayLine Cable message.
Parameters
- text String The text or language key to show
- color Color optional, defaults to
nilColour of the line; white whennil
Defined in
Adds to a player's criminal points with Schema:SetCP.
Parameters
- player Player The player
- amt Number The amount to add; may be negative
Registers a custom business permit in Schema.customPermits.
Citizens can buy the permit from the business menu while permits are enabled, gaining the flag. The
permit is stored under its lowercased name without spaces or punctuation, which is also the argument
the PermitBuy command expects.
Schema:AddCustomPermit('Literature', '3', 'models/props_lab/bindergreenlabel.mdl')
Parameters
- name String Display name of the permit
- flag String The flag the permit grants
- model String Model shown for the permit in the business menu
Starts a flash effect on the local player.
Adds a ten second white-out (see Schema:HUDPaintForeground), a twenty second colour shift and motion
blur (see Schema:RenderScreenspaceEffects) and plays a flatline sound. Triggered by the Flashed
Cable message.
Adds to a player's loyalty points with Schema:SetLP.
Parameters
- player Player The player
- amt Number The amount to add; may be negative
Starts a stun effect on the local player.
Adds a white-out lasting duration seconds and a flash blur lasting twice as long. Triggered by the
Stunned Cable message.
Parameters
- duration Number optional, defaults to
1Length of the white-out in seconds;0also means one second
Adds to a player's work points with Schema:SetWorkPoints.
Parameters
- player Player The player
- amt Number The amount to add; may be negative
Attaches a Combine lock to a door.
Parameters
- entity Entity The door
- position Vector optional, defaults to
nilPosition of the lock; a trace result places it at the default spot on the door, moved out along the hit normal - angles Angle optional, defaults to
nilAngles of the lock
Returns
- Entity The
cw_combinelock, ornilwhen it failed to spawn
Knocks down a door for five minutes.
Hides and unlocks the door, destroys its Combine lock, triggers its breach and throws a decaying physics copy of it, away from the player unless a force is given. The door returns after 300 seconds.
Parameters
- player Player The player busting the door down, or
nil - door Entity The door
- force Vector optional, defaults to
nilForce applied to the fake door instead of pushing it away from the player
Keeps a scanner player in sync with their scanner; does nothing for other players.
Copies the scanner's health to the player, keeps them in observer movement and plays a random scanner sound every 8 to 48 seconds.
Parameters
- player Player The player controlling the scanner
- curTime Number The current
CurTime()
Called when a player attempts to use a tool; Wire tools need the w flag.
Parameters
- player Player The player
- trace Map The player's eye trace
- tool String The tool mode
Returns
- Boolean
falseto block the tool
Returns whether a player may play a Civil Protection character.
Characters below rank 6 are marked as unavailable on the character screen when this is false;
the schema always allows it.
Parameters
- player Player The player
Returns
- Boolean Always
true
Called when the info of a chat box message should be adjusted.
Hides the speaker's name for anonymous messages and shows scanner units as Dispatch on the radio.
Parameters
- info Map The message info:
speaker,class,dataandname, which may be replaced
Implements hook ChatboxAdjustMessageInfo
Called when a chat message's info should be adjusted.
In-character messages starting with ? are sent anonymously, without the ?.
Parameters
- info Map The message:
filter,sender,textanddata, changed in place - listeners List<Player> The players who will receive it
Implements hook ClockworkInitPostEntity
Called when Catwork has loaded all of the entities.
Loads the saved ration dispensers, vending machines, Combine objectives, radios and named NPCs.
Schema:DefineLoyalistTier(name, description, color, min, max)
shared gamemodes/cwhl2rp/schema/sh_schema.lua:130Adds a loyalist tier to Schema.LoyalistTiers.
Tiers are matched against a character's loyalty points by Schema:DetermineLoyalistTier; define them
in ascending order of points.
Schema:DefineLoyalistTier('#Loyalist_Red', '#Loyalist_Red_Desc', Color(210, 100, 100), 150, -1)
Parameters
- name String Name or language key of the tier
- description String Description or language key of the tier
- color Color Colour the tier is shown in
- min Number Lowest number of loyalty points in the tier
- max Number Highest number of loyalty points in the tier, or
-1for no limit
Returns the loyalist tier for a number of loyalty points.
When several tiers match, the last defined one wins.
Parameters
- num Number The loyalty points
Returns
- Map The tier (
name,description,color,min,max); the first tier when none match, or a magentaERRORtier when none are defined
Schema:DoPlayerDeath(player, attacker, damageInfo)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1666Implements hook DoPlayerDeath
Called just before a player dies.
Returns worn clothes to the inventory, ends any search and unties the player without a respawn.
Parameters
- player Player The player
- attacker Entity The attacker
- damageInfo CTakeDamageInfo The damage
Downloads a file over HTTP into the data folder, unless it already exists there.
The download is asynchronous and the response body is written as is. Used for scoreboard icons, which
are then referenced as data/<path>.
Parameters
- url String The URL to download
- path String The destination, relative to the
DATAfolder
Implements hook DrawTargetPlayerStatus
Called when the status of a player under the crosshair should be drawn.
Draws whether the target is in critical condition, unconscious, tied or being tied or untied, with an untie prompt when the local player is close enough.
Parameters
- target Player The player being looked at
- alpha Number The alpha to draw with
- x Number The X position to draw at
- y Number The Y position to draw at
Returns
- Number The Y position after the drawn text, or
nilwhen the target is dead
Implements hook EntityBreached
Called when an entity has been breached.
Opens doors without a Combine lock, busting down rotating doors breached by a player. A Combine lock breached by a Combine player is blown off a rotating door with a smoke charge; otherwise it flashes.
Parameters
- entity Entity The breached entity
- activator Entity Who breached it, if anyone
Schema:EntityHandleMenuOption(player, entity, option, arguments)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:58Implements hook EntityHandleMenuOption
Called when a player chooses an option from an entity's menu.
Opens corpse loot and belongings storage, charges breaches and handles the stationary radio options:
setting a frequency in the 1X1.X format, toggling it and picking it up as an item. Empty
belongings are removed when closed.
Parameters
- player Player The player who chose the option
- entity Entity The entity
- option String The option's name
- arguments Any The option's menu string, such as
'cw_radioToggle', or the typed frequency
Called when an entity is removed.
When a ragdoll holding belongings (see Schema:PermaKillPlayer) is removed, they are left behind as a
cw_belongings entity.
Parameters
- entity Entity The entity
Implements hook EntityTakeDamage
Called when an entity takes damage.
Progresses the victim's Endurance, plays scanner pain sounds and warns the Combine when a unit is attacked. Scales damage by the attacker's weapon, melee Strength and explosions (NPC damage is halved), and lets shots at the handle, shotguns and explosions open or bust down rotating doors.
Parameters
- entity Entity The damaged entity
- damageInfo CTakeDamageInfo The damage, scaled in place
Implements hook GetCinematicIntroInfo
Called when the cinematic intro info is needed.
Returns
- Map The intro's
credits,titleandtext, taken from theintro_text_bigandintro_text_smallconfig values
Returns a player's citizen status, from their CitizenStatus net var.
Parameters
- player Player The player
Returns
- String A key of
Schema.CitizenStates,'Unknown'by default
Returns the colour of a player's citizen status from Schema.CitizenStates.
Parameters
- player Player The player
Returns
- Color The status colour, or white for an unknown status
Returns a player's criminal points, from their CriminalPoints net var.
Parameters
- player Player The player
Returns
- Number The criminal points,
0by default
Returns how long a dexterity action such as tying takes a player, based on their Agility attribute.
Parameters
- player Player The player
Returns
- Number The time in seconds, from 7 down to 2 with full Agility
Implements hook GetEntityMenuOptions
Called when an entity's menu options are needed.
Adds the Loot option to corpses, Open to belongings, Charge to breaches and turn on/off, set frequency and take options to stationary radios.
Parameters
- entity Entity The entity the menu is for
- options Map Option names mapped to a menu option string or a callback, filled in place
Returns how much health a player heals, based on their Medical attribute.
Parameters
- player Player The player doing the healing
- scale Number optional, defaults to
1Multiplier for the amount
Returns
- Number 15 plus up to 35 for the Medical attribute, times
scale
Returns whether a player is jailed, from their Jailed net var.
Parameters
- player Player The player
Returns
- Boolean Whether the player is jailed,
falseby default
Returns a player's job, from their Job net var.
Parameters
- player Player The player
Returns
- String The job,
'None'by default
Returns a player's loyalty points, from their LoyaltyPoints net var.
Parameters
- player Player The player
Returns
- Number The loyalty points,
0by default
Implements hook GetPlayerCharacterScreenFaction
Called when the faction shown for a character on the character screen is needed.
Parameters
- character Character The character's data
Returns
- String The character's custom class, or
nilwhen it has none
Returns a number for a player's Combine rank, used to sort and compare ranks.
Overwatch ranks are 0 (OWS) to 3 (other). Civil Protection ranks are 0 (RCT), 1-4 (04-01),
5 (no rank found), 6 (GHOST), 7 (OfC), 8 (EpU), 9 (DvL), 10 (CmD), 11 (SCN) and 12
(SYNTH scanner).
Parameters
- player Player The player
Returns
- Number The rank number; higher is more senior
Schema:GetPlayerDefaultInventory(player, character, inventory)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:258Implements hook GetPlayerDefaultInventory
Called when a new character's default inventory is needed.
Gives administrators a radio, Civil Protection a radio and stunstick, Overwatch a radio, pistol, MP7 and ammunition, and everyone else a suitcase.
Parameters
- player Player The player
- character Character The new character
- inventory Inventory The inventory, filled in place
Implements hook GetPlayerDefaultModel
Called when a player's default model is needed; overridden to do nothing so the faction model is used.
Parameters
- player Player The player
Implements hook GetPlayerInfoText
Called when the player info text is needed; adds the citizen ID line for citizens.
Parameters
- playerInfoText Map The info text object, with an
Add(id, text)method
Implements hook GetPlayerScoreboardClass
Called when a player's scoreboard class is needed.
Uses the player's custom class when set, and groups Civil Protection and Overwatch under their faction.
Parameters
- player Player The player on the scoreboard
Returns
- String The scoreboard class name, or
nilfor the default
Schema:GetPlayerScoreboardOptions(player, options, menu)
client gamemodes/cwhl2rp/schema/cl_hooks.lua:365Implements hook GetPlayerScoreboardOptions
Called when a player's scoreboard options are needed.
Adds server whitelist, custom class and permakill options, each only when the command exists and the local player has its access flags. The options run the matching commands.
Parameters
- player Player The player the options are for
- options Map Option names mapped to callbacks or sub-option maps, filled in place
- menu Panel The scoreboard menu
Implements hook GetPlayerTypingDisplayPosition
Called when the position of a player's typing display is needed.
Places the display above the body bone of the player's scanner when they control one.
Parameters
- player Player The player who is typing
Returns
- Vector The display position, or
nilfor the default
Returns a player's residence, from their Residence net var.
Parameters
- player Player The player
Returns
- String The residence,
'Unknown'by default
Returns the scanner a player controls, from their scanner net var.
Parameters
- player Player The player
Returns
- Entity The scanner, or
nilwhen the player controls no valid scanner
Implements hook GetScreenTextInfo
Called when the full screen text info is needed.
Shows a message while the local player's character is permakilled, being tied or tied.
Returns
- Map The text's
alpha,titleand optionaltext, ornilfor none
Implements hook GetTargetPlayerFadeDistance
Called when the fade distance of a player's target ID is needed.
Returns 512 while the local player controls a scanner, so targets stay visible from further away.
Parameters
- player Player The player being looked at
Returns
- Number The fade distance, or
nilfor the default
Returns a player's work points, from their WorkPoints net var.
Parameters
- player Player The player
Returns
- Number The work points,
0by default
Implements hook HUDPaintEntityTargetID
Called when an entity's target ID should be painted.
Draws the physical description of props and the name and title of named NPCs.
Parameters
- entity Entity The entity being looked at
- info Map Drawing state with
x,yandalpha;yis advanced past each drawn line
Implements hook HUDPaintForeground
Called when the foreground HUD should be painted; draws the white flash of active stun effects.
Implements hook HUDPaintTopScreen
Called when the top of the screen HUD should be painted.
Draws the Combine display lines for Combine players, typing each line out a character per frame and removing it when it expires.
Parameters
- info Map Drawing state with
xandy;yis advanced past each line
Called when the gamemode initializes on the client.
Creates the catwork data folder and downloads the developer scoreboard icons into it with
Schema:DownloadMaterial.
Returns whether a faction is Civil Protection or Overwatch.
Parameters
- faction String The faction name
Returns
- Boolean Whether the faction is
FACTION_MPForFACTION_OTA
Schema:IsPlayerCombineRank(player, rank, realRank)
shared gamemodes/cwhl2rp/schema/sh_schema.lua:256Returns whether a Civil Protection or Overwatch player's name contains a Combine rank.
Works like Schema:IsStringCombineRank on the player's name, and is always nil for players outside
the Combine factions.
Parameters
- player Player The player to check
- rank String The rank, or a
Listof ranks of which any may match - realRank Boolean optional, defaults to
nilWhentrue,EpUmatches only the literalEpUrank
Returns
- Any A truthy value (
trueor the match position) when the player has the rank, otherwisenil
Returns whether a name contains a Combine rank.
Ranks appear in Combine names between punctuation, as in C24.MPF-RCT.1234. The rank EpU also
matches the SeC, DvL and CmD ranks.
Parameters
- text String The name to search
- rank String The rank, or a
Listof ranks of which any may match
Returns
- Any A truthy value (
trueor the match position) when the rank is found, otherwisenil
See also
Returns whether a text entry has focus and is visible.
The entry is tracked by Schema:OnTextEntryGetFocus and Schema:OnTextEntryLoseFocus.
Returns
- Boolean
truewhen one is in use, otherwisenil
Called when a player presses a key.
Use starts untying the tied player being looked at. Scanner players play a scanner sound with the
attack keys, take a photo with reload (every two seconds at most) that stuns facing non-Combine players
nearby, and follow the player they look at with walk (see the CharFollow command).
Parameters
- player Player The player
- key Number The
IN_*key
Spawns the named NPCs saved for the current map by Schema:SaveNPCs.
Loads the Combine objectives from the objectives schema data into Schema.combineObjectives.
Spawns the stationary radios saved for the current map by Schema:SaveRadios.
Restores each radio's owner, frequency and on/off state, and freezes radios that were frozen.
Spawns the ration dispensers saved for the current map by Schema:SaveRationDispensers.
Spawns the vending machines saved for the current map by Schema:SaveVendingMachines.
Schema:MakePlayerScanner(player, noMessage, lightSpawn)
server gamemodes/cwhl2rp/schema/sv_schema.lua:414Turns a player into a scanner they control.
Replaces any existing scanner (see Schema:ResetPlayerScanner), spawns an npc_cscanner (or an
npc_clawscanner for the SYNTH rank) that follows a marker, and makes the player spectate it with
their weapons and armour stripped. The scanner's entity index is stored in the scanner net var.
Parameters
- player Player The player
- noMessage Boolean optional, defaults to
nilPassed toSchema:ResetPlayerScannerfor the old scanner - lightSpawn Boolean optional, defaults to
nilWhether this is a light spawn; skips turning off the flashlight, unducking and the shield scanner's 200 health
Implements hook OnePlayerSecond
Called every second for each player.
Networks the custom class, citizen ID, clothes and icon character data, and progresses Strength while the player moves carrying at least a quarter of their maximum weight.
Parameters
- player Player The player
- curTime Number The current
CurTime()
Called when an NPC is killed.
When the NPC is a player's scanner, the player dies with it and the scanner is reset.
Parameters
- npc NPC The NPC
- attacker Entity The attacker
- inflictor Entity The inflictor
Called when a text entry gains focus; remembers it for Schema:IsTextEntryBeingUsed.
Parameters
- panel Panel The focused text entry
Called when a text entry loses focus; clears the entry remembered by Schema:OnTextEntryGetFocus.
Parameters
- panel Panel The text entry that lost focus
Permanently kills a player's character.
Kills the player if alive and, unless the character is already permakilled, marks it permakilled
and moves its inventory and cash onto the ragdoll as belongings, or into a cw_belongings entity when
there is no ragdoll. Items with allowStorage = false are lost. Runs the
PlayerAdjustPermaKillInfo hook with the inventory, cash and entity info, and saves the
character.
Parameters
- player Player The player
- ragdoll Entity optional, defaults to
nilThe player's ragdoll, if they are already dead
Schema:PlayerAdjustCharacterScreenInfo(player, character, info)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:860Implements hook PlayerAdjustCharacterScreenInfo
Called when a character's entry on the character screen should be adjusted.
Marks permakilled characters, shows Overwatch availability, shows the elite Overwatch and scanner models and passes on the character's custom class.
Parameters
- player Player The player whose characters are listed
- character Character The character
- info Map The entry:
name,faction, anddetails,modelandcustomClass, which may be set
Implements hook PlayerAdjustClassModelInfo
Called when the model shown for a class in the class menu should be adjusted.
Shows the scanner class with the scanner or shield scanner model.
Parameters
- class Number The class index, compared against
CLASS_MPS - info Map The model info;
modelmay be replaced
Implements hook PlayerAdjustColorModify
Called when the local player's colour modification should be adjusted.
While antidepressants are active the colours fade towards normal, and back to the default afterwards.
Parameters
- colorModify Map
$pp_colour_*values, adjusted in place
Implements hook PlayerAdjustDeathInfo
Called when a player's death info should be adjusted; permakilled characters get no respawn time.
Parameters
- player Player The player
- info Map The death info;
spawnTimemay be replaced
Implements hook PlayerAdjustDropWeaponInfo
Called when the info of a weapon a player drops should be adjusted.
Drops the active weapon from the player's eyes and holstered weapons from where their gear model is.
Parameters
- player Player The player
- info Map The drop info:
itemTable, andpositionandangles, which are set in place
Implements hook PlayerAdjustMotionBlurs
Called when the local player's motion blurs should be adjusted.
Adds the flash blur while a stun-style flash effect (see Schema:AddStunEffect) is active.
Parameters
- motionBlurs Map Motion blur state; its
blurTablemaps blur names to amounts
Implements hook PlayerAdjustRadioInfo
Called when a player's radio message info should be adjusted.
Combine players reach every Combine player; a player with a frequency also reaches untied players with a handheld radio on the same frequency.
Parameters
- player Player The player sending the message
- info Map The radio info; players are added to its
listeners
Schema:PlayerAttributeUpdated(player, attributeTable, amount)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1159Implements hook PlayerAttributeUpdated
Called when a player's attribute is updated; shows an attribute line on a Combine player's display.
Parameters
- player Player The player
- attributeTable Attribute The attribute
- amount Number The change in the attribute
Implements hook PlayerBusinessRebuilt
Called when the local player's business menu is rebuilt.
Remembers the panel in Schema.businessPanel and, when permits are enabled and the local player is a
citizen, adds a permits form listing the total cost of each permit they lack (general goods and
Schema.customPermits). Players without the x flag see a single entry for creating a business.
Parameters
- panel Panel The business menu panel
- categories List<Map> The orderable item categories, each with
categoryanditemsList
Schema:PlayerCanBeGivenWeapon(player, class, uniqueID, forceReturn)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:813Implements hook PlayerCanBeGivenWeapon
Called when a player attempts to be given a weapon; scanner players cannot.
Parameters
- player Player The player
- class String The weapon class
- uniqueID String The item's unique ID
- forceReturn Boolean Whether the weapon is being returned forcibly
Returns
- Boolean
falseto block the weapon
Implements hook PlayerCanBreachEntity
Called when a player attempts to breach an entity; any real door except rotating ones may be breached.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean Whether the entity can be breached, or
nilfor the default
Implements hook PlayerCanChangeClass
Called when a player attempts to change class.
Tied players cannot, and Combine players can only join the classes their rank allows; the player is told why.
Parameters
- player Player The player
- class Number The class index
Returns
- Boolean
falseto block the change
Schema:PlayerCanDeleteCharacter(player, character)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1184Implements hook PlayerCanDeleteCharacter
Called when a player attempts to delete a character; permakilled characters can always be deleted.
Parameters
- player Player The player
- character Character The character
Returns
- Boolean
trueto allow the deletion, ornilfor the default
Schema:PlayerCanDestroyItem(player, itemTable, noMessage)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1421Implements hook PlayerCanDestroyItem
Called when a player attempts to destroy an item; scanners and tied players cannot.
Parameters
- player Player The player
- itemTable Item The item
- noMessage Boolean Whether to skip telling the player why
Returns
- Boolean
falseto block it
Schema:PlayerCanDropItem(player, itemTable, noMessage)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1442Implements hook PlayerCanDropItem
Called when a player attempts to drop an item; scanners and tied players cannot.
Parameters
- player Player The player
- itemTable Item The item
- noMessage Boolean Whether to skip telling the player why
Returns
- Boolean
falseto block it
Schema:PlayerCanEarnGeneratorCash(player, info, cash)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1530Called when a player attempts to earn cash from a generator; Combine players cannot.
Parameters
- player Player The player
- info Map The generator info
- cash Number The amount
Returns
- Boolean
falseto block it
Called when a player attempts to lock an entity.
Doors with a Combine lock cannot be locked with keys while the lock is locked or the
combine_lock_overrides config is enabled.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean
falseto block it
Schema:PlayerCanRadio(player, text, listeners, eavesdroppers)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:543Implements hook PlayerCanRadio
Called when a player attempts to use the radio.
Combine players and scanners can always use it; everyone else needs a handheld radio and a frequency.
Parameters
- player Player The player
- text String The message
- listeners Map The players who will hear the message
- eavesdroppers Map The players who will overhear it
Returns
- Boolean
falseto block the message
Schema:PlayerCanRagdoll(player, state, delay, decay, ragdoll)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1091Implements hook PlayerCanRagdoll
Called when a player attempts to be ragdolled; scanners cannot.
Parameters
- player Player The player
- state Number The
RAGDOLL_*state - delay Number How long the ragdoll lasts
- decay Number How long the ragdoll takes to decay
- ragdoll Entity The existing ragdoll, if any
Returns
- Boolean
falseto block it
Schema:PlayerCanRestoreRecognisedName(player, target)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:519Implements hook PlayerCanRestoreRecognisedName
Called when a player attempts to restore a recognised name; Combine names are never restored.
Parameters
- player Player The player
- target Player The recognised player
Returns
- Boolean
falseto forget the name
Implements hook PlayerCanSaveRecognisedName
Called when a player attempts to save a recognised name; Combine names are never saved.
Parameters
- player Player The player
- target Player The recognised player
Returns
- Boolean
falseto not save the name
Implements hook PlayerCanSeeClass
Called when the local player attempts to see a class in the class menu.
Hides the Combine classes whose rank the local player does not hold.
Parameters
- class Class The class
Returns
- Boolean
falseto hide the class
Implements hook PlayerCanSwitchCharacter
Called when a player attempts to switch characters.
Permakilled characters can always be switched from; tied characters cannot.
Parameters
- player Player The player
- character Character The character to switch to
Returns
- Boolean Whether the switch is allowed
- String The reason when it is not
Implements hook PlayerCanUnlockEntity
Called when a player attempts to unlock an entity.
Doors with a Combine lock cannot be unlocked with keys while the lock is locked or the
combine_lock_overrides config is enabled.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean
falseto block it
Implements hook PlayerCanUseCharacter
Called when a player attempts to use a character.
Refuses permakilled characters, Civil Protection characters while Schema:CanUseCP is false (below
rank 6) and scanner characters while three scanners are online.
Parameters
- player Player The player
- character Character The character
Returns
- String The reason the character cannot be used, or
nilto allow it
Schema:PlayerCanUseCommand(player, commandTable, arguments)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1238Implements hook PlayerCanUseCommand
Called when a player attempts to use a command.
Tied players cannot order shipments, broadcast, dispatch, request or use the radio.
Parameters
- player Player The player
- commandTable Command The command
- arguments List<String> The command's arguments
Returns
- Boolean
falseto block the command
Implements hook PlayerCanUseDoor
Called when a player attempts to open a door with the use key.
Only untied Combine players, administrators and holders of a combine_lock_access_x card may.
Parameters
- player Player The player
- door Entity The door
Returns
- Boolean
falseto block it
Schema:PlayerCanUseEntityInVehicle(player, entity, vehicle)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:630Implements hook PlayerCanUseEntityInVehicle
Called when a player attempts to use an entity from a vehicle; allows players and their ragdolls.
Parameters
- player Player The player
- entity Entity The entity
- vehicle Vehicle The vehicle
Returns
- Boolean
trueto allow it
Schema:PlayerCanUseItem(player, itemTable, noMessage)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1466Implements hook PlayerCanUseItem
Called when a player attempts to use an item.
Scanners and tied players cannot use items. Players can equip one secondary weapon (weight 1 to 2), one primary weapon (heavier) and one melee or light weapon (lighter than 1) at a time.
Parameters
- player Player The player
- itemTable Item The item
- noMessage Boolean Whether to skip telling the player why
Returns
- Boolean
falseto block it
Implements hook PlayerCanZoom
Called when the local player attempts to zoom; only Combine players may zoom.
Returns
- Boolean
falseto block the zoom
Implements hook PlayerCharacterInitialized
Called when a player's character has initialized.
Puts Combine players in the class matching their rank when it has room, and adds a database line to the Combine display for citizens.
Parameters
- player Player The player
Implements hook PlayerCharacterLoaded
Called when a player's character has loaded.
Resets the permakill and tied state and networks the loyalty, criminal and work points, citizen status, residence, jail state and job from the character data.
Parameters
- player Player The player
Implements hook PlayerCharacterUnloaded
Called when a player's character has unloaded; removes their scanner.
Parameters
- player Player The player
Schema:PlayerDeath(player, inflictor, attacker, damageInfo)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1690Implements hook PlayerDeath
Called when a player dies.
Combine deaths trigger the cwCTO biosignal loss and a radio announcement, and destroy the unit's
scanner. Deaths at the hands of a player or NPC permakill the character when enable_permakill is
on and the player lacks the d flag. Other deaths lose each item with a one in four chance and 40 to
60 percent of the cash.
Parameters
- player Player The player
- inflictor Entity The inflictor
- attacker Entity The attacker
- damageInfo CTakeDamageInfo The damage, or
truewhen the player's scanner was destroyed
Called each frame a player is dead; permakilled characters cannot respawn.
Parameters
- player Player The player
Returns
- Boolean
trueto stop the player respawning
Schema:PlayerDestroyGenerator(player, entity, generator)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1638Called when a player destroys a generator.
Pays a quarter of the generator's cash to the player, or to every Combine player when a Combine player destroyed it.
Parameters
- player Player The player
- entity Entity The generator entity
- generator Map The generator info, with
cashandname
Implements hook PlayerDoesHaveFlag
Called to check whether a player has a flag.
When permits are disabled, denies the business flag x, the general goods flag 1 and every custom
permit flag.
Parameters
- player Player The player to check
- flag String The flag
Returns
- Boolean
falseto deny the flag, ornilto leave it to the flag system
Defined in
Schema:PlayerDoesRecognisePlayer(player, target, status, isAccurate, realValue)
shared gamemodes/cwhl2rp/schema/sv_hooks.lua:1174Implements hook PlayerDoesRecognisePlayer
On the server
Called to check whether a player recognises another player.
Combine players and administrators are always recognised.
Parameters
- player Player The player who may recognise the target
- target Player The player to be recognised
- status Number The
RECOGNISE_*level being checked - isAccurate Boolean Whether the level must match exactly
- realValue Boolean The result of the recognition system
Returns
- Boolean
trueto recognise the target, ornilto keeprealValue
On the client
Called to check whether the local player recognises another player.
Combine players and administrators are always recognised.
Parameters
- player Player The player to be recognised
- status Number The
RECOGNISE_*level being checked - isAccurate Boolean Whether the level must match exactly
- realValue Boolean The result of the recognition system
Returns
- Boolean
trueto recognise the player, ornilto keeprealValue
Defined in
Schema:PlayerFinishTypingDisplay(player, textTyped)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:311Implements hook PlayerFinishTypingDisplay
Called when a player stops typing; plays the radio-off sound for Combine players who sent a message.
Parameters
- player Player The player
- textTyped Boolean Whether the player sent a message
Schema:PlayerFootstep(player, position, foot, sound, volume, recipientFilter)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:2143Called when a player's footstep sound should be played.
Running Civil Protection and Overwatch players play gear sounds; everyone else plays the normal sound.
Parameters
- player Player The player
- position Vector The footstep position
- foot Number
0for the left foot,1for the right - sound String The default sound
- volume Number The default volume
- recipientFilter CRecipientFilter Who would hear the sound
Returns
- Boolean Always
true, replacing the engine's sound
Returns the name of the area a player is in, using the Area Names plugin.
When the player is in no area, the area whose minimum corner is closest is used. A leading "the " is removed from the name.
Parameters
- player Player The player
Returns
- String The area name, or
'#Location_Unknown'without the plugin or any areas
Implements hook PlayerGiveWeapons
Called when a player's spawn weapons should be given.
Gives GHOST units a sniper rifle, vortigaunts their vortigaunt weapon and enslaved vortigaunts a broom.
Parameters
- player Player The player
Schema:PlayerHasUnknownInventoryItem(player, inventory, item, amount)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:245Called when a player's inventory contains an item that no longer exists.
Replaces the old radio item with handheld_radio.
Parameters
- player Player The player
- inventory Inventory The inventory being restored
- item String The unique ID of the unknown item
- amount Number How many of the item there are
Implements hook PlayerHealed
Called when a player has been healed.
Boosts the healer's Agility and progresses their Medical attribute, more for a health kit than a health vial and least for a bandage.
Parameters
- player Player The player who was healed
- healer Player The player who healed them
- itemTable Item The item used
Schema:PlayerHealthSet(player, newHealth, oldHealth)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:799Implements hook PlayerHealthSet
Called when a player's health is set; copies it to their scanner.
Parameters
- player Player The player
- newHealth Number The new health
- oldHealth Number The old health
Called when a player first spawns; exchanges custom scoreboard icons with them two seconds later.
Parameters
- player Player The player
- bOneWay Boolean Unused
Schema:PlayerInventoryItemUpdated(player, itemTable, amount, force)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:376Called when an item in a player's inventory is updated.
Takes off the player's clothes when they no longer have the clothes item.
Parameters
- player Player The player
- itemTable Item The item
- amount Number The change in amount
- force Boolean Whether the update was forced
On the server
Returns whether a player is Combine, using Player:IsCombine.
Parameters
- player Player The player to check
Returns
- Boolean Whether the player is Combine, or
nilfor an invalid player
On the client
Returns whether a player is Combine, using Player:IsCombine.
Parameters
- player Player The player to check
- bHuman Boolean optional, defaults to
nilUnused
Returns
- Boolean Whether the player is Combine, or
nilfor an invalid player
Defined in
Returns whether a player's character belongs to the Civil Workers' Union.
Parameters
- player Player The player to check
Returns
- Boolean Whether the player is in
FACTION_CWU, ornilwithout a valid player and character
Returns whether the tier of a player's loyalty points has a name containing the given text.
The comparison is case-insensitive and uses the LoyaltyPoints character data. Tier names are
language keys such as #Loyalist_Grey, so 'grey' matches the first tier.
Parameters
- player Player The player to check
- tier String Text to look for in the tier name, used as a Lua pattern
Returns
- Number The position of the match, or
nilwhen the name does not contain it
Schema:PlayerLimbDamageHealed(player, hitGroup, amount)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1899Implements hook PlayerLimbDamageHealed
Called when a player's limb damage is healed; removes the limb's attribute penalties.
Parameters
- player Player The player
- hitGroup Number The
HITGROUP_*limb - amount Number The amount healed
Implements hook PlayerLimbDamageReset
Called when a player's limb damage is reset; removes every limb damage attribute penalty.
Parameters
- player Player The player
Schema:PlayerLimbTakeDamage(player, hitGroup, damage)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1925Implements hook PlayerLimbTakeDamage
Called when a player's limb takes damage.
Lowers the attributes the limb affects by its damage: Medical for the head, Endurance for the body, Agility for the legs and Agility and Strength for the arms.
Parameters
- player Player The player
- hitGroup Number The
HITGROUP_*limb - damage Number The damage taken
Schema:PlayerNameChanged(player, previousName, newName)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:595Implements hook PlayerNameChanged
Called when a player's name changes.
Moves Combine players to the class of a newly gained rank. Civil Protection units who become scanners
are turned into one with Schema:MakePlayerScanner.
Parameters
- player Player The player
- previousName String The old name
- newName String The new name
Called when a player attempts to noclip; scanners cannot.
Parameters
- player Player The player
Returns
- Boolean
falseto block it
Implements hook PlayerPlayDeathSound
Called when a player's death sound should be played.
For Combine players whose biosignal is still active, every such Combine player hears the lost biosignal announcement with the digits among the last three characters of the dead unit's name.
Parameters
- player Player The player
- gender String The player's gender
Returns
- String A Civil Protection death sound, or
nilfor the default
Schema:PlayerPlayPainSound(player, gender, damageInfo, hitGroup)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1609Implements hook PlayerPlayPainSound
Called when a player's pain sound should be played; Combine players use Civil Protection sounds.
Parameters
- player Player The player
- gender String The player's gender
- damageInfo CTakeDamageInfo The damage
- hitGroup Number The
HITGROUP_*hit
Returns
- String The sound, or
nilfor the default
Implements hook PlayerPunchEntity
Called when a player punches an entity; progresses Strength, twice as much for players and NPCs.
Parameters
- player Player The player
- entity Entity The entity
Implements hook PlayerPunchThrown
Called when a player throws a punch; progresses their Strength.
Parameters
- player Player The player
Schema:PlayerRadioUsed(player, text, listeners, eavesdroppers)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:899Implements hook PlayerRadioUsed
Called after a player has used the radio.
Sends the message to players near switched-on stationary radios tuned to the player's frequency, within twice the talk radius, unless they heard or overheard it already.
Parameters
- player Player The player
- text String The message
- listeners List<Player> The players who heard the message
- eavesdroppers List<Player> The players who overheard it
Implements hook PlayerRestoreCharacterData
Called when a player's character data is restored.
Gives non-Combine characters a random five-digit citizen ID when they have none, or an old four-digit one.
Parameters
- player Player The player
- data Map The character data, changed in place
Implements hook PlayerRestoreData
Called when a player's data is restored.
Kicks players missing from the whitelist named by the server_whitelist_identity config, when set.
Parameters
- player Player The player
- data Map The player data;
serverwhitelistis created when missing
Implements hook PlayerSaveData
Called when a player's data should be saved; drops an empty server whitelist.
Parameters
- player Player The player
- data Map The player data, changed in place
Schema:PlayerScaleDamageByHitGroup(player, attacker, hitGroup, damageInfo, baseDamage)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1949Implements hook PlayerScaleDamageByHitGroup
Called when a player's damage should be scaled by hit group.
Scales damage by 1.5 minus up to 0.75 for Endurance, and reduces bullet damage by the protection of
the clothes the player wears.
Parameters
- player Player The player
- attacker Entity The attacker
- hitGroup Number The
HITGROUP_*hit - damageInfo CTakeDamageInfo The damage, scaled in place
- baseDamage Number The damage before scaling
Implements hook PlayerSetDefaultColorModify
Called when the local player's default colour modification should be set.
Darkens and desaturates the screen for the schema's look.
Parameters
- colorModify Map
$pp_colour_*values, set in place
Called when a player attempts to spawn an object; tied players and scanners cannot.
Parameters
- player Player The player
Returns
- Boolean
falseto block the spawn
Called when a player attempts to spawn a prop.
While the cwu_props config is enabled, citizens outside the Civil Worker's Union cannot spawn beds or
the furniture in Schema.cwuProps. Admins are exempt.
Parameters
- player Player The player
- model String The prop's model
Returns
- Boolean
falseto block the spawn
Called when a player attempts to spray; only untied players with a spray can may spray.
Parameters
- player Player The player
Returns
- Boolean
trueto block the spray
Implements hook PlayerStartTypingDisplay
Called when a player starts typing; plays the radio-on sound for Combine players typing a message.
Parameters
- player Player The player
- code String The typing display code, such as
'n'for normal speech or'r'for the radio
Implements hook PlayerStorageShouldClose
Called to check whether a player's storage should close.
Closes a search of another player once the searched player is no longer tied.
Parameters
- player Player The player
- storage Map The open storage
Returns
- Boolean
trueto close the storage
Implements hook PlayerStunEntity
Called when a player hits an entity with a stunstick.
Progresses the player's Strength and punches the view of a hit player. Four hits less than two seconds
apart knock the target out for the knockout_time config value.
Parameters
- player Player The player with the stunstick
- entity Entity The entity that was hit
Called when a player switches their flashlight; scanner players and tied players cannot turn it on.
Parameters
- player Player The player
- on Boolean Whether the flashlight is being turned on
Returns
- Boolean
falseto block the switch
Schema:PlayerTakeDamage(player, inflictor, attacker, hitGroup, damageInfo)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1887Implements hook PlayerTakeDamage
Called when a player takes damage; stuns their view, longer when they have armour.
Parameters
- player Player The player
- inflictor Entity The inflictor
- attacker Entity The attacker
- hitGroup Number The
HITGROUP_*hit - damageInfo CTakeDamageInfo The damage
Implements hook PlayerThink
Called at an interval while a player is connected.
Progresses Agility while jumping or running, runs Schema:CalculateScannerThink for scanners, and
raises carry weight, jump power and run speed from the Strength and Agility attributes. Combine
players carry 8 more.
Parameters
- player Player The player
- curTime Number The current
CurTime() - infoTable Map The player's movement info, adjusted in place
Implements hook PlayerUse
Called when a player attempts to use an entity.
Restricts entities whose overlay text contains CA, OTA, MPF or CWU to those factions (and
those above them), and blocks scanners, busted-down doors and tied players (who may still use seats).
Sprint and use toggles a door's Combine lock for players with access, every three seconds at most.
Parameters
- player Player The player
- entity Entity The entity
Returns
- Boolean
falseto block the use
Implements hook PlayerUseDoor
Called when a player uses a door.
On rp_c18_v1, closes certain doors automatically ten seconds after they are used.
Parameters
- player Player The player
- door Entity The door
Schema:PlayerWearClothes(player, itemTable, noMessage)
server gamemodes/cwhl2rp/schema/sv_schema.lua:899Puts clothes on a player, or takes off the clothes they wear.
Clothes are only put on when the player's class has no model of its own. The worn item is stored in
the clothes character data and net var, and the item's OnChangeClothes is called.
Parameters
- player Player The player
- itemTable Item optional, defaults to
nilThe clothes to wear;niltakes off the current clothes - noMessage Boolean optional, defaults to
nilUnused
Schema:PostPlayerLightSpawn(player, weapons, ammo, special)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1826Implements hook PostPlayerLightSpawn
Called after a player light-spawns; reapplies the clothes they wear.
Parameters
- player Player The player
- weapons Boolean Whether weapons were restored
- ammo Boolean Whether ammunition was restored
- special Boolean Whether this was a special light spawn
Schema:PostPlayerSpawn(player, lightSpawn, changeClass, firstSpawn)
server gamemodes/cwhl2rp/schema/sv_hooks.lua:1773Implements hook PostPlayerSpawn
Called just after a player spawns.
On a full spawn, clears effects and searches and gives Combine and administrators their armour (and Overwatch 150 health). Turns scanner ranks into scanners, re-ties tied players and puts worn clothes back on.
Parameters
- player Player The player
- lightSpawn Boolean Whether this is a light spawn
- changeClass Boolean Whether the player changed class
- firstSpawn Boolean Whether this is the character's first spawn
Implements hook PostSaveData
Called just after data has been saved.
Saves the ration dispensers, vending machines, radios and named NPCs of the current map.
Implements hook RegisterVoiceGroups
Called when voice groups should be registered.
Adds the Combine and Dispatch groups for Combine players and the gendered Human group for
everyone else.
Parameters
- voices Map The
cw.voiceslibrary
Implements hook RegisterVoices
Called when voices should be registered.
Adds the schema's Dispatch announcements, Combine lines and human lines, each with its chat command, phrase and Half-Life 2 sound; human lines also have a female sound.
Parameters
- voices Map The
cw.voiceslibrary
Called when screen space effects should be rendered.
Draws the colour shift and motion blur of an active flash effect and the Combine visor overlay for Combine players, unless the screen is faded to black.
Removes a player's scanner and its follow marker; does nothing when they have none.
Unless noMessage is set, the player is also returned to walking, stops spectating and is killed
silently.
Parameters
- player Player The player controlling the scanner
- noMessage Boolean optional, defaults to
nilOnly remove the entities, leaving the player as they are
Implements hook SaveData
Called when data should be saved; the schema saves its entities in Schema:PostSaveData instead.
Saves every NPC with a name and title (set with the SetNPCName command) for the current map.
Saves the position, owner, frequency and state of every stationary radio for the current map.
Saves the position, angles and lock state of every ration dispenser for the current map.
Saves the position, angles and stock of every vending machine for the current map.
Sends a broadcast message from a player to everyone.
Parameters
- player Player The player broadcasting
- text String The message
Sends a message to everyone under the name of Dispatch.
Parameters
- player Player The player sending the message
- text String The message
Sends a message through a player's request device.
The request is shown on the Combine display and sent to Combine players, administrators, CWU and anyone carrying a request device. When a citizen sends it, nearby citizens overhear it.
Parameters
- player Player The player sending the request
- text String The message
Implements hook ScoreboardAdjustPlayerInfo
Called when a player's scoreboard info should be adjusted.
Shows scanner units with the scanner or shield scanner model.
Parameters
- info Map The scoreboard entry;
playeris the player andmodelmay be replaced
Implements hook ScoreboardSortClassPlayers
Called when the players of a scoreboard class should be sorted.
Sorts Civil Protection and Overwatch players by Combine rank, then by name.
Parameters
- class String The scoreboard class name
- a Player The first player to compare
- b Player The second player to compare
Returns
- Boolean Whether
acomes beforeb, ornilfor other classes
Sends custom scoreboard icons over the PlayerSetCustomIcon Cable message.
The player's own CustomIcon data is sent to everyone; unless bOneWay is set, every other player's
icon is then sent to this player, as needed when they have just connected.
Parameters
- player Player The player whose icon is sent
- bOneWay Boolean optional, defaults to
nilOnly broadcast this player's icon, and make clients re-download it
Sets a player's citizen status in their character data and CitizenStatus net var.
Parameters
- player Player The player
- status String A key of
Schema.CitizenStates; any other value is stored as'Unknown'
Sets a player's criminal points, rounded, in their character data and CriminalPoints net var.
Parameters
- player Player The player
- amt Number The new amount; numeric strings are converted, anything else is ignored
Sets whether a player is jailed, in their character data and Jailed net var.
Parameters
- player Player The player
- value Boolean Whether the player is jailed; converted with
tobool
Sets a player's job in their character data and Job net var.
Parameters
- player Player The player
- value String The job
Sets a player's loyalty points, rounded, in their character data and LoyaltyPoints net var.
Parameters
- player Player The player
- amt Number The new amount; numeric strings are converted, anything else is ignored
Sets a player's residence in their character data and Residence net var.
Parameters
- player Player The player
- value String The residence
Called when a player's visibility is set up; adds a scanner player's scanner to their PVS.
Parameters
- player Player The player
Sets a player's work points, rounded, in their character data and WorkPoints net var.
Parameters
- player Player The player
- value Number The new amount; numeric strings are converted, anything else is ignored
Called when a player presses F3; uses the player's zip tie, or tells them they have none.
Parameters
- player Player The player
Called when a player presses F4; runs the CharSearch command.
Parameters
- player Player The player
Subtracts from a player's criminal points with Schema:AddCP.
Parameters
- player Player The player
- amt Number The amount to subtract
Subtracts from a player's loyalty points with Schema:AddLP.
Parameters
- player Player The player
- amt Number The amount to subtract
On the server
Called every tick.
Moves each scanner's follow marker while its player holds forward (slower with sprint), replaces a
scanner whose class no longer matches its player's SYNTH rank and removes the scanners of players who
left.
On the client
Called every tick.
For Combine players, adds Combine display lines when health or armour changes and a random display line every three seconds.
Defined in
Ties or unties a player.
Sets the tied net var to 0 (untied), 1 (tied) or 2 (tied by the Combine). Tying drops and
strips the player's weapons; untying light-spawns them to give their weapons back. Both are logged.
Parameters
- player Player The player
- isTied Boolean Whether to tie the player
- reset Boolean optional, defaults to
nilWhen untying, skip the light spawn and the log entry - combine Boolean optional, defaults to
nilWhether the Combine tied the player