player class
Adds per-player permission methods to the Player metatable: Player:HasPermission in both realms and
Player:SetPermission, Player:GivePermission and Player:TakePermission on the server.
Permissions are stored in the player's data under permissions, keyed by lowercased ID.
Summary
Functions
Methods
Player:FindItemByID.true.Player:IsInGodMode.Player:GodEnable.Player:Kick was called for them.cw_hands).cw_keys).Clothes net variable as '<uniqueID> <itemID>'.Player:Name returns for this player, on the server and on clients.PlayerArmorSet hook with the new and old values.OnPlayerUserGroupSet hook.bClockwork is set, remembers it as the base speed.Player:Alive return false.PlayerHealthSet hook with the new and old values.bClockwork is set, remembers it as their base jump power.MaxAP.MaxHP.bClockwork is set, remembers it as their base run speed.bClockwork is set, remembers it as their base walk speed.nil.false.Functions
player.Find(name, bCaseSensitive)
shared gamemodes/catwork/gamemode/core/libraries/sh_player.lua:107Finds an initialized player by part of their name or by Steam ID.
The name is matched as plain text anywhere in the player's name. A player whose whole name or Steam ID matches wins; otherwise the first partial match does. Passing a valid player returns that player.
Parameters
- name String Part of the player's name or their Steam ID, or a Player
- bCaseSensitive Boolean optional, defaults to
nilMatch the name case-sensitively
Returns
- Player The player, or
nilif nobody matches ornameis empty
Returns a random connected player.
Returns
- Player A random player, or
nilwhen the server is empty
Methods
Returns whether the player is alive, treating a player who is faking death as dead.
Returns
- Boolean Whether the player is alive
See also
Bans the player's Steam ID, which also kicks them.
Parameters
- duration Number Ban length in minutes;
0bans permanently - reason String optional, defaults to
nilBan reason
See also
Player:BoostAttribute(identifier, attribute, amount, duration)
server gamemodes/catwork/gamemode/core/sv_kernel.lua:2351Adds or removes a boost to one of the player's attributes.
Parameters
- identifier String Boost identifier; generated when
nilandamountis given - attribute Any Attribute index, unique ID or name
- amount Number optional, defaults to
nilPoints to add while the boost lasts, ornilto remove boosts - duration Number optional, defaults to
nilHow long the boost lasts in seconds, ornilfor no time limit
Returns
- String The boost identifier when a boost was added, or
truewhen boosts were removed
See also
Returns whether the player has at least an amount of cash.
Parameters
- amount Number The amount of cash
Returns
- Boolean Whether the player can afford it; always
truewhen cash is disabled
See also
Returns whether the player has room for additional inventory space.
Parameters
- space Number The space to add
Returns
- Boolean Whether the inventory stays within
Player:GetMaxSpace; alwaystruewhen the space system is disabled
Returns whether the player can carry additional weight.
Parameters
- weight Number The weight to add
Returns
- Boolean Whether the inventory stays within
Player:GetMaxWeight
Returns the player's Steam community ID, computed from their Steam ID.
Returns
- Number The community ID, or the Steam ID string if it could not be parsed (e.g. for bots)
Stops the player's forced animation after a delay, replacing any pending stop timer.
Parameters
- delay Number Seconds until the animation stops
Puts out the fire on the player, or on their ragdoll while they are ragdolled.
Plays a pickup animation towards an entity: a low pickup when it is nearer the feet, a reach otherwise.
Parameters
- entity Entity The entity being picked up
Finds an instance of an item in the player's inventory.
Parameters
- uniqueID String Unique ID, index or name of the item, as accepted by
item.FindByID - itemID Number optional, defaults to
nilItem ID of the instance; any instance of the item whennil
Returns
- Item The instance, or
nilif the player does not have it
See also
Returns the instances of an item in the player's inventory whose name matches, ignoring case.
Parameters
- uniqueID String Unique ID, index or name of the item, as accepted by
item.FindByID - name String Name to match against each instance's
nameandPrintName
Returns
- List<Item> The matching instances, or
nilif the player has none of the item
See also
Player:FindWeaponItemByID(uniqueID, itemID)
server gamemodes/catwork/gamemode/core/sv_kernel.lua:2172Returns the item instance behind one of the player's weapons.
Parameters
- uniqueID String Unique ID of the item
- itemID Number Item ID of the instance
Returns
- Item The instance, or
nilif no weapon of the player belongs to it
Returns the accessory data of the player's character.
Returns
- Map Item IDs of worn accessories mapped to their unique IDs; an empty table when no data is stored
Returns the player's attribute boosts.
Returns
- Map Attribute unique IDs mapped to tables of boosts by identifier, each with
amount,default,durationandendTime
Returns the attributes of the player's character.
Returns
- Map Attribute unique IDs mapped to
{ amount = Number, progress = Number }, ornilwithout a character
Returns the cash of the player's character.
Returns
- Number The cash, or
0when thecash_enabledconfig is off
Returns the player's current character.
Returns
- Character The character, or
nilif the player has not loaded one
On the server
Returns a value from the player's character data.
Parameters
- key String Name of the value, as registered with
cw.player:AddCharacterData - default Any optional, defaults to
nilValue to return when the key is not set or there is no character
Returns
- Any The stored value, or
default
See also
On the client
Returns a networked character data value.
The default is returned when the value is not set, the key is not registered character data
(see cw.player:AddCharacterData), or it is player-only and the player is not the local player.
Parameters
- key String The data key
- default Any optional, defaults to
nilFallback value
Returns
- Any The value
Defined in
Returns the ID of the player's character among the player's own characters.
Returns
- Number The character ID, or
nilwithout a character
See also
Returns the key of the player's character, which is unique among all characters.
Used to identify a character across players, e.g. for recognition and entity ownership.
Returns
- Number The character key, or
nilwithout a character
Returns the player's characters.
Returns
- Map<Character> Character IDs mapped to characters
Returns the icon shown next to the player in chat.
Returns
- String Path of the icon material
Returns the player's Catwork user group.
Returns
- String The user group
Returns the clothes data of the player's character.
Returns
- Map
uniqueIDanditemIDof the worn clothes; an empty table when no data is stored
Returns the clothes item the player is wearing.
Returns
- Item The clothes item, or
nilif the player wears none or no longer has it
On the server
Returns a value from the player's persistent data, which belongs to the player rather than a character.
Parameters
- key String Name of the value
- default Any optional, defaults to
nilValue to return when the key is not set
Returns
- Any The stored value, or
default
See also
On the client
Returns a networked player data value.
The default is returned when the value is not set, the key is not registered player data, or it is player-only and the player is not the local player.
Parameters
- key String The data key
- default Any optional, defaults to
nilFallback value
Returns
- Any The value
See also
Defined in
Returns the model chosen for the player's character.
Returns
- String The model path, or
nilwithout a character
On the server
Returns the faction of the player's character.
Returns
- String The faction name, or
nilwithout a character
On the client
Returns the name of the player's faction.
Returns
- String The faction name, or
'Unknown'
Defined in
On the server
Returns the player's rank within their faction.
Parameters
- character Character optional, defaults to
nilCharacter to check instead of the player's current one
Returns
- String The rank name
- Map The rank's table from the faction's
ranks
See also
On the client
Returns the player's rank within their faction; see cw.player:GetFactionRank.
Parameters
- character Character optional, defaults to
nilCharacter to check instead of the current one
Returns
- String The rank name, or
nilwhen the faction has no ranks - Map The rank table
Defined in
Returns the flags of the player's character.
Returns
- String The character's flags, one letter each
See also
On the server
Returns the player's current forced animation.
Returns
- Map
animation,delay,OnAnimateandOnFinish, ornilif none is playing
See also
On the client
Returns the player's forced animation.
Returns
- Map Table with the
animationfield, ornilwhen no animation is forced
Defined in
On the server
Returns the gender of the player's character.
Returns
- String
GENDER_MALEorGENDER_FEMALE, ornilwithout a character
On the client
Returns the gender of the player's character.
Returns
- String
GENDER_FEMALEorGENDER_MALE
Defined in
Returns the entity the player is holding.
The PlayerGetHoldingEntity hook is asked first.
Returns
- Entity The held entity, or
nilif the player holds nothing
Returns the table of movement and inventory values the kernel refreshes for the player every think.
Returns
- Map The info table, with keys such as
walkSpeed,jumpPowerandinventoryWeight
Returns the inventory of the player's character.
Returns
- Inventory The inventory, or
nilwithout a character
Returns the total space taken by the player's inventory.
Returns
- Number The space
Returns the total weight of the player's inventory.
Returns
- Number The weight
Returns how many instances of an item the player has.
Parameters
- uniqueID String Unique ID, index or name of the item, as accepted by
item.FindByID
Returns
- Number The number of instances
Returns the item entity the player is interacting with.
Returns
- Entity The item entity, or
nilif it is not set or no longer valid
Finds an instance of an item in the player's inventory; the same as Player:FindItemByID.
Parameters
- uniqueID String Unique ID, index or name of the item, as accepted by
item.FindByID - itemID Number optional, defaults to
nilItem ID of the instance; any instance of the item whennil
Returns
- Item The instance, or
nilif the player does not have it
Returns all instances of an item in the player's inventory.
Parameters
- uniqueID String Unique ID, index or name of the item, as accepted by
item.FindByID
Returns
- Map<Item> Item IDs mapped to instances, or
nilif the player has none; an empty table for an unknown item
See also
On the server
Returns the player's maximum armor.
Parameters
- armor Any optional, defaults to
nilUnused
Returns
- Number The maximum armor;
100when it is unset or not positive
On the client
Returns the player's maximum armor.
Parameters
- armor Number Unused
Returns
- Number The
MaxAPnet variable, or100when it is not positive
Defined in
On the server
Returns the player's maximum health.
Parameters
- health Any optional, defaults to
nilUnused
Returns
- Number The maximum health;
100when it is unset or not positive
On the client
Returns the player's maximum health.
Parameters
- health Number Unused
Returns
- Number The
MaxHPnet variable, or100when it is not positive
Defined in
Returns the maximum inventory space the player has.
This is the InvSpace net variable (10 by default) plus the addInvVolume of every carried item.
Runs the PlayerAdjustMaxSpace hook with the result, but cannot be changed by it.
Returns
- Number The maximum space
Returns the maximum weight the player can carry.
This is the InvWeight net variable (8 by default) plus the addInvSpace of every carried item.
Runs the PlayerAdjustMaxWeight hook with the result, but cannot be changed by it.
Returns
- Number The maximum weight
On the server
Returns the playback rate of the player's animations.
Returns
- Number The playback rate,
1by default
On the client
Returns the player's animation playback rate.
Returns
- Number The rate,
1by default
Defined in
Returns the player's global flags, which apply to all of their characters.
Returns
- String The flags, one letter each;
''when none
See also
On the server
Returns the player's ragdoll entity.
Returns
- Entity The ragdoll, or
nilif the player has no valid ragdoll
On the client
Returns the player's ragdoll entity.
Returns
- Entity The ragdoll, or
nilwhen the player is not ragdolled
Defined in
On the server
Returns the player's ragdoll state.
Returns
- Number One of
RAGDOLL_KNOCKEDOUT,RAGDOLL_FALLENOVER,RAGDOLL_RESETorRAGDOLL_NONE
On the client
Returns the player's ragdoll state.
Returns
- Number A
RAGDOLL_*constant
Defined in
Returns the player's ragdoll table, which holds the ragdoll entity and what to restore when they get up.
Returns
- Map The ragdoll table, with keys such as
entity,weapons,modelandskin
Returns the weapons the player will get back when their ragdoll gets up.
Returns
- List<Map> Entries with
weaponData(class,itemTable),canHolsterandteamIndex
Returns the characters the player's character recognises.
Returns
- Map Character keys mapped to
RECOGNISE_*values, ornilwithout a character
Returns the ammo saved with the player's character.
Returns
- Map Ammo types mapped to amounts, or
nilwithout a character
Returns the entity whose storage the player has open.
Returns
- Entity The storage entity, or
nilif no storage is open
See also
Returns the storage the player has open.
Returns
- Map The storage table, or
nilif no storage is open
See also
Returns the run speed the player is meant to have.
Returns
- Number The target run speed, or the current run speed if none is set
Returns when the player's character was created.
Returns
- Number The creation time, or
nilwithout a character
Returns the wages the player earns each wages interval.
Returns
- Number The wages, from the
Wagesnet variable
On the server
Returns the name of the player's wages, as shown to players (e.g. "Supplies").
Returns
- String The wages name
On the client
Returns what the player's class calls its wages.
Returns
- String The wages name
Defined in
Player:Give(class, itemTable, bForceReturn)
server gamemodes/catwork/gamemode/core/sv_kernel.lua:1162Gives the player a weapon, optionally tied to an item.
Does nothing if the PlayerCanBeGivenWeapon hook returns false. While the player is ragdolled the weapon
is added to the ragdoll's weapons and handed out when they get up, unless bForceReturn is set. With an
item, the weapon gets its ItemID networked string, the item definition is sent to the player and
the item's OnWeaponGiven callback runs. Runs PlayerGivenWeapon afterwards. Unlike the engine function
(kept as Player:ClockworkGive), nothing is returned.
Parameters
- class String Weapon class name
- itemTable Item optional, defaults to
nilItem instance the weapon belongs to - bForceReturn Boolean optional, defaults to
nilGive the weapon now even if the player is ragdolled
Player:GiveCash(amount, reason, bNoMsg)
server gamemodes/catwork/gamemode/core/libraries/sv_player.lua:4229Gives cash to the player's character, or takes it with a negative amount.
Same as cw.player:GiveCash.
Parameters
- amount Number Cash to give; negative takes it
- reason String optional, defaults to
nilShown in the hint after the amount - bNoMsg Boolean optional, defaults to
nilDo not show a hint
Gives the player an item.
Fails when the item does not fit within Player:GetMaxWeight and Player:GetMaxSpace, unless bForce
is set. On success, calls the item's OnGiveToPlayer, logs it, sends the item to the client, runs the
PlayerItemGiven hook and rebuilds the inventory.
local success, fault = player:GiveItem('ration')
if !success then
player:Notify(fault)
end
Parameters
- itemTable Item The item instance, or an item unique ID to create a new instance of
- bForce Boolean optional, defaults to
nilGive the item even if the player cannot carry it
Returns
- Item The given instance, or
falseon failure - String The failure reason, as a language phrase
Gives the player several items.
Parameters
- itemTables List<Item> Item instances or unique IDs
See also
Gives the player the weapon of a weapon item.
Parameters
- itemTable Item The weapon item instance
See also
Grants a permission to the player by setting it to true.
Parameters
- id String Permission ID
See also
Disables god mode for the player.
Enables god mode for the player and remembers it for Player:IsInGodMode.
Player:HandleAttributeBoosts(curTime)
server internal gamemodes/catwork/gamemode/core/sv_kernel.lua:1447Internal
This function is internal. It is not part of the public API and may change without notice.
Called by the kernel once a second for each player.
Updates the player's timed attribute boosts, fading their amount out and removing expired ones.
Parameters
- curTime Number The current
CurTime
Player:HandleAttributeProgress(curTime)
server internal gamemodes/catwork/gamemode/core/sv_kernel.lua:1424Internal
This function is internal. It is not part of the public API and may change without notice.
Called by the kernel once a second for each player.
Sends the player's accumulated attribute progress to their client every 30 seconds.
Clears the accumulated progress after sending it.
Parameters
- curTime Number The current
CurTime
Returns whether the player is wearing any accessory of an item type.
Parameters
- uniqueID String Unique ID of the accessory item, compared ignoring case
Returns
- Boolean Whether such an accessory is worn
Returns whether the player has received the config.
Returns
- Boolean Whether the config was sent to the player
On the server
Returns whether the player has loaded a character and finished initializing.
Returns
- Boolean Whether the player has initialized
On the client
Returns whether the player has fully loaded and has a character.
Returns
- Boolean The
Initializednet variable, ornilfor invalid players
Defined in
Returns whether the player has one of their weapons from an item instance.
Parameters
- itemTable Item The item instance
Returns
- Boolean Whether a weapon of the player belongs to the item
Returns whether the player has at least one instance of an item.
Parameters
- uniqueID String Unique ID of the item
Returns
- Boolean Whether the player has the item
See also
Returns whether the player has at least an amount of instances of an item.
Parameters
- uniqueID String Unique ID, index or name of the item, as accepted by
item.FindByID - amount Number The amount needed
Returns
- Boolean Whether the player has at least
amountof the item
Returns whether a specific item instance is in the player's inventory.
Parameters
- itemTable Item The item instance
Returns
- Boolean Whether the instance is in the inventory
Returns the value of one of the player's permissions.
Permissions live in the player's data under permissions. The ID is lowercased before the
lookup.
Parameters
- id String Permission ID
Returns
- Any The stored value (normally a Boolean), or
nilwhen the permission was never set oridis not a non-empty string
See also
Returns whether the player's initial spawn has happened.
Returns
- Boolean
trueoncePlayerInitialSpawnhas run for the player, otherwisenil
Player:IsBoostActive(identifier, attribute, amount, duration)
server gamemodes/catwork/gamemode/core/sv_kernel.lua:2362Returns whether the player has a specific attribute boost.
Parameters
- identifier String Boost identifier
- attribute Any Attribute index, unique ID or name
- amount Number optional, defaults to
nilAmount the boost must have - duration Number optional, defaults to
nilDuration the boost must have, in seconds
Returns
- Boolean Whether the boost is active
See also
Returns whether the player's character menu was opened with a reset, which kills them silently.
Returns
- Boolean Whether the character menu was reset
Returns whether god mode was enabled with Player:GodEnable.
Returns
- Boolean
truein god mode, otherwisenil
Returns whether the player is in the middle of a jump.
Returns
- Boolean Whether the player is jumping and alive, not ragdolled, crouching or in a vehicle
Returns the reason the player is being kicked, if Player:Kick was called for them.
Returns
- String The kick reason, or
nilif the player is not being kicked
On the server
Returns whether the player is in noclip.
Returns
- Boolean Whether the player is noclipping
See also
On the client
Returns whether the player is in noclip outside a vehicle.
Returns
- Boolean Whether the player is noclipping
Defined in
Returns whether the player, or their ragdoll while they are ragdolled, is on fire.
Returns
- Boolean Whether the player is burning
On the server
Returns whether the player is ragdolled (knocked out or fallen over).
Parameters
- exception Number optional, defaults to
nilARAGDOLL_*state that does not count as ragdolled - entityless Boolean optional, defaults to
nilCheck the ragdoll state even if the player has no ragdoll entity
Returns
- Boolean Whether the player is ragdolled, or
nilwhen there is no ragdoll entity
See also
On the client
Returns whether the player is ragdolled; see cw.player:IsRagdolled.
Parameters
- exception Number optional, defaults to
nilARAGDOLL_*state that does not count - entityless Boolean optional, defaults to
falseCheck the state even when there is no ragdoll entity
Returns
- Boolean Whether the player is ragdolled
Defined in
On the server
Returns whether the player is sprinting.
True while the player is alive, not ragdolled, crouching or in a vehicle, holds the sprint key and moves at least at walking speed.
Parameters
- bNoWalkSpeed Boolean optional, defaults to
nilWhether to skip the walking speed check
Returns
- Boolean Whether the player is running
On the client
Returns whether the player is running.
The player must be alive, standing, out of a vehicle, not ragdolled, and flagged as running by the server.
Parameters
- bNoWalkSpeed Boolean optional, defaults to
falseDo not require moving at least at walk speed
Returns
- Boolean Whether the player is running
Defined in
Returns whether the player's active weapon is the hands (cw_hands).
Returns
- Boolean Whether the player is using their hands
Returns whether the player's active weapon is the keys (cw_keys).
Returns
- Boolean Whether the player is using their keys
Returns whether the player is still being shown the starter hints after joining.
Returns
- Boolean Whether the starter hints are showing
Returns whether the player is wearing a specific accessory item instance.
Parameters
- itemTable Item The accessory item instance
Returns
- Boolean Whether it is worn
Returns whether the player is wearing a clothes item.
Returns
- Boolean Whether the player wears clothes
Returns whether the player is wearing an item as clothes.
Parameters
- itemTable Item The item instance
Returns
- Boolean Whether the item is the worn clothes, or
nilif the player wears none
Kicks the player with a reason.
The kick happens a moment later; a player whose initial spawn has not happened yet is kicked once it has.
The engine function is kept as Player:ClockworkKick.
Parameters
- reason String optional, defaults to
'You have been kicked.'Reason shown to the player
Returns the hit group the player was last hit in, including hits on their ragdoll.
Returns
- Number A
HITGROUP_*value
Returns when the player last played on the server.
Returns
- Number Unix time of the last session; the current time if it is not known yet
On the server
Returns the player's display name.
This is the name set with Player:OverrideName if any, otherwise the character's name, otherwise the
Steam name (Player:SteamName is the engine's original Name).
Parameters
- bRealName Boolean optional, defaults to
nilWhether to ignore the name override
Returns
- String The player's name
Aliases
Player.GetNamePlayer.Nick
On the client
Returns the player's character name.
Uses the NameOverride net variable unless bRealName is set, then the character name, and
falls back to the Steam name (Player:SteamName) when there is no character.
Parameters
- bRealName Boolean optional, defaults to
falseIgnore the name override
Returns
- String The name
Aliases
Player.GetNamePlayer.Nick
Defined in
Sends all of the player's worn accessories to their client.
Networks the player's worn clothes in the Clothes net variable as '<uniqueID> <itemID>'.
The variable is an empty string when no clothes are worn.
Player:Notify(text, class, icon)
server gamemodes/catwork/gamemode/core/libraries/sv_player.lua:4239Notifies the player in chat or with a notification popup.
Same as cw.player:Notify.
Parameters
- text String The text
- class Any optional, defaults to
niltrueornilfor chat, or aNOTIFY_*number for a popup - icon String optional, defaults to
nilPath of the chat icon
Overrides the name Player:Name returns for this player, on the server and on clients.
Stored in the NameOverride net variable.
Parameters
- name String The name to show;
nilor''removes the override
Plays a footstep sound, at most once every quarter second.
Wraps the engine function, kept as Player:ClockworkPlayStepSound.
Parameters
- volume Number Volume of the sound, from 0 to 1
Player:ProgressAttribute(attribute, amount, gradual)
server gamemodes/catwork/gamemode/core/sv_kernel.lua:2340Adds progress towards the next point of one of the player's attributes.
Parameters
- attribute Any Attribute index, unique ID or name
- amount Number Progress to add; negative values remove progress
- gradual Boolean optional, defaults to
nilWhether to scale positive progress down as the attribute grows
Returns
- Boolean
falsewhen the progress was not applied - String The reason
See also
Returns a field of the player's character.
The key is converted to camel case, so 'Name' reads character.name.
Parameters
- key String Name of the field
- default Any optional, defaults to
nilValue to return when the field is not set or there is no character
Returns
- Any The field's value, or
default
See also
Returns whether the player's ragdoll holds a weapon of a class.
Parameters
- weaponClass String Weapon class name
Returns
- Boolean
trueif the ragdoll has the weapon, otherwisenil
Tells the player's client to rebuild its inventory panel on the next frame.
Takes off an accessory the player is wearing.
Tells the client and calls the item's OnWearAccessory with false. Does nothing if it is not worn.
Parameters
- itemTable Item The accessory item instance
Takes off the player's clothes, optionally removing the clothes item from their inventory.
Parameters
- bRemoveItem Boolean optional, defaults to
nilWhether to also take the clothes item
Returns
- Item The removed clothes item when
bRemoveItemis set and the player wore one
Runs a Catwork command as the player.
Parameters
- command String Name of the command
- ... String The command's arguments
See also
Runs a console command on the player's client.
The client refuses to run cwlua this way.
Parameters
- ... String The command and its arguments, as for
RunConsoleCommand
Saves the player's current character to the database.
See also
Sets the player's armor and runs the PlayerArmorSet hook with the new and old values.
Parameters
- armor Number The new armor; does nothing if
nil
Player:SetCharacterData(key, value, bFromBase)
server gamemodes/catwork/gamemode/core/sv_kernel.lua:3114Sets a value in the player's character data, or a base field of the character.
When the value changes, it is sent to clients with cw.player:UpdateCharacterData and the
PlayerCharacterDataChanged hook is called with the key, old and new value. Base fields
(bFromBase) are camel cased, only set if they already exist, and are not networked.
Parameters
- key String Name of the value, as registered with
cw.player:AddCharacterData - value Any The new value
- bFromBase Boolean optional, defaults to
nilSet a base field of the character table instead of its data
See also
Sets the player's user group, saves it and runs the OnPlayerUserGroupSet hook.
Does nothing if the player is already in the group. Also sets the engine user group.
Parameters
- userGroup String The user group, e.g.
'superadmin','admin','operator'or'user'
Puts clothes on the player, or takes them off.
Calls OnChangeClothes on the old and new items and networks the change. Wearing clothes does nothing
when the player's class forces a model.
Parameters
- itemTable Item The clothes item to wear, or
nilto take the current clothes off
Sets whether the player has received the config.
Parameters
- initialized Boolean Whether the config was sent
Player:SetCrouchedWalkSpeed(speed, bClockwork)
server gamemodes/catwork/gamemode/core/sv_kernel.lua:2406Sets the player's crouched walk speed and, unless bClockwork is set, remembers it as the base speed.
Parameters
- speed Number The crouched walk speed multiplier
- bClockwork Boolean optional, defaults to
nilWhether this is a temporary change that keeps the base speed
Sets a value in the player's persistent data, which belongs to the player rather than a character.
When the value changes, it is sent with cw.player:UpdatePlayerData and the PlayerDataChanged hook is
called with the key, old and new value. Does nothing before the player's data has loaded.
Parameters
- key String Name of the value
- value Any The new value
See also
Sets the player's rank within their faction, applying the rank's class, model and weapons.
Parameters
- rank String Name of a rank in the faction's
ranks
See also
Player:SetFakingDeath(fakingDeath, killSilent)
server gamemodes/catwork/gamemode/core/sv_kernel.lua:1131Sets whether the player is faking death, which makes Player:Alive return false.
Parameters
- fakingDeath Boolean Whether the player is faking death
- killSilent Boolean optional, defaults to
nilWhen ending the fake death, kill the player silently
Player:SetForcedAnimation(animation, delay, OnAnimate, OnFinish)
server gamemodes/catwork/gamemode/core/sv_kernel.lua:1877Forces the player to play an animation, or stops the current forced animation.
The sequence is networked in the ForceAnim net variable. A permanent animation started with a delay
of 0 cannot be replaced until it is stopped. The previous animation's OnFinish runs when it is
replaced or stopped.
player:SetForcedAnimation('pickup', 1.2, nil, function(player)
player:EmitSound('items/ammo_pickup.wav')
end)
Parameters
- animation String Sequence name or activity number;
falsestops the forced animation - delay Number optional, defaults to
nilSeconds to play it for;nilor0plays it until stopped - OnAnimate Function optional, defaults to
nilCalled asOnAnimate(player)when the animation first plays - OnFinish Function optional, defaults to
nilCalled asOnFinish(player)when the animation ends or is replaced
Returns
- Boolean
trueif the animation started,falseif it was stopped,nilif it was not played
Sets the player's health and runs the PlayerHealthSet hook with the new and old values.
Parameters
- health Number The new health; does nothing if
nil
Sets the item entity the player is interacting with.
Parameters
- entity Entity The item entity;
nilclears it
Sets the player's jump power and, unless bClockwork is set, remembers it as their base jump power.
Parameters
- power Number The jump power
- bClockwork Boolean optional, defaults to
nilWhether this is a temporary change that keeps the base power
Sets a networked variable on the player that is only sent to that player.
Does nothing if the value contains a function (which prints an error). The value is always sent, even if it is unchanged.
Parameters
- key String Name of the variable
- value Any The new value; must not be or contain a function
See also
Player:GetLocalVar
Sets the player's maximum armor, networked as MaxAP.
Parameters
- armor Number The maximum armor
Sets the player's maximum health, networked as MaxHP.
Parameters
- health Number The maximum health
Sets the player's model and announces the change.
Overrides Entity:SetModel for players: runs the PlayerModelChanged hook first and, on the
server, sends a PlayerModelChanged Cable message to every client so they run the hook too.
Parameters
- strPath String Path of the new model
Returns
- Any Whatever the original
Entity:SetModelreturns
Sets one of the player's permissions and stores it in the player's data.
The ID is lowercased, as Player:HasPermission looks it up. Does nothing when id is not a
string.
Parameters
- id String Permission ID
- value Any New value, normally
trueorfalse
Returns
- Boolean Whether the value differs from the previous one
See also
Sets the player's run speed and, unless bClockwork is set, remembers it as their base run speed.
The kernel passes bClockwork for temporary changes such as slowing injured players.
Parameters
- speed Number The run speed
- bClockwork Boolean optional, defaults to
nilWhether this is a temporary change that keeps the base speed
Sets the player's walk speed and, unless bClockwork is set, remembers it as their base walk speed.
Also sets the slow walk (+walk) speed to the same value.
Parameters
- speed Number The walk speed
- bClockwork Boolean optional, defaults to
nilWhether this is a temporary change that keeps the base speed
Returns the player's 64-bit Steam ID, or an empty string where the engine returns nil.
Wraps the engine function, kept as Player:ClockworkSteamID64, so callers can concatenate the result
safely; prints a message when the fallback is used.
Returns
- String The SteamID64, or
''if it is not available
Removes a weapon from the player, or from their ragdoll's weapons while they are ragdolled.
Parameters
- weaponClass String Weapon class name
Removes all of the player's weapons, or their ragdoll's weapons while they are ragdolled.
Parameters
- ragdollForce Boolean optional, defaults to
nilStrip the player's real weapons even while ragdolled
Internal
This function is internal. It is not part of the public API and may change without notice.
Called from the PlayerInitialSpawn hook.
Sends every entity and global networked variable to the player.
Variables set with Player:SetLocalVar are only sent to the player they belong to.
Takes an item instance from the player.
Calls the item's OnTakeFromPlayer, logs it, runs the PlayerItemTaken hook, removes the instance,
tells the client and rebuilds the inventory.
Parameters
- itemTable Item The item instance
Returns
- Boolean
true, orfalsewhenitemTableis not an item instance
Takes an instance of an item from the player's inventory.
Parameters
- uniqueID String Unique ID, index or name of the item, as accepted by
item.FindByID - itemID Number optional, defaults to
nilItem ID of the instance; any instance of the item whennil
Returns
- Boolean Whether an item was taken
See also
Takes several item instances from the player.
Parameters
- itemTables List<Item> The item instances
See also
Revokes a permission from the player by setting it to false.
Parameters
- id String Permission ID
See also
Returns when the player first joined the server.
Returns
- Number Unix time of the first join; the current time if it is not known yet
Changes one of the player's attributes by a number of points.
Parameters
- attribute Any Attribute index, unique ID or name
- amount Number Points to add; negative values remove points
Returns
- Boolean Whether the attribute was updated
- String The reason it was not
See also
Internal
This function is internal. It is not part of the public API and may change without notice.
Called by the kernel from PlayerThink.
Detects whether the player's active weapon fired since the last check by comparing its clips.
Runs the PlayerFireWeapon hook with the weapon, CLIP_ONE or CLIP_TWO and the ammo type when a clip
went down.
Returns how deep the player is in water, using their ragdoll while they are ragdolled.
Returns
- Number Water level from 0 (dry) to 3 (fully submerged)
Puts on an accessory item.
Tells the client and calls the item's OnWearAccessory with true. Does nothing if it is already worn.
Parameters
- itemTable Item The accessory item instance
Defined in
- gamemodes/catwork/gamemode/core/cl_kernel.lua
- gamemodes/catwork/gamemode/core/libraries/sh_admin.lua
- gamemodes/catwork/gamemode/core/libraries/sh_player.lua
- gamemodes/catwork/gamemode/core/libraries/sv_netvars.lua
- gamemodes/catwork/gamemode/core/libraries/sv_player.lua
- gamemodes/catwork/gamemode/core/sh_kernel.lua
- gamemodes/catwork/gamemode/core/sv_kernel.lua
- gamemodes/catwork/gamemode/hooks/sh_hooks.lua