Summary

Methods

Returns the attribute points of the player's character that have not been spent yet.
Returns the experience the player's character has gathered toward its next level, which may be more than the level needs while the character is at the level cap.
Returns the experience the player's character still needs to reach its next level.
Returns the level of the player's character.
Returns the skill points of the player's character that have not been spent yet.
Gives the player's character experience.
Sets the level of the player's character and resets its experience to 0.
Spends one unspent attribute point of the player's character on a stat of the Stats plugin, raising it by one level.
Spends one unspent skill point of the player's character on a skill of the Stats plugin, raising it by one rank.

Methods

Player:get_attribute_points()

shared plugins/levels/plugin/lib/sh_levels.lua:713

Returns the attribute points of the player's character that have not been spent yet. On the client only the local player's points are known.

Returns

  • Number

Player:get_experience()

shared plugins/levels/plugin/lib/sh_levels.lua:683

Returns the experience the player's character has gathered toward its next level, which may be more than the level needs while the character is at the level cap. On the client this is what the server has networked, which it does for the local player alone.

Returns

  • Number; 0 when the player has no character, is at the highest level or, on the client, is not the local player

Player:get_experience_to_level()

shared plugins/levels/plugin/lib/sh_levels.lua:699

Returns the experience the player's character still needs to reach its next level.

Returns

  • Number; 0 at the highest level

Returns the level of the player's character. On the client this is what the server has networked, which it does for the local player alone.

Returns

  • Number between 1 and the highest level; 1 when the player has no character or, on the client, is not the local player

Player:get_skill_points()

shared plugins/levels/plugin/lib/sh_levels.lua:706

Returns the skill points of the player's character that have not been spent yet. On the client only the local player's points are known.

Returns

  • Number

Player:give_experience(amount, reason, ignore_cap)

server plugins/levels/plugin/lib/sh_levels.lua:736

Gives the player's character experience. Whenever the experience reaches what the level needs, the character goes up a level and keeps the rest, as many times as the amount allows, but never past the level cap (Levels.get_level_cap): a character at the cap keeps all the experience it is given, even more than the level needs, and spends it on levels once the cap rises (Levels.catch_up). A negative amount takes experience away and takes levels back once the experience falls below 0, down to level

  1. At the highest level no experience is kept. The player is told about every level gained. Server only.
target:give_experience(250, 'quest')

Parameters

  • amount Number experience, rounded; negative to take experience away
  • reason String optional, defaults to nil what the experience is for, passed on to the PlayerExperienceChanged hook
  • ignore_cap Boolean optional, defaults to false level up past the level cap, as far as the highest level; the staff commands do this

Returns

  • Boolean true if the level or the experience has changed

See also

Player:set_level(level)

server plugins/levels/plugin/lib/sh_levels.lua:769

Sets the level of the player's character and resets its experience to 0. The unspent skill and attribute points are worked out again for the new level, so they grow or shrink with it; points that were already spent stay spent. Server only.

Parameters

  • level Number new level, rounded and kept between 1 and the highest level

Returns

  • Boolean true if the level or the experience has changed

See also

Player:spend_attribute_point(stat_id)

server plugins/levels/plugin/lib/sh_levels.lua:866

Spends one unspent attribute point of the player's character on a stat of the Stats plugin, raising it by one level. Refused when the stat is not registered or is hidden, the character has no attribute points left or the stat is at its highest level. Server only.

Parameters

  • stat_id String attribute ID of the stat

Returns

  • Boolean true if the point was spent
  • String phrase of the reason otherwise: 'error.levels.no_active_character', 'error.levels.invalid_stat', 'error.levels.no_attribute_points', 'error.levels.stat_maxed' or 'error.levels.cannot_raise'

Player:spend_skill_point(skill_id)

server plugins/levels/plugin/lib/sh_levels.lua:849

Spends one unspent skill point of the player's character on a skill of the Stats plugin, raising it by one rank. Refused when the skill is not registered or is hidden, the character has no skill points left or the skill is at its highest rank. Server only.

Parameters

  • skill_id String ID of the skill

Returns

  • Boolean true if the point was spent
  • String phrase of the reason otherwise: 'error.levels.no_active_character', 'error.levels.invalid_skill', 'error.levels.no_skill_points', 'error.levels.skill_maxed' or 'error.levels.cannot_raise'

Defined in