> ## Documentation Index
> Fetch the complete documentation index at: https://docs.awokenlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exports

> Read a driver's shift and stats from your own scripts.

All three are server-side and read-only. They are for scripts that want to know what a courier is doing, such as blocking another job while someone is on shift.

## hasActiveContract

```lua theme={"dark"}
local onShift = exports.awoken_courier:hasActiveContract(src)
```

`true` while the player is on a shift.

## getActiveContract

```lua theme={"dark"}
local shift = exports.awoken_courier:getActiveContract(src)
if shift then
    print(shift.state, shift.payout)
end
```

Returns `nil` when the player is not on a shift, otherwise:

| Field | Meaning |
| - | - |
| `contractId` | The route being run |
| `packages` | The parcels on this shift |
| `payout` | The route's base payout |
| `state` | `'assigned'` while loading at the depot, `'loaded'` while on route, `'returning'` on the way back |

It is a copy, so changing it does not change the shift.

## getStats

```lua theme={"dark"}
local stats = exports.awoken_courier:getStats(src)
-- { completed = 42, earned = 61500 }
```

Lifetime deliveries completed and money earned. Both are `0` for a player with no history.

## Example

Stop a player starting your own job while they are mid delivery:

```lua theme={"dark"}
RegisterNetEvent('my_job:start', function()
    local src = source
    if exports.awoken_courier:hasActiveContract(src) then
        exports.awoken_bridge:Notify(src, 'Finish your delivery shift first.', 'error')
        return
    end
    -- start the job
end)
```

## Restricting the app with your own rule

To decide who sees the courier app from your own script, use `callbackGate` in the [configuration](/resources/awoken-courier/configuration#who-sees-the-app). The tablet calls your export and shows the app when it returns `true`.

```lua theme={"dark"}
exports('canUseCourier', function(src)
    return isEmployee(src)
end)
```


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