Summary

Methods

Adds a boost to the player's level in an attribute.
Lowers the player's level in an attribute.
Lowers the player's rank in a skill.
Returns the player's level in an attribute.
Returns the sum of the player's active boosts to an attribute.
Returns the player's active boosts to an attribute.
Returns the level and the boosts of one attribute of the player's character, in the form Player:get_attributes describes.
Returns the modifier that an attribute adds to the player's rolls: its level, boosts included.
Returns the level and the boosts of every attribute of the player's character.
Returns the player's rank in a skill.
Returns the modifier that a skill adds to the player's rolls: the modifier of the key stat of the skill plus the player's proficiency in it.
Returns the rank of every skill of the player's character.
Checks whether the player has an active boost with the given identifier.
Raises the player's level in an attribute.
Raises the player's rank in a skill.
Removes the boost with the given identifier from one attribute of the player's character.
Removes boosts from the player's character: all of them, those of one attribute, those with one identifier, or the boost of one attribute with one identifier.
Rolls a stat for the player: a d20 plus the modifier of the stat, after the AdjustAttributeRoll hook.
Rolls a skill for the player: a d20 plus the modifier of the skill, after the AdjustAttributeRoll hook.
Sets the player's level in an attribute, rounded and clamped to the attribute's min and max, and networks it.
Sets the player's rank in a skill, rounded and clamped between 0 and the skill's max, and networks it.

Methods

Player:boost_attribute(attribute_id, value, duration, identifier)

server plugins/stats/plugin/lib/sh_attributes.lua:713

Adds a boost to the player's level in an attribute. The boost is stored on the character, networked, and removed when it expires. A boost that is given an identifier replaces the boosts of the attribute that carry the same identifier, and can be removed with Player:remove_attribute_boost. Server only.

-- Two extra levels of strength for five minutes.
target:boost_attribute('strength', 2, 300)
-- One level less for as long as the character is drunk.
target:boost_attribute('strength', -1, nil, 'drunk')

Parameters

  • attribute_id String attribute to boost; ignored when it is not boostable
  • value Number levels to add, negative to take levels away
  • duration Number optional, defaults to nil seconds until the boost expires; it never expires if this is nil or not above 0
  • identifier Any optional, defaults to nil name of the boost, kept as a string

Returns

  • AttributeBoost the record of the boost, or nil if it was not added

Player:decrease_attribute(attribute_id, amount)

server plugins/stats/plugin/lib/sh_attributes.lua:691

Lowers the player's level in an attribute. Boosts are not counted. Server only.

Parameters

  • attribute_id String
  • amount Number optional, defaults to 1 levels to remove

Player:decrease_skill(skill_id, amount)

server plugins/stats/plugin/lib/sh_skills.lua:305

Lowers the player's rank in a skill. Server only.

Parameters

  • skill_id String
  • amount Number optional, defaults to 1 ranks to remove

Player:get_attribute(attribute_id, no_boost)

shared plugins/stats/plugin/lib/sh_attributes.lua:587

Returns the player's level in an attribute. Active boosts are added to the level unless disabled or the attribute is not boostable. A player whose character has no data for the attribute, such as a bot, is at the attribute's default level.

Parameters

  • attribute_id String
  • no_boost Boolean optional, defaults to false leave active boosts out of the level

Returns

  • Number level; 0 if the attribute is not registered

Player:get_attribute_boost(attribute_id)

shared plugins/stats/plugin/lib/sh_attributes.lua:628

Returns the sum of the player's active boosts to an attribute. The server leaves an expired boost out and takes it out of the networked data, so on the client every networked boost counts. If the attribute has boost_limited set, the sum is cut down so that the level together with the boost stays between the attribute's min and max.

Parameters

  • attribute_id String

Returns

  • Number

Player:get_attribute_boosts(attribute_id)

shared plugins/stats/plugin/lib/sh_attributes.lua:641

Returns the player's active boosts to an attribute.

Parameters

  • attribute_id String

Returns

  • List<Map> boosts, each with value and, when set, id, expires_at and end_time

See also

Player:get_attribute_data(attribute_id)

shared plugins/stats/plugin/lib/sh_attributes.lua:567

Returns the level and the boosts of one attribute of the player's character, in the form Player:get_attributes describes.

Parameters

  • attribute_id String

Returns

  • Map attribute data, or nil if the attribute is not registered or the player's character has no data for it

Player:get_attribute_modifier(stat_id)

shared plugins/stats/plugin/lib/sh_rolls.lua:218

Returns the modifier that an attribute adds to the player's rolls: its level, boosts included.

Parameters

  • stat_id String ID of the stat

Returns

  • Number 0 if the attribute is not registered

Player:get_attributes()

shared plugins/stats/plugin/lib/sh_attributes.lua:552

Returns the level and the boosts of every attribute of the player's character. On the client this is what the server has networked, which it does for the local player alone: any other player has no attributes there. A boost has a value, the identifier it was given (id), the time it expires at as a date-time string (expires_at) and as a CurTime (end_time); the last three are nil when not set.

local attributes = target:get_attributes()

-- attributes.strength = {
--   level = 3,
--   boosts = {
--     { value = 2, expires_at = '2026-01-01T12:00:00Z', end_time = 1520 },
--     { value = -1, id = 'drunk' }
--   }
-- }

Returns

  • Map attribute data keyed by attribute ID; empty if the player has no character or, on the client, nothing has been networked yet or the player is not the local one

Player:get_skill(skill_id)

shared plugins/stats/plugin/lib/sh_skills.lua:265

Returns the player's rank in a skill. A player whose character has no record for the skill, such as a bot, is at rank 0.

Parameters

  • skill_id String

Returns

  • Number rank; 0 if the skill is not registered

Player:get_skill_modifier(skill_id)

shared plugins/stats/plugin/lib/sh_rolls.lua:231

Returns the modifier that a skill adds to the player's rolls: the modifier of the key stat of the skill plus the player's proficiency in it.

Parameters

  • skill_id String ID of the skill

Returns

  • Number 0 if the skill is not registered

See also

Player:get_skills()

shared plugins/stats/plugin/lib/sh_skills.lua:253

Returns the rank of every skill of the player's character. On the client this is what the server has networked, which it does for the local player alone: any other player has no skills there.

local skills = target:get_skills()

-- skills.athletics = 2

Returns

  • Map ranks keyed by skill ID; empty if the player has no character or, on the client, nothing has been networked yet or the player is not the local one

Player:has_attribute_boost(attribute_id, identifier)

shared plugins/stats/plugin/lib/sh_attributes.lua:651

Checks whether the player has an active boost with the given identifier.

Parameters

  • attribute_id String
  • identifier Any identifier the boost was given, compared as a string

Returns

  • Boolean

Player:increase_attribute(attribute_id, amount)

server plugins/stats/plugin/lib/sh_attributes.lua:682

Raises the player's level in an attribute. Boosts are not counted. Server only.

Parameters

  • attribute_id String
  • amount Number optional, defaults to 1 levels to add

Player:increase_skill(skill_id, amount)

server plugins/stats/plugin/lib/sh_skills.lua:296

Raises the player's rank in a skill. Server only.

Parameters

  • skill_id String
  • amount Number optional, defaults to 1 ranks to add

Player:remove_attribute_boost(attribute_id, identifier)

server plugins/stats/plugin/lib/sh_attributes.lua:751

Removes the boost with the given identifier from one attribute of the player's character. Server only.

Parameters

  • attribute_id String
  • identifier Any identifier the boost was given

Returns

  • Boolean true if a boost was removed

See also

Player:remove_attribute_boosts(attribute_id, identifier)

server plugins/stats/plugin/lib/sh_attributes.lua:741

Removes boosts from the player's character: all of them, those of one attribute, those with one identifier, or the boost of one attribute with one identifier. Server only.

target:remove_attribute_boosts()                    -- every boost
target:remove_attribute_boosts('strength')          -- every boost to strength
target:remove_attribute_boosts(nil, 'drunk')        -- 'drunk' boosts to any attribute
target:remove_attribute_boosts('strength', 'drunk') -- the 'drunk' boost to strength

Parameters

  • attribute_id String optional, defaults to nil only remove the boosts to this attribute
  • identifier Any optional, defaults to nil only remove the boosts with this identifier

Returns

  • Number amount of boosts removed

Player:roll_attribute(stat_id)

shared plugins/stats/plugin/lib/sh_rolls.lua:259

Rolls a stat for the player: a d20 plus the modifier of the stat, after the AdjustAttributeRoll hook.

local result = target:roll_attribute('strength')

if result and result.total >= 15 then
  door:Fire('Unlock')
end

Parameters

  • stat_id String ID of the stat

Returns

  • Map the result of Dice.roll, or nil and String the reason if nothing was rolled

Player:roll_skill(skill_id)

shared plugins/stats/plugin/lib/sh_rolls.lua:273

Rolls a skill for the player: a d20 plus the modifier of the skill, after the AdjustAttributeRoll hook.

Parameters

  • skill_id String ID of the skill

Returns

  • Map the result of Dice.roll, or nil and String the reason if nothing was rolled

See also

Player:set_attribute(attribute_id, level)

server plugins/stats/plugin/lib/sh_attributes.lua:671

Sets the player's level in an attribute, rounded and clamped to the attribute's min and max, and networks it. Server only.

Parameters

  • attribute_id String
  • level Number

See also

Player:set_skill(skill_id, rank)

server plugins/stats/plugin/lib/sh_skills.lua:285

Sets the player's rank in a skill, rounded and clamped between 0 and the skill's max, and networks it. Server only.

Parameters

  • skill_id String
  • rank Number

See also

Defined in