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

Finds an initialized player by part of their name or by Steam ID.
Random()shared
Returns a random connected player.

Methods

Alive()server
Returns whether the player is alive, treating a player who is faking death as dead.
Bans the player's Steam ID, which also kicks them.
Adds or removes a boost to one of the player's attributes.
Returns whether the player has at least an amount of cash.
Returns whether the player has room for additional inventory space.
Returns whether the player can carry additional weight.
Returns the player's Steam community ID, computed from their Steam ID.
Stops the player's forced animation after a delay, replacing any pending stop timer.
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.
Finds an instance of an item in the player's inventory.
Returns the instances of an item in the player's inventory whose name matches, ignoring case.
Returns the item instance behind one of the player's weapons.
Returns the accessory data of the player's character.
Returns the player's attribute boosts.
Returns the attributes of the player's character.
GetCash()server
Returns the cash of the player's character.
Returns the player's current character.
Returns a value from the player's character data.
Returns the ID of the player's character among the player's own characters.
Returns the key of the player's character, which is unique among all characters.
Returns the player's characters.
Returns the icon shown next to the player in chat.
Returns the player's Catwork user group.
Returns the clothes data of the player's character.
Returns the clothes item the player is wearing.
Returns a value from the player's persistent data, which belongs to the player rather than a character.
Returns the model chosen for the player's character.
Returns the faction of the player's character.
Returns the player's rank within their faction.
Returns the flags of the player's character.
Returns the player's current forced animation.
Returns the gender of the player's character.
Returns the entity the player is holding.
Returns the table of movement and inventory values the kernel refreshes for the player every think.
Returns the inventory of the player's character.
Returns the total space taken by the player's inventory.
Returns the total weight of the player's inventory.
Returns how many instances of an item the player has.
Returns the item entity the player is interacting with.
Finds an instance of an item in the player's inventory; the same as Player:FindItemByID.
Returns all instances of an item in the player's inventory.
Returns the player's maximum armor.
Returns the player's maximum health.
Returns the maximum inventory space the player has.
Returns the maximum weight the player can carry.
Returns the playback rate of the player's animations.
Returns the player's global flags, which apply to all of their characters.
Returns the player's ragdoll entity.
Returns the player's ragdoll state.
Returns the player's ragdoll table, which holds the ragdoll entity and what to restore when they get up.
Returns the weapons the player will get back when their ragdoll gets up.
Returns the characters the player's character recognises.
Returns the ammo saved with the player's character.
Returns a net variable of the player.
Returns the entity whose storage the player has open.
Returns the storage the player has open.
Returns the run speed the player is meant to have.
Returns when the player's character was created.
Returns the wages the player earns each wages interval.
Returns the name of the player's wages, as shown to players (e.g. "Supplies").
Gives the player a weapon, optionally tied to an item.
Gives cash to the player's character, or takes it with a negative amount.
Gives the player an item.
Gives the player several items.
Gives the player the weapon of a weapon item.
Grants a permission to the player by setting it to true.
Disables god mode for the player.
Enables god mode for the player and remembers it for Player:IsInGodMode.
Updates the player's timed attribute boosts, fading their amount out and removing expired ones.
Sends the player's accumulated attribute progress to their client every 30 seconds.
Returns whether the player is wearing any accessory of an item type.
Returns whether the player has received the config.
Returns whether the player has loaded a character and finished initializing.
Returns whether the player has one of their weapons from an item instance.
Returns whether the player has at least one instance of an item.
Returns whether the player has at least an amount of instances of an item.
Returns whether a specific item instance is in the player's inventory.
Returns the value of one of the player's permissions.
Returns whether the player's initial spawn has happened.
Returns whether the player has a specific attribute boost.
Returns whether the player's character menu was opened with a reset, which kills them silently.
Returns whether god mode was enabled with Player:GodEnable.
Returns whether the player is in the middle of a jump.
Returns the reason the player is being kicked, if Player:Kick was called for them.
Returns whether the player is in noclip.
Returns whether the player, or their ragdoll while they are ragdolled, is on fire.
Returns whether the player is ragdolled (knocked out or fallen over).
Returns whether the player is sprinting.
Returns whether the player's active weapon is the hands (cw_hands).
Returns whether the player's active weapon is the keys (cw_keys).
Returns whether the player is still being shown the starter hints after joining.
Returns whether the player is wearing a specific accessory item instance.
Returns whether the player is wearing a clothes item.
Returns whether the player is wearing an item as clothes.
Kicks the player with a reason.
Returns the hit group the player was last hit in, including hits on their ragdoll.
Returns when the player last played on the server.
Returns the player's display name.
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>'.
Notifies the player in chat or with a notification popup.
Overrides the name Player:Name returns for this player, on the server and on clients.
Plays a footstep sound, at most once every quarter second.
Adds progress towards the next point of one of the player's attributes.
Returns a field of the player's character.
Returns whether the player's ragdoll holds a weapon of a class.
Tells the player's client to rebuild its inventory panel on the next frame.
Takes off an accessory the player is wearing.
Takes off the player's clothes, optionally removing the clothes item from their inventory.
Runs a Catwork command as the player.
Runs a console command on the player's client.
Saves the player's current character to the database.
Sets the player's armor and runs the PlayerArmorSet hook with the new and old values.
Sets a value in the player's character data, or a base field of the character.
Sets the player's user group, saves it and runs the OnPlayerUserGroupSet hook.
Puts clothes on the player, or takes them off.
Sets whether the player has received the config.
Sets the player's crouched walk speed and, unless bClockwork is set, remembers it as the base speed.
Sets a value in the player's persistent data, which belongs to the player rather than a character.
Sets the player's rank within their faction, applying the rank's class, model and weapons.
Sets whether the player is faking death, which makes Player:Alive return false.
Forces the player to play an animation, or stops the current forced animation.
Sets the player's health and runs the PlayerHealthSet hook with the new and old values.
Sets the item entity the player is interacting with.
Sets the player's jump power and, unless bClockwork is set, remembers it as their base jump power.
Sets a networked variable on the player that is only sent to that player.
Sets the player's maximum armor, networked as MaxAP.
Sets the player's maximum health, networked as MaxHP.
Sets the player's model and announces the change.
Sets one of the player's permissions and stores it in the player's data.
Sets the player's run speed and, unless bClockwork is set, remembers it as their base run speed.
Sets a net variable of the player.
Sets the player's walk speed and, unless bClockwork is set, remembers it as their base walk speed.
Returns the player's 64-bit Steam ID, or an empty string where the engine returns nil.
Removes a weapon from the player, or from their ragdoll's weapons while they are ragdolled.
Removes all of the player's weapons, or their ragdoll's weapons while they are ragdolled.
SyncVars()server internal
Sends every entity and global networked variable to the player.
Takes an item instance from the player.
Takes an instance of an item from the player's inventory.
Takes several item instances from the player.
Revokes a permission from the player by setting it to false.
Returns when the player first joined the server.
Changes one of the player's attributes by a number of points.
UpdateWeaponFired()server internal
Detects whether the player's active weapon fired since the last check by comparing its clips.
Returns how deep the player is in water, using their ragdoll while they are ragdolled.
Puts on an accessory item.

Functions

player.Find(name, bCaseSensitive)

shared gamemodes/catwork/gamemode/core/libraries/sh_player.lua:107

Finds 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 nil Match the name case-sensitively

Returns

  • Player The player, or nil if nobody matches or name is empty

Returns a random connected player.

Returns

  • Player A random player, or nil when 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

Player:Ban(duration, reason)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1654

Bans the player's Steam ID, which also kicks them.

Parameters

  • duration Number Ban length in minutes; 0 bans permanently
  • reason String optional, defaults to nil Ban reason

See also

Player:BoostAttribute(identifier, attribute, amount, duration)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2351

Adds or removes a boost to one of the player's attributes.

Parameters

  • identifier String Boost identifier; generated when nil and amount is given
  • attribute Any Attribute index, unique ID or name
  • amount Number optional, defaults to nil Points to add while the boost lasts, or nil to remove boosts
  • duration Number optional, defaults to nil How long the boost lasts in seconds, or nil for no time limit

Returns

  • String The boost identifier when a boost was added, or true when boosts were removed

See also

Player:CanAfford(amount)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2613

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 true when cash is disabled

See also

Player:CanHoldSpace(space)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2085

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; always true when the space system is disabled

Player:CanHoldWeight(weight)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2069

Returns whether the player can carry additional weight.

Parameters

  • weight Number The weight to add

Returns

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)

Player:CreateAnimationStopDelay(delay)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1848

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.

Player:FakePickup(entity)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1962

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

Player:FindItemByID(uniqueID, itemID)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2147

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 nil Item ID of the instance; any instance of the item when nil

Returns

  • Item The instance, or nil if the player does not have it

See also

Player:FindItemsByName(uniqueID, name)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2016

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 name and PrintName

Returns

  • List<Item> The matching instances, or nil if the player has none of the item

See also

Player:FindWeaponItemByID(uniqueID, itemID)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2172

Returns 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 nil if no weapon of the player belongs to it

Player:GetAccessoryData()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2493

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

Player:GetAttributeBoosts()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2220

Returns the player's attribute boosts.

Returns

  • Map Attribute unique IDs mapped to tables of boosts by identifier, each with amount, default, duration and endTime

Returns the attributes of the player's character.

Returns

  • Map Attribute unique IDs mapped to { amount = Number, progress = Number }, or nil without a character

Returns the cash of the player's character.

Returns

  • Number The cash, or 0 when the cash_enabled config is off

Returns the player's current character.

Returns

  • Character The character, or nil if the player has not loaded one

Player:GetCharacterData(key, default)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:2455

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 nil Value 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 nil Fallback 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 nil without a character

See also

Player:GetCharacterKey()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1711

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 nil without 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

Player:GetClockworkUserGroup()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1996

Returns the player's Catwork user group.

Returns

  • String The user group

Returns the clothes data of the player's character.

Returns

  • Map uniqueID and itemID of 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 nil if the player wears none or no longer has it

Player:GetData(key, default)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:1225

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 nil Value 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 nil Fallback value

Returns

  • Any The value

See also

Defined in

Player:GetDefaultModel()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1696

Returns the model chosen for the player's character.

Returns

  • String The model path, or nil without a character

On the server

Returns the faction of the player's character.

Returns

  • String The faction name, or nil without a character

On the client

Returns the name of the player's faction.

Returns

  • String The faction name, or 'Unknown'

Defined in

Player:GetFactionRank(character)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:2621

On the server

Returns the player's rank within their faction.

Parameters

  • character Character optional, defaults to nil Character 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 nil Character to check instead of the current one

Returns

  • String The rank name, or nil when 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

Player:GetForcedAnimation()

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:1942

On the server

Returns the player's current forced animation.

Returns

  • Map animation, delay, OnAnimate and OnFinish, or nil if none is playing

See also

On the client

Returns the player's forced animation.

Returns

  • Map Table with the animation field, or nil when no animation is forced

Defined in

On the server

Returns the gender of the player's character.

Returns

  • String GENDER_MALE or GENDER_FEMALE, or nil without a character

On the client

Returns the gender of the player's character.

Returns

  • String GENDER_FEMALE or GENDER_MALE

Defined in

Player:GetHoldingEntity()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2599

Returns the entity the player is holding.

The PlayerGetHoldingEntity hook is asked first.

Returns

  • Entity The held entity, or nil if 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, jumpPower and inventoryWeight

Returns the inventory of the player's character.

Returns

  • Inventory The inventory, or nil without a character

Player:GetInventorySpace()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2109

Returns the total space taken by the player's inventory.

Returns

  • Number The space

Player:GetInventoryWeight()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2103

Returns the total weight of the player's inventory.

Returns

  • Number The weight

Player:GetItemCountByID(uniqueID)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2126

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 nil if it is not set or no longer valid

Player:GetItemInstance(uniqueID, itemID)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2196

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 nil Item ID of the instance; any instance of the item when nil

Returns

  • Item The instance, or nil if the player does not have it

Player:GetItemsByID(uniqueID)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2005

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 nil if the player has none; an empty table for an unknown item

See also

Player:GetMaxArmor(armor)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:1775

On the server

Returns the player's maximum armor.

Parameters

  • armor Any optional, defaults to nil Unused

Returns

  • Number The maximum armor; 100 when it is unset or not positive

On the client

Returns the player's maximum armor.

Parameters

  • armor Number Unused

Returns

  • Number The MaxAP net variable, or 100 when it is not positive

Defined in

Player:GetMaxHealth(health)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:1794

On the server

Returns the player's maximum health.

Parameters

  • health Any optional, defaults to nil Unused

Returns

  • Number The maximum health; 100 when it is unset or not positive

On the client

Returns the player's maximum health.

Parameters

  • health Number Unused

Returns

  • Number The MaxHP net variable, or 100 when 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

Player:GetPlaybackRate()

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:1235

On the server

Returns the playback rate of the player's animations.

Returns

  • Number The playback rate, 1 by default

On the client

Returns the player's animation playback rate.

Returns

  • Number The rate, 1 by 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

Player:GetRagdollEntity()

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:1743

On the server

Returns the player's ragdoll entity.

Returns

  • Entity The ragdoll, or nil if the player has no valid ragdoll

On the client

Returns the player's ragdoll entity.

Returns

  • Entity The ragdoll, or nil when the player is not ragdolled

Defined in

Player:GetRagdollState()

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:1734

On the server

Returns the player's ragdoll state.

Returns

  • Number One of RAGDOLL_KNOCKEDOUT, RAGDOLL_FALLENOVER, RAGDOLL_RESET or RAGDOLL_NONE

On the client

Returns the player's ragdoll state.

Returns

  • Number A RAGDOLL_* constant

Defined in

Player:GetRagdollTable()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1730

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, model and skin

Player:GetRagdollWeapons()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1747

Returns the weapons the player will get back when their ragdoll gets up.

Returns

  • List<Map> Entries with weaponData (class, itemTable), canHolster and teamIndex

Player:GetRecognisedNames()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1715

Returns the characters the player's character recognises.

Returns

  • Map Character keys mapped to RECOGNISE_* values, or nil without a character

Returns the ammo saved with the player's character.

Returns

  • Map Ammo types mapped to amounts, or nil without a character

Player:GetSharedVar(key, default)

shared deprecated gamemodes/catwork/gamemode/core/sv_kernel.lua:2437

On the server

Deprecated

Use Player:GetNetVar instead.

Returns a net variable of the player.

Parameters

  • key String Name of the variable
  • default Any optional, defaults to nil Value to return when the variable is not set

Returns

  • Any The value, or default

On the client

Returns a networked variable of the player.

Parameters

  • key String Name of the variable
  • default Any optional, defaults to nil Value returned when the variable is not set

Returns

  • Any The value

Defined in

Player:GetStorageEntity()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1739

Returns the entity whose storage the player has open.

Returns

  • Entity The storage entity, or nil if no storage is open

See also

Player:GetStorageTable()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1726

Returns the storage the player has open.

Returns

  • Map The storage table, or nil if no storage is open

See also

Player:GetTargetRunSpeed()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1415

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 nil without a character

Returns the wages the player earns each wages interval.

Returns

  • Number The wages, from the Wages net 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:1162

Gives 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 nil Item instance the weapon belongs to
  • bForceReturn Boolean optional, defaults to nil Give the weapon now even if the player is ragdolled

Player:GiveCash(amount, reason, bNoMsg)

server gamemodes/catwork/gamemode/core/libraries/sv_player.lua:4229

Gives 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 nil Shown in the hint after the amount
  • bNoMsg Boolean optional, defaults to nil Do not show a hint

Player:GiveItem(itemTable, bForce)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2246

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 nil Give the item even if the player cannot carry it

Returns

  • Item The given instance, or false on failure
  • String The failure reason, as a language phrase

Player:GiveItems(itemTables)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2310

Gives the player several items.

Parameters

  • itemTables List<Item> Item instances or unique IDs

See also

Player:GiveItemWeapon(itemTable)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1148

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

Internal

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

Internal

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

Player:HasAccessory(uniqueID)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:3058

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

Player:HasConfigInitialized()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1935

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 Initialized net variable, or nil for invalid players

Defined in

Player:HasItemAsWeapon(itemTable)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2156

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

Player:HasItemByID(uniqueID)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2117

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

Player:HasItemCountByID(uniqueID, amount)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2136

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 amount of the item

Player:HasItemInstance(itemTable)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2186

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 nil when the permission was never set or id is not a non-empty string

See also

Returns whether the player's initial spawn has happened.

Returns

  • Boolean true once PlayerInitialSpawn has run for the player, otherwise nil

Player:IsBoostActive(identifier, attribute, amount, duration)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2362

Returns 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 nil Amount the boost must have
  • duration Number optional, defaults to nil Duration the boost must have, in seconds

Returns

  • Boolean Whether the boost is active

See also

Player:IsCharacterMenuReset()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2605

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 true in god mode, otherwise nil

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 nil if 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

Player:IsRagdolled(exception, entityless)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:1601

On the server

Returns whether the player is ragdolled (knocked out or fallen over).

Parameters

  • exception Number optional, defaults to nil A RAGDOLL_* state that does not count as ragdolled
  • entityless Boolean optional, defaults to nil Check the ragdoll state even if the player has no ragdoll entity

Returns

  • Boolean Whether the player is ragdolled, or nil when 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 nil A RAGDOLL_* state that does not count
  • entityless Boolean optional, defaults to false Check the state even when there is no ragdoll entity

Returns

  • Boolean Whether the player is ragdolled

Defined in

Player:IsRunning(bNoWalkSpeed)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:1374

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 nil Whether 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 false Do 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

Player:IsViewingStarterHints()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1806

Returns whether the player is still being shown the starter hints after joining.

Returns

  • Boolean Whether the starter hints are showing

Player:IsWearingAccessory(itemTable)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:3073

Returns whether the player is wearing a specific accessory item instance.

Parameters

  • itemTable Item The accessory item instance

Returns

  • Boolean Whether it is worn

Player:IsWearingClothes()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2535

Returns whether the player is wearing a clothes item.

Returns

  • Boolean Whether the player wears clothes

Player:IsWearingItem(itemTable)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2542

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 nil if 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 nil Whether to ignore the name override

Returns

  • String The player's name

Aliases

  • Player.GetName
  • Player.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 false Ignore the name override

Returns

  • String The name

Aliases

  • Player.GetName
  • Player.Nick

Defined in

Player:NetworkAccessories()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:3028

Sends all of the player's worn accessories to their client.

Player:NetworkClothesData()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2550

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

Notifies the player in chat or with a notification popup.

Same as cw.player:Notify.

Parameters

  • text String The text
  • class Any optional, defaults to nil true or nil for chat, or a NOTIFY_* number for a popup
  • icon String optional, defaults to nil Path of the chat icon

Player:OverrideName(name)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1066

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; nil or '' removes the override

Player:PlayStepSound(volume)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1090

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

Adds 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 nil Whether to scale positive progress down as the attribute grows

Returns

  • Boolean false when the progress was not applied
  • String The reason

See also

Player:QueryCharacter(key, default)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2424

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 nil Value to return when the field is not set or there is no character

Returns

  • Any The field's value, or default

See also

Player:RagdollHasWeapon(weaponClass)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1754

Returns whether the player's ragdoll holds a weapon of a class.

Parameters

  • weaponClass String Weapon class name

Returns

  • Boolean true if the ragdoll has the weapon, otherwise nil

Player:RebuildInventory()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2225

Tells the player's client to rebuild its inventory panel on the next frame.

Player:RemoveAccessory(itemTable)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:3038

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

Player:RemoveClothes(bRemoveItem)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2506

Takes off the player's clothes, optionally removing the clothes item from their inventory.

Parameters

  • bRemoveItem Boolean optional, defaults to nil Whether to also take the clothes item

Returns

  • Item The removed clothes item when bRemoveItem is set and the player wore one

Player:RunClockworkCmd(command, ...)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1836

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

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

Sets 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 nil Set a base field of the character table instead of its data

See also

Player:SetClockworkUserGroup(userGroup)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1984

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'

Player:SetClothesData(itemTable)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2565

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 nil to take the current clothes off

Player:SetConfigInitialized(initialized)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1929

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

Sets 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 nil Whether this is a temporary change that keeps the base speed

Player:SetData(key, value)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:3144

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

Player:SetFactionRank(rank)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2628

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

Sets 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 nil When ending the fake death, kill the player silently

Player:SetForcedAnimation(animation, delay, OnAnimate, OnFinish)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1877

Forces 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; false stops the forced animation
  • delay Number optional, defaults to nil Seconds to play it for; nil or 0 plays it until stopped
  • OnAnimate Function optional, defaults to nil Called as OnAnimate(player) when the animation first plays
  • OnFinish Function optional, defaults to nil Called as OnFinish(player) when the animation ends or is replaced

Returns

  • Boolean true if the animation started, false if it was stopped, nil if it was not played

Player:SetHealth(health)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1351

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

Player:SetItemEntity(entity)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1956

Sets the item entity the player is interacting with.

Parameters

  • entity Entity The item entity; nil clears it

Player:SetJumpPower(power, bClockwork)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2398

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 nil Whether this is a temporary change that keeps the base power

Player:SetLocalVar(key, value)

server gamemodes/catwork/gamemode/core/libraries/sv_netvars.lua:179

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

Player:SetMaxArmor(armor)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1768

Sets the player's maximum armor, networked as MaxAP.

Parameters

  • armor Number The maximum armor

Player:SetMaxHealth(health)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1787

Sets the player's maximum health, networked as MaxHP.

Parameters

  • health Number The maximum health

Player:SetModel(strPath)

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

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

Player:SetPermission(id, value)

server gamemodes/catwork/gamemode/core/libraries/sh_admin.lua:37

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 true or false

Returns

  • Boolean Whether the value differs from the previous one

See also

Player:SetRunSpeed(speed, bClockwork)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2377

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 nil Whether this is a temporary change that keeps the base speed

Player:SetSharedVar(key, value, sharedTable)

shared deprecated gamemodes/catwork/gamemode/core/sv_kernel.lua:2446

On the server

Deprecated

Use Player:SetNetVar instead.

Sets a net variable of the player.

Parameters

  • key String Name of the variable
  • value Any The new value
  • sharedTable Any optional, defaults to nil Ignored

On the client

Does nothing; shared variables can only be set on the server.

Parameters

  • key String Name of the variable
  • value Any The value

Defined in

Player:SetWalkSpeed(speed, bClockwork)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2387

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 nil Whether 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

Player:StripWeapon(weaponClass)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1399

Removes a weapon from the player, or from their ragdoll's weapons while they are ragdolled.

Parameters

  • weaponClass String Weapon class name

Player:StripWeapons(ragdollForce)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:1471

Removes all of the player's weapons, or their ragdoll's weapons while they are ragdolled.

Parameters

  • ragdollForce Boolean optional, defaults to nil Strip 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.

Player:TakeItem(itemTable)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2284

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, or false when itemTable is not an item instance

Player:TakeItemByID(uniqueID, itemID)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2207

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 nil Item ID of the instance; any instance of the item when nil

Returns

  • Boolean Whether an item was taken

See also

Player:TakeItems(itemTables)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2319

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

Player:UpdateAttribute(attribute, amount)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:2330

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

Player:UpdateWeaponFired()

server internal gamemodes/catwork/gamemode/core/sv_kernel.lua:1500

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)

Player:WearAccessory(itemTable)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:3088

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