# Server exports

> Read job data, manage employees and connect company payments from another server script.

All calls on this page run in a **server script** and use `exports["sky_jobs_base"]`. `playerId` means the online player's numeric server ID. `jobName` means the technical job name, such as `sunrise_cafe`.

## Job and duty

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Arguments
    </th>
    
    <th>
      Returns
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        getPlayerJobInfo(playerId)
      </code>
    </td>
    
    <td>
      Player server ID
    </td>
    
    <td>
      <code>
        { job, grade, gradeLabel, onDuty }
      </code>
      
      , or <code>
        nil
      </code>
      
       if unavailable
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        isPlayerOnDuty(playerId)
      </code>
    </td>
    
    <td>
      Player server ID
    </td>
    
    <td>
      <code>
        boolean
      </code>
      
      ; <code>
        false
      </code>
      
       when off duty or not loaded
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getOnDutyPlayers(jobName)
      </code>
    </td>
    
    <td>
      Technical job name
    </td>
    
    <td>
      Array of on-duty player server IDs
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        setPlayerDuty(playerId, onDuty)
      </code>
    </td>
    
    <td>
      Player server ID and <code>
        true
      </code>
      
       / <code>
        false
      </code>
    </td>
    
    <td>
      Whether the resulting duty state matches the request
    </td>
  </tr>
</tbody>
</table>

For example, restrict an external activity to on-duty cafe employees:

```lua [server.lua]
local job = exports["sky_jobs_base"]:getPlayerJobInfo(playerId)
if not job or job.job ~= "sunrise_cafe" or not job.onDuty then
    return
end

-- Continue your cafe-only action here.
```

Set duty from your own authorised clock-in or clock-out workflow:

```lua [server.lua]
local changed = exports["sky_jobs_base"]:setPlayerDuty(playerId, true) -- On duty
-- Pass false to clock out.
if not changed then
    print("The requested duty state could not be applied")
end
```

Use the authenticated player's server ID. See [Duty](/docs/base/jobs-base/server-exports/duty) for the complete reference.

## Employees

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Arguments
    </th>
    
    <th>
      Returns
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        setJobMember(jobName, playerOrIdentifier, grade?)
      </code>
    </td>
    
    <td>
      Job, online server ID or offline character identifier, optional grade
    </td>
    
    <td>
      <code>
        success, error?
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        removeJobMember(jobName, playerOrIdentifier)
      </code>
    </td>
    
    <td>
      Job and online server ID or offline character identifier
    </td>
    
    <td>
      <code>
        success, error?
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getJobMembers(jobName)
      </code>
    </td>
    
    <td>
      Technical job name
    </td>
    
    <td>
      Array of employee records
    </td>
  </tr>
</tbody>
</table>

`setJobMember` hires a player or changes an existing employee's grade. If the grade is omitted, it uses the job's lowest grade. Preserve actual grade numbers, including gaps.

```lua [server.lua]
-- Run after your hiring system has authorised the application.
local success, errorMessage = exports["sky_jobs_base"]:setJobMember("sunrise_cafe", playerId)
if not success then
    print(("Hiring failed: %s"):format(errorMessage))
end
```

See [Players & members](/docs/base/jobs-base/server-exports/players-members) for employee record fields and offline examples.

## Company accounts

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Arguments
    </th>
    
    <th>
      Returns
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        getJobMoney(jobName)
      </code>
    </td>
    
    <td>
      Technical job name
    </td>
    
    <td>
      Current balance; <code>
        0
      </code>
      
       for an invalid job
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        addJobMoney(jobName, amount)
      </code>
    </td>
    
    <td>
      Job and positive whole amount
    </td>
    
    <td>
      Success as <code>
        boolean
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        removeJobMoney(jobName, amount)
      </code>
    </td>
    
    <td>
      Job and positive whole amount
    </td>
    
    <td>
      Success as <code>
        boolean
      </code>
    </td>
  </tr>
</tbody>
</table>

For example, credit the company after a sale confirmed by your server script:

```lua [server.lua]
local credited = exports["sky_jobs_base"]:addJobMoney("sunrise_cafe", 250)
```

Check the result before confirming the transaction to the player. Calculate prices and rewards on the server. See [Society money](/docs/base/jobs-base/server-exports/society-money) for details.

## Billing

Use `CreateInvoice(request)` to issue an invoice from your own service workflow. It returns `{ success = true, data = invoice }` or `{ success = false, error = code }`.

The [Billing reference](/docs/base/jobs-base/server-exports/billing) covers the full request, player/company recipients, payment modes, employee shares and the `sky_jobs_base:billing:changed` server event. Successful invoice creation does not mean the invoice was paid; check its payment status.

## Salary

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Returns
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        pausePlayerSalary(playerId)
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        resumePlayerSalary(playerId)
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        isPlayerSalaryPaused(playerId)
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getGradeSalary(jobName, grade)
      </code>
    </td>
    
    <td>
      Salary amount, interval in minutes
    </td>
  </tr>
</tbody>
</table>

The pause state lasts until resumed or the player disconnects. See [Salary](/docs/base/jobs-base/server-exports/salary).

## Business and announcements

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Use
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        GetBusinessState(jobName)
      </code>
    </td>
    
    <td>
      Read opening state and configured blip values; <code>
        nil
      </code>
      
       if unavailable
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GetBusinessContext(playerId)
      </code>
    </td>
    
    <td>
      Read the employee's authorised Business context
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GetBusinessHistory(playerId, request)
      </code>
    </td>
    
    <td>
      Read announcement history for the employee's current job
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SubmitBusinessAnnouncement(playerId, request)
      </code>
    </td>
    
    <td>
      Publish as an employee, with duty, permission and cooldown checks
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SetBusinessOpen(jobName, open, message?, announce?, actorId?)
      </code>
    </td>
    
    <td>
      Change opening state from trusted server automation; <code>
        true
      </code>
      
       or <code>
        false, reason
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        BroadcastBusinessAnnouncement(jobName, kind, message?, actorId?)
      </code>
    </td>
    
    <td>
      Publish from trusted server automation; <code>
        true
      </code>
      
       or <code>
        false, reason
      </code>
    </td>
  </tr>
</tbody>
</table>

For player actions use `SubmitBusinessAnnouncement` with the authenticated handler's player ID. `actorId` on the automation exports only supplies history context. See [Business](/docs/base/jobs-base/server-exports/business) for request fields and error codes.

## Storage

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Returns
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        GetStorageItemCount(stationId, jobName, grade, itemName)
      </code>
    </td>
    
    <td>
      Item count; <code>
        0
      </code>
      
       if missing
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        RemoveStorageItem(stationId, jobName, grade, itemName, amount)
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        AddStorageItem(stationId, jobName, grade, itemName, amount, metadata?)
      </code>
    </td>
    
    <td>
      <code>
        success, reason?
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        AddStorageItems(stationId, jobName, grade, items)
      </code>
    </td>
    
    <td>
      <code>
        success, reason?
      </code>
    </td>
  </tr>
</tbody>
</table>

Use the storage point's actual ID and authorise the supplied job/grade in your server script. These calls operate on shared station storage. See [Storage](/docs/base/jobs-base/server-exports/storage) for capacity, metadata and batch examples.

## Vehicles and deliveries

Use `registerExternalVehicle(plate, jobName, model, netId?, ownerSource?, trunkCapacity?)` after your external garage spawns a job vehicle, and `unregisterExternalVehicle(plate)` when it is removed. See [External garage integration](/docs/base/jobs-base/server-exports/external-garage-integration) for the complete spawn/cleanup example and accepted values.

For delivery scripts, use the [Wholesale orders](/docs/base/jobs-base/server-exports/wholesale-orders) exports to read, accept, reject and complete orders. Completing an order and depositing stock are separate operations; persist which delivery you completed before allowing it to run again.

## Permissions and events

`hasJobPermission(playerId, permission, jobName?)` checks a registered employee permission. Use the exact permission keys from [Permissions](/docs/base/jobs-base/server-exports/permissions).

React to job, duty, employee and invoice changes with [Events](/docs/base/jobs-base/events). These notifications let your integration update when something changes, without repeatedly polling exports.

## More server integrations

- [Business status and announcements](/docs/base/jobs-base/server-exports/business)
- [Rank and unit permissions](/docs/base/jobs-base/server-exports/permissions)
- [Salary settings](/docs/base/jobs-base/server-exports/salary)
- [Storage](/docs/base/jobs-base/server-exports/storage)
- [External garage integration](/docs/base/jobs-base/server-exports/external-garage-integration)
