> ## Documentation Index
> Fetch the complete documentation index at: https://zyra-store.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Server exports

**Server exports** allow you to interact with Zyra Store scripts from the server side of your FiveM resource. Through these functions you can register players, read and write data, verify permissions, and access the script configuration, all without modifying Zyra Store's source code.

Remember that the standard syntax for invoking any export in Lua is:

```lua theme={null}
exports['resource-name']:FunctionName(args)
```

All exports documented on this page must be called exclusively from server-side scripts (`server.lua`).

***

## RegisterPlayer(source, data)

Registers or updates a player's data in the script's system. Call this function when a player connects or when you need to force an update of their information.

**source** `number` *required*

The FiveM server ID of the player (the `source` value in server events).

**data** `table` *required*

Table with the player data to register. Recommended fields:

| Field | Type | Description |
| - | - | - |
| `identifier` | string | Player's unique identifier |
| `name` | string | Player's in-game name |

**Returns** `boolean`

`true` if the registration was successful; `false` in case of error.

```lua other-resource/server.lua theme={null}
local ok = exports['zyra-mi-script']:RegisterPlayer(source, {
    identifier = GetPlayerIdentifierByType(source, 'license'),
    name       = GetPlayerName(source),
})
```

***

## GetConfig()

Returns the script's complete configuration table as defined in `config.lua`. Useful for reading script settings from an external resource without duplicating configuration values.

**Parameters** `none`

This function receives no parameters.

**Returns** `table`

The script's complete `Config` table, including all its fields and current values.

```lua other-resource/server.lua theme={null}
local config = exports['zyra-mi-script']:GetConfig()
print('Framework:', config.Framework)
print('Locale:', config.Locale)
```

***

## SetPlayerData(source, key, value)

Sets the value of a specific field in the data stored by the script for a player. You can use this function to write custom fields or update existing values in real time.

**source** `number` *required*

The FiveM server ID of the target player.

**key** `string` *required*

The name of the data field you want to modify (for example, `'customField'`).

**value** `any` *required*

The new value to assign to the field. Can be of any type compatible with Lua.

**Returns** `boolean`

`true` if the field was updated correctly; `false` if the player does not exist or there was an error.

```lua other-resource/server.lua theme={null}
exports['zyra-mi-script']:SetPlayerData(source, 'customField', 'value')
```

***

## GetPlayerData(source)

Returns the data stored on the server for a specific player. Returns `nil` if the player is not registered or is not connected.

**source** `number` *required*

The FiveM server ID of the player whose information you want to obtain.

**Returns** `table | nil`

A table with the player's data, or `nil` if the player was not found.

```lua other-resource/server.lua theme={null}
local data = exports['zyra-mi-script']:GetPlayerData(source)
if data then
    print('Identifier:', data.identifier)
end
```

***

## HasPermission(source, level)

Checks whether a player has a specific permission level according to the script's permission configuration. Use this function before executing restricted actions to make sure the player is authorized.

**source** `number` *required*

The FiveM server ID of the player you want to verify.

**level** `string` *required*

The permission level to check. Accepted values: `'admin'`, `'mod'`, `'vip'`.

**Returns** `boolean`

`true` if the player has the indicated permission level; `false` otherwise.

```lua other-resource/server.lua theme={null}
if exports['zyra-mi-script']:HasPermission(source, 'admin') then
    -- The player is an admin
end
```

***

> [!WARNING]
>
> Server exports can only be invoked from scripts that run on the **server side** (`server.lua` or files marked as `server` in the `fxmanifest.lua`). Calling a server export from a client script will cause a runtime error and the code will not execute correctly.

***

To see the available server-side events, visit the [server events reference](https://zyra-store.mintlify.site/en/reference/events/server-events.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.