> For the complete documentation index, see [llms.txt](https://mythic-scripts.gitbook.io/mythic-scripts-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mythic-scripts.gitbook.io/mythic-scripts-documentation/resources/multicharacter-and-identity-creation/server-exports.md).

# Server Exports

### AddXP

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:AddXP(src, amount)
```

{% endcode %}

Adds XP to the player. Recomputes the level and automatically distributes the SP/AP from any crossed tiers (Config.SkillPoints / Config.AttributePoints). Syncs the level (weapon lock) and the UI.

**Returns:**

* newXp (number) — total XP after the add
* newLevel (number)
* leveledUp (boolean) — true if the player gained at least one level

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
local xp, level, up = exports["ms_skills"]:AddXP(source, 250)
if up then print(("%s reached level %d"):format(GetPlayerName(source), level)) end
```

{% endcode %}

</details>

***

### RemoveXP

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:RemoveXP(src, amount)
```

{% endcode %}

Removes XP (never below 0). Recomputes the level. Does not remove already-granted SP/AP (losing a level does not claw back spendable points).

**Returns:**

* newXp (number)
* newLevel (number)
* leveledUp (boolean) — always false here

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
local xp = exports["ms_skills"]:RemoveXP(source, Config.ShotXPLoss)
```

{% endcode %}

</details>

***

### SetXP

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:SetXP(src, amount)
```

{% endcode %}

Sets XP to an exact value. If the new value raises the level, tier rewards are distributed.

**Returns:**

* newXp (number)
* newLevel (number)
* leveledUp (boolean)

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:SetXP(source, 0) -- 0 = reset XP
```

{% endcode %}

</details>

***

### GetXP

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:GetXP(src)
```

{% endcode %}

Reads XP, level and progress within the current level.

**Returns:**

* xp (number | nil) — nil if the player is not loaded
* level (number)
* progress (table) — { level, current, needed, max, totalXp }

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
local xp, level, p = exports["ms_skills"]:GetXP(source)
print(("Lvl %d — %d/%d"):format(level, p.current, p.needed))
```

{% endcode %}

</details>

***

### GetLevel

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:GetLevel(src)
```

{% endcode %}

Current level of the player.

**Returns:**

* level (number | nil)

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
if (exports["ms_skills"]:GetLevel(source) or 0) >= Config.LevelForGuns then
    -- allow the weapon
end
```

{% endcode %}

</details>

### SetLevel

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:SetLevel(src, level)
```

{% endcode %}

Sets the level directly (admin use). XP is snapped to the lower threshold of the target level. If it's a level-up, intermediate tier rewards are distributed.

**Returns:**

* newXp (number)
* newLevel (number)
* leveledUp (boolean)

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:SetLevel(source, 10)
```

{% endcode %}

</details>

***

### AddSkillPoints

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:AddSkillPoints(src, amount)
```

{% endcode %}

Adds Skill Points to the player's spendable pool. Syncs the UI.

**Returns:**

* newTotal (number | false) — false if the player is not loaded

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:AddSkillPoints(source, 2)
```

{% endcode %}

</details>

***

### RemoveSkillPoints

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:RemoveSkillPoints(src, amount)
```

{% endcode %}

Removes Skill Points. Fails if the balance is insufficient (nothing is removed).

**Returns:**

* ok (boolean) — false if insufficient balance or player not loaded
* newTotal (number)

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
local ok, total = exports["ms_skills"]:RemoveSkillPoints(source, 1)
if not ok then print("Not enough SP") end
```

{% endcode %}

</details>

***

### GetSkillPoints

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:GetSkillPoints(src)
```

{% endcode %}

**Returns:**

* skillPoints (number | nil)

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
local sp = exports["ms_skills"]:GetSkillPoints(source)
```

{% endcode %}

</details>

***

### AddAttributePoints

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:AddAttributePoints(src, amount)
```

{% endcode %}

Adds Attribute Points to the player's spendable pool. Syncs the UI.

**Returns:**

* newTotal (number | false)

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:AddAttributePoints(source, 25)
```

{% endcode %}

</details>

***

### RemoveAttributePoints

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:RemoveAttributePoints(src, amount)
```

{% endcode %}

Removes Attribute Points. Fails if the balance is insufficient.

**Returns:**

* ok (boolean)
* newTotal (number)

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
local ok, total = exports["ms_skills"]:RemoveAttributePoints(source, 10)
```

{% endcode %}

</details>

***

### GetAttributePoints

{% code overflow="wrap" expandable="true" %}

```lua
exports["ms_skills"]:GetAttributePoints(src)
```

{% endcode %}

**Returns:**

* attributePoints (number | nil)

<details>

<summary>Example</summary>

{% code overflow="wrap" expandable="true" %}

```lua
local ap = exports["ms_skills"]:GetAttributePoints(source)
```

{% endcode %}

</details>

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mythic-scripts.gitbook.io/mythic-scripts-documentation/resources/multicharacter-and-identity-creation/server-exports.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
