Skill Management
Unturned tracks each player's skills and experience through the game's skill system. RocketMod exposes four methods on UnturnedPlayer for working with skills, plus an Experience property for reading and writing the player's experience balance. The finer-grained skill data model (categories, the Skill struct, the PlayerSkills component) lives in the SDG.Unturned layer, not in the RocketMod API surface, so this article covers only the RocketMod endpoints you can call directly.
This article documents the UnturnedPlayer skill methods, the Experience property, and the UnturnedSkill class that exists in the RocketMod namespace.
Prerequisites
- Articles 1 through 7 (Fundamentals track), especially article 6 (Event Subscription and Lifecycle) for event-driven skill management.
- Article 29 (Join Validation and Connection Filtering) for context on player lifecycle timing.
What you will learn
- The four skill-related methods on
UnturnedPlayer:GetSkill,GetSkillLevel,SetSkillLevel, andMaxSkills. - How to read and set a player's experience through the
Experienceproperty. - That the
UnturnedSkillclass exists inRocket.Unturned.Skills.
UnturnedPlayer skill methods
The UnturnedPlayer class (namespace Rocket.Unturned.Player) exposes four methods for working with player skills. The parameter signatures below reflect the return types visible in the API surface; full parameter lists are drawn from the SDG.Unturned layer and are not captured here.
| Method | Return type | What it does |
|---|---|---|
GetSkill(Skill) | Skill | Returns a Skill reference for the player. The Skill type comes from the SDG layer. |
GetSkillLevel(byte) | byte | Returns the current level of a skill as a byte value. |
SetSkillLevel(void) | void | Sets the level of a skill for the player. |
MaxSkills(void) | void | Maximises all of the player's skills in one call. |
These are the only skill-related members on UnturnedPlayer confirmed present in the RocketMod API surface. There is no EPlayerSkill enum, no PlayerSkills component, and no skills array in the RocketMod surface -- those belong to the SDG.Unturned layer.
Basic usage
csharp
using Rocket.Unturned.Player;
UnturnedPlayer player = UnturnedPlayer.FromName("Notch");
if (player == null)
return;
// Read a skill (returns a Skill object from the SDG layer)
var skill = player.GetSkill(/* Skill parameter */);
// Read a skill level (returns a byte)
byte level = player.GetSkillLevel(/* byte parameter */);
// Set a skill level
player.SetSkillLevel(/* parameters */);
// Max all skills
player.MaxSkills();The Skill parameter on GetSkill, and the Skill return type, both refer to a type in the SDG.Unturned layer. This type is not present in the RocketMod API surface, so its members (level, name, etc.) are not documented here.
Experience property
UnturnedPlayer has an Experience property you can read and write directly:
| Property | Type | Description |
|---|---|---|
Experience | uint | The player's current experience point balance. Readable and writable. |
csharp
using Rocket.Unturned.Player;
UnturnedPlayer player = UnturnedPlayer.FromName("Notch");
if (player == null)
return;
// Read experience
uint currentXp = player.Experience;
// Set experience
player.Experience = 5000;
// Grant experience
player.Experience += 250;Unlike the skill methods, Experience is a plain property. RocketMod does not expose helper methods such as GrantExperience, DeductExperience, or SetExperience -- you manipulate the property directly.
UnturnedSkill class
The Rocket.Unturned.Skills namespace contains an UnturnedSkill class at Rocket.Unturned/Skills/UnturnedSkill.cs. The API surface extraction confirms the class exists but does not list any methods, properties, or events on it. Its role relative to the UnturnedPlayer skill methods is not fully captured by the surface.
Edge cases
Player not found
UnturnedPlayer.FromName(string) returns null when no player matches. Always check for null before calling skill methods:
csharp
UnturnedPlayer player = UnturnedPlayer.FromName("Notch");
if (player == null)
{
Rocket.Core.Logging.Logger.Log("Player not found.");
return;
}Player not spawned
The UnturnedPlayer.Player property accesses the underlying player GameObject. Early in the connection lifecycle (during OnBeforePlayerConnected or immediately after OnPlayerConnected), the player's character may not have spawned yet and Player may be null. Delay skill access until the character is ready.
Frequently asked questions
Do skill changes persist across server restarts?
Yes. Unturned saves player data -- including skills and experience -- to the player's character save file. Changes made through the UnturnedPlayer methods are included in that save.
Can I modify skills for an offline player?
Not through the UnturnedPlayer API. The UnturnedPlayer object exists only for players currently connected to the server. Offline skill modification would require editing the player's save file directly, which is a binary format that changes between Unturned versions.
Cross-references
- Join Validation and Connection Filtering -- the previous article; player lifecycle timing.
- Scheduling Tasks and Background Work -- the next article; running skill-related work on a timer.
- Plugin Lifecycle and Event Subscription -- when to access skills during the player lifecycle.
- Plugin Configuration Files -- storing limits and thresholds in configuration.
What changed in this revision
- Removed the
EPlayerSkillenum and skill categories table (type not found in RocketMod API surface). - Removed the
PlayerSkillscomponent access chain (player.Player.skills),Skillstruct field descriptions, andSendSkill/SendExperiencemethods (all SDG.Unturned types, not in RocketMod API surface). - Removed invented helper methods:
GrantExperience,DeductExperience,SetExperience,GetExperience,ApplyPreset,ResetSkills,CalculateTotalExperienceSpent,EnforceSkillCaps,FormatSkillSummary. - Removed the
SkillIndiceshelper class,SkillCapsConfiguration, andSkillPresettypes (all invented, not in API surface). - Removed the skill preset command example (used
R.Permissions.HasPermissionwhich does not exist on theRclass in the real API). - Removed the
IsConnectededge case guard (IsConnectedis not a property onUnturnedPlayerin the API surface). - Removed the experience overflow guard (referenced
skills.experience, an SDG type not in the RocketMod surface). - Removed FAQ entries relying on
EPlayerSkillor unverifiable skill data model claims. - Retained and documented only the four confirmed
UnturnedPlayerskill methods, theExperienceproperty, and theUnturnedSkillclass.
