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

# Server Exports

Here, you'll discover all the handy exports for this asset. Please take the time to read through each step and example carefully to grasp how they function. We advise against using these exports if you're not an experienced developer.

***

## open

This export opens the MDT interface for a specific player.

```lua
exports['redutzu-mdt']:open(source)
```

Here's how you can utilize this export:

```lua
RegisterCommand('open_mdt', function(source)
    exports['redutzu-mdt']:open(source)
end, false)
```

***

## isAllowed

This export verifies if a player has the job necessary to open the MDT.

```lua
exports['redutzu-mdt']:isAllowed(source)
```

Here's how you can utilize this export:

{% code overflow="wrap" %}

```lua
RegisterCommand('example', function(source)
    local allowed = exports['redutzu-mdt']:isAllowed(source)

    if allowed then
        -- Do something if the player is allowed to open the MDT
    end
end, false)
```

{% endcode %}

***

## isJobWhitelisted

This export checks if at least one job is whitelisted.

```lua
exports['redutzu-mdt']:isJobWhitelisted(jobs) -- table or string
```

Here's how you can utilize this export:

```lua
RegisterNetEvent('dispatchEvent', function(data)
    local isWhitelisted = exports['redutzu-mdt']:isJobWhitelisted(data.jobs)

    if isWhitelisted then
        -- data.jobs includes one of the whitelisted jobs from Config.WhitelistedJobs
    end
end)
```

***

## hasPermission

This export verifies if a player has a specific permission.

```lua
exports['redutzu-mdt']:hasPermission(source, permission)
```

Here's how you can utilize this export:

```lua
RegisterCommand('pin_announcement', function(source)
    local hasPerm = exports['redutzu-mdt']:hasPermission(source, 'announcements.pin')
    
    if hasPerm then
        print('The player can pin announcements')    
    end
end, false)
```

***

## GetOfficerCallsign

This export retrieves the callsign of a player.

```lua
exports['redutzu-mdt']:GetOfficerCallsign(source)
```

Here's how you can utilize this export:

```lua
RegisterCommand('callsign', function(source)
    local callsign = exports['redutzu-mdt']:GetOfficerCallsign(source)
    
    if callsign then
        print('Callsign: ' .. callsign)    
    else
        print('No callsign')
    end
end, false)
```

***

## SetOfficerCallsign

This export modifies the callsign of a player.

```lua
exports['redutzu-mdt']:SetOfficerCallsign(source, callsign)
```

Here's how you can utilize this export:

```lua
RegisterCommand('change_callsign', function(source)
    exports['redutzu-mdt']:SetOfficerCallsign(source, 'ABC123')
end, false)
```

***

## GetOfficerStatus

This export retrieves the status of a player.

```lua
exports['redutzu-mdt']:GetOfficerStatus(source)
```

Here's how you can utilize this export:

```lua
RegisterCommand('status', function(source)
    local status = exports['redutzu-mdt']:GetOfficerStatus(source) -- 0, 1, 2, 3
    -- if you are using this code inside the MDT you can do:
    local statusName = Config.Statuses[status]?.label
    print('Current status: ' .. statusName )
end, false)
```

***

## SetOfficerStatus

This export updates the status of a player.

```lua
exports['redutzu-mdt']:SetOfficerStatus(source, status) -- status: keyof Config.Statuses
```

Here's how you can utilize this export:

```lua
RegisterCommand('change_status', function(source, args)
    local status = args[1] -- must be 0, 1, 2 or 3
    exports['redutzu-mdt']:SetOfficerStatus(source, status)
end, false)
```

***

## IsDuty

This export indicates whether the player is on duty or not.

```lua
exports['redutzu-mdt']:IsDuty(source)
```

Here's how you can utilize this export:

```lua
RegisterCommand('duty', function(source)
    local isDuty = exports['redutzu-mdt']:IsDuty(source)
    print('Player is ' .. isDuty and 'on duty' or 'off duty')
end, false)
```

***

## SetDuty

This export modifies the duty state of a player.

```lua
exports['redutzu-mdt']:SetDuty(source, state)
```

Here's how you can utilize this export:

```lua
RegisterCommand('toggleDuty', function(source)
    local isDuty = exports['redutzu-mdt']:IsDuty(source)
    exports['redutzu-mdt']:SetDuty(source, not isDuty)
end, false)
```


---

# 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://docs.redutzu.com/resources/redutzu-mdt/exports-events/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.
