> For the complete documentation index, see [llms.txt](https://docs.vames-store.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vames-store.com/assets/vms_needs/developer-api/server-exports.md).

# Server Exports

### GetStatus

Returns a status controller for the specified player and status.

```lua
---@param {source: number}: Player Server ID
---@param {statusName: string}: Status name defined in Config.Statuses
---@return {status: table}: Status controller with Set, GetPercentage, Add and Remove functions
local status = exports['vms_needs']:GetStatus(source, statusName)
```

<details>

<summary><strong>Example Usage</strong></summary>

```lua
local hunger = exports['vms_needs']:GetStatus(1, 'hunger')

hunger.Set(300)

print(hunger.GetPercentage())

hunger.Add(50)
hunger.Remove(25)
```

</details>

<details>

<summary><strong>Returned Functions</strong></summary>

```lua
{
    Set = function(value)
        -- Sets the raw status value.
    end,

    GetPercentage = function()
        -- Returns the current status value as a percentage from 0 to 100.
    end,

    Add = function(value)
        -- Adds the specified value to the status.
    end,

    Remove = function(value)
        -- Removes the specified value from the status.
    end,
}
```

</details>

***

### GetPercentageStatus

Returns the current status value as a percentage (0-100).

```lua
---@param {source: number}: Player Server ID
---@param {statusName: string}: Status name defined in Config.Statuses
---@return {statusPercentage: number}: Current status value as a percentage (0-100)
local statusPercentage = exports['vms_needs']:GetPercentageStatus(source, statusName)
```

***

### SetStatus

Sets the raw value of the specified player status.

```lua
---@param {source: number}: Player Server ID
---@param {statusName: string}: Status name defined in Config.Statuses
---@param {value: number}: New raw status value
exports['vms_needs']:SetStatus(source, statusName, value)
```

***

### AddStatus

Adds a raw value to the specified player status.

```lua
---@param {source: number}: Player Server ID
---@param {statusName: string}: Status name defined in Config.Statuses
---@param {value: number}: Raw status value to add
exports['vms_needs']:AddStatus(source, statusName, value)
```

***

### RemoveStatus

Removes a raw value from the specified player status.

```lua
---@param {source: number}: Player Server ID
---@param {statusName: string}: Status name defined in Config.Statuses
---@param {value: number}: Raw status value to remove
exports['vms_needs']:RemoveStatus(source, statusName, value)
```

***

### CleanupOptionalStatuses

Clear all statuses if they are marked as `isOptional` in `Config.Statuses`.

```lua
---@param {source: number}: Player Server ID
exports['vms_needs']:CleanupOptionalStatuses(source)
```

***

### SaveStatus

Saves the status data for the specified player or all online players.

```lua
---@param {source: number | nil}: Player Server ID or nil to save all online players.
exports['vms_needs']:SaveStatus(source)
```

***

### GetServerTemperature

Returns the current server temperature.

```lua
local tempreature = exports['vms_needs']:GetServerTemperature()
```
