# Exports

Here you will find all the useful exports for this asset, please read each step and example carefully to better understand how it works, we do not recommend using these if you are not an experienced developer.

{% hint style="warning" %}
REMEMBER ABOUT CLIENT SIDE AND SERVER SIDE IN CHOOSING EXPORT!
{% endhint %}

***

## GetDutyData

To fetch player duty data you need to use following export.

{% tabs %}
{% tab title="Client Side" %}

```lua
exports['piotreq_jobcore']:GetDutyData()
```

{% endtab %}

{% tab title="Server Side" %}

* identifier `string`

```lua
exports['piotreq_jobcore']:GetPlayerDutyData(identifier)
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Client Side" %}

```lua
local data = exports['piotreq_jobcore']:GetDutyData()
print(json.encode(data, {indent=true}))

--[[
    {
        "status": 1,
    }
]]
```

{% endtab %}

{% tab title="Server Side" %}

```lua
local data = exports['piotreq_jobcore']:GetPlayerDutyData('char1:12345678')
print(json.encode(data, {indent=true}))

--[[
    {
        "identifier": "char1:12345678",
        "player": 10,
        "job": "police",
        "status": 1,
        "time": 500,
    }
]]
```

{% endtab %}
{% endtabs %}

***

## DutyPlayersTrigger

You can use this export to trigger some client event for players with specific job.

{% tabs %}
{% tab title="Server Side" %}

* eventName `string`
* data `any` (args for event)
* job `string`
* online? `boolean` (if true then only trigger for players which are on duty else all players in table

```lua
exports['piotreq_jobcore']:DutyPlayersTrigger(eventName, data, job, online)
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

<pre class="language-lua"><code class="lang-lua"><strong>local eventName = 'restaurants:refreshOrders'
</strong>local data = {'Order'}
local job = 'burgershot'
local online = true
<strong>
</strong><strong>exports['piotreq_jobcore']:DutyPlayersTrigger(eventName, data, job, online)
</strong></code></pre>

{% endtab %}
{% endtabs %}

***

## On Duty Update

With this event handler you are able to follow player duty updates.

{% tabs %}
{% tab title="Client Side" %}

```lua
AddEventHandler('piotreq_jobcore:UpdateDuty', function(data)
    print(json.encode(data))
end)
```

{% endtab %}

{% tab title="Server Side" %}

```lua
AddEventHandler('piotreq_gpt:UpdateDuty', function(player, data)
    print(player, json.encode(data))
end)
```

{% endtab %}
{% endtabs %}

***

## ResetDutyTimer

You can use this export to reset duty time for specific player.

{% tabs %}
{% tab title="Server Side" %}

* identifier `string`

```lua
exports['piotreq_jobcore']:ResetDutyTimer(identifier)
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

```lua
exports['piotreq_jobcore']:ResetDutyTimer('char:12345678')
```

{% endtab %}
{% endtabs %}

***

## ResetDutyTimers

With this export you can reset duty time for all players in specific job.

{% tabs %}
{% tab title="Server Side" %}

* job `string`
* type `string` ("all", "online", "offline")

```lua
exports['piotreq_jobcore']:ResetDutyTimers({
   job = job,
   type = type
})
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

```lua
exports['piotreq_jobcore']:ResetDutyTimers({
   job = 'police',
   type = 'all'
})
```

{% endtab %}
{% endtabs %}

***

## ToggleDuty

You can use following trigger to toggle duty status

{% tabs %}
{% tab title="Client Side" %}

* duty `number` (0 = off duty, 1 = on duty, 2 = break)

```lua
TriggerServerEvent('piotreq_jobcore:SwitchDuty', {duty = 1})
```

{% endtab %}

{% tab title="Server Side" %}

* duty `number` (0 = off duty, 1 = on duty, 2 = break)
* playerId `number`

```lua
exports['piotreq_jobcore']:SwitchDuty(playerId, {duty = 1})
```

{% endtab %}
{% endtabs %}

***

## FormatDutyTime

Use following export to receive formatted duty time

{% tabs %}
{% tab title="Server Side" %}

* time `number`

```lua
exports['piotreq_jobcore']:FormatDutyTime(time)
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

```lua
local time = 100
local formattedTime = exports['piotreq_jobcore']:FormatDutyTime(time)
print(formattedTime)
```

{% endtab %}
{% endtabs %}

***

## SavePlayerDutyTime

You can use this export to save player duty time manually.

{% tabs %}
{% tab title="Server Side" %}

* identifier `string`
* time `number`

```lua
exports['piotreq_jobcore']:SavePlayerDutyTime(identifier, time)
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

```lua
local identifier = 'char:123456789' -- replace it with player identifier
local time = 100 -- replace it with player duty time

exports['piotreq_jobcore']:SavePlayerDutyTime(identifier, time)
```

{% endtab %}
{% endtabs %}

***

## isPlayerOnDuty

You can check if specific player is on duty with this export.

{% tabs %}
{% tab title="Server Side" %}

* identifier `string`

```lua
exports['piotreq_jobcore']:isPlayerOnDuty(identifier)
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

```lua
local identifier = 'char:123456789' -- replace this with player identifier

local result = exports['piotreq_jobcore']:isPlayerOnDuty(identifier)
print(result)
```

{% endtab %}
{% endtabs %}

***

## GetJobDutyPlayers

With this export you are able to get all online players with specific job

{% tabs %}
{% tab title="Server Side" %}

* job `string`

```lua
exports['piotreq_jobcore']:GetJobDutyPlayers(job)
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

```lua
local job = 'police'
local players = exports['piotreq_jobcore']:GetJobDutyPlayers(job)
print(json.encode(players, {indent=true}))
```

{% endtab %}
{% endtabs %}

***

## GetAllDutyPlayers

This export will get all online players with job from config

{% tabs %}
{% tab title="Server Side" %}

```lua
exports['piotreq_jobcore']:GetAllDutyPlayers()
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

```lua
local players = iotreq_jobcore']:GetAllDutyPlayers()
print(json.encode(players, {indent=true}))
```

{% endtab %}
{% endtabs %}

***

## SetPlayerDutyData

{% tabs %}
{% tab title="Server Side" %}

* identifier `string`
* data `table`
* playerId `string`
* jobName `string`
* status `number`
* time `number`
* startTime? `number`

```lua
exports['piotreq_jobcore']:SetPlayerDutyData(identifier, {
   identifier = identifier,
   player = playerId,
   job = jobName,
   status = status,
   time = time,
   startTime = startTime
})
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

```lua
local identifier = 'char1:1234578' -- replace this with player identifier
local playerId = 1 -- replace it with player id
local jobName = 'police' -- replace it with player job
local status = 1 -- (0 = off duty, 1 = on duty, 2 = on break)
local time = 100 -- replace it with player duty time
local startTime = os.time() -- should be os.time every time

exports['piotreq_jobcore']:SetPlayerDutyData(identifier, {
   identifier = identifier,
   player = playerId,
   job = jobName,
   status = status,
   time = time,
   startTime = startTime
})
```

{% endtab %}
{% endtabs %}

***

## GetJobActivePlayers

This export will return on duty players count from specific job / jobs.

{% tabs %}
{% tab title="undefined" %}

* job `string / table`&#x20;

```lua
exports['piotreq_jobcore']:GetJobActivePlayers(job)
```

{% endtab %}
{% endtabs %}

### Example of Usage

{% tabs %}
{% tab title="Server Side" %}

```lua
local job = 'police'
-- local job = {'police', 'ambulance', 'sheriff'} -- it can be table

local count = exports['piotreq_jobcore']:GetJobActivePlayers(job)
print(count)
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://piotreq-scripts.gitbook.io/piotreq-scripts/assets-and-guides/job-core/exports.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
