# Documents

> View your own document, inspect another player's document, or present your document to one or more nearby players.

<span id="document-views">



</span>



## Choose an export

<table>
<thead>
  <tr>
    <th>
      I want to…
    </th>
    
    <th>
      Client export
    </th>
    
    <th>
      Whose screen?
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Look at my own document
    </td>
    
    <td>
      <code>
        ViewOwnDocument
      </code>
    </td>
    
    <td>
      Mine
    </td>
  </tr>
  
  <tr>
    <td>
      Inspect another player's document
    </td>
    
    <td>
      <code>
        InspectPlayerDocument
      </code>
    </td>
    
    <td>
      Mine
    </td>
  </tr>
  
  <tr>
    <td>
      Show my document to one player
    </td>
    
    <td>
      <code>
        PresentOwnDocumentToPlayer
      </code>
    </td>
    
    <td>
      The selected player's
    </td>
  </tr>
  
  <tr>
    <td>
      Show my document to everyone nearby
    </td>
    
    <td>
      <code>
        PresentOwnDocumentNearby
      </code>
    </td>
    
    <td>
      Nearby players'; mine too with <code>
        includeSelf = true
      </code>
    </td>
  </tr>
</tbody>
</table>

Use Sky Jobs Base **1.56.0** or newer. Call these exports from a **client** event, command
handler or thread after Jobs Base has started. The calls yield while Jobs Base handles the request.
Use `"identity"` for an ID card, `"licenses"` for held licenses, or `"service"` for a service ID.

## Show my ID to everyone nearby and myself for five seconds

```lua
local success, openedCount, reason = exports["sky_jobs_base"]:PresentOwnDocumentNearby("identity", {
    includeSelf = true,
    durationMs = 5000,
})

if not success then
    print(("Could not show ID: %s"):format(reason or "unavailable"))
end
```

## ViewOwnDocument(documentType, options?)

Opens your own document on your screen. You do not need a job inspection permission.

```lua
local success, reason = exports["sky_jobs_base"]:ViewOwnDocument("licenses")
```

## InspectPlayerDocument(documentType, targetServerId, options?)

Opens another player's document on **your** screen. Pass the selected player's positive integer
**server ID**. The inspection requires the corresponding `identity` or `licenses` permission,
including job, grade and duty requirements. The target must be restrained by Jobs Base
(handcuffs or zip ties), within **2.5 metres**, and in the same routing bucket. Service IDs use
the `identity` permission. Use `ViewOwnDocument` for your own character.

```lua
local success, reason = exports["sky_jobs_base"]:InspectPlayerDocument("identity", targetServerId)
```

## PresentOwnDocumentToPlayer(documentType, recipientServerId, options?)

Opens your document on **one selected player's** screen. Pass their positive integer **server
ID**. You must be within **2.5 metres** of the recipient, in the same routing bucket, and
free of restraints. The recipient needs their screen free of other focused menus. No job
inspection permission is required. The radial also offers this under **Player interactions → Documents**.

```lua
local success, reason = exports["sky_jobs_base"]:PresentOwnDocumentToPlayer("service", recipientServerId, {
    durationMs = 8000,
})
```

## PresentOwnDocumentNearby(documentType, options?)

Opens your document on eligible nearby players' screens. The server picks the recipients
in your routing bucket. The same presentation rules apply as for one recipient. Players
with another focused menu are skipped. Set `includeSelf = true` to include your own screen;
this also works when you're alone. Presenting a document does not transfer an item.

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      What it does
    </th>
    
    <th>
      Default
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        includeSelf
      </code>
    </td>
    
    <td>
      Also open the card on your screen. Must be a boolean.
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        radius
      </code>
    </td>
    
    <td>
      Distance in metres. Must be greater than 0 and at most 2.5.
    </td>
    
    <td>
      <code>
        2.5
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        durationMs
      </code>
    </td>
    
    <td>
      How long the card stays open on each screen, in milliseconds.
    </td>
    
    <td>
      <code>
        60000
      </code>
    </td>
  </tr>
</tbody>
</table>

## Display duration and external card providers

All four exports accept `{ durationMs = 5000 }` as the last argument. Use a whole number
from `1000` to `60000`. The timer starts when Jobs Base opens the card on each viewer's
screen. The viewer can still close it early with **Enter** or **Escape**.

Presentation always uses the shared Jobs Base card. For self views and inspections,
passing `durationMs` also selects the shared card so Jobs Base can close it on time.
Omit the option to keep your configured card provider. The shared card then closes after
60 seconds; external providers manage their own closing behaviour.

## Return values

`ViewOwnDocument`, `InspectPlayerDocument` and `PresentOwnDocumentToPlayer` return
`success, reason`. `PresentOwnDocumentNearby` returns `success, openedCount, reason`.
For a nearby presentation, `success` is true if at least one card opened. The count includes
your own screen when it opened with `includeSelf = true`. If no card opens, the count is 0
and `reason` describes a failed check or delivery.

<table>
<thead>
  <tr>
    <th>
      Reason
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        invalid_document_type
      </code>
    </td>
    
    <td>
      Use <code>
        identity
      </code>
      
      , <code>
        licenses
      </code>
      
       or <code>
        service
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        invalid_options
      </code>
    </td>
    
    <td>
      Pass a table for options and a boolean for <code>
        includeSelf
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        invalid_duration
      </code>
    </td>
    
    <td>
      Pass a whole number from 1000 to 60000 for <code>
        durationMs
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        invalid_radius
      </code>
    </td>
    
    <td>
      Pass a radius greater than 0 and at most 2.5.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        invalid_target
      </code>
    </td>
    
    <td>
      The server ID is invalid or has no loaded character, or you passed your own ID instead of using the self option.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        no_recipients
      </code>
    </td>
    
    <td>
      No players with a loaded character were within range for the nearby request.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        busy
      </code>
    </td>
    
    <td>
      A viewer has another focused menu, an offer is pending, or the request was rate limited.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        too_far
      </code>
    </td>
    
    <td>
      A player was outside the permitted range or routing bucket, or had no usable ped.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        restrained
      </code>
    </td>
    
    <td>
      You cannot present a document while restrained.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        target_not_restrained
      </code>
    </td>
    
    <td>
      Inspection requires the target to be restrained by Jobs Base.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        not_authorized
      </code>
    </td>
    
    <td>
      An inspection or character check failed.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        disabled
      </code>
    </td>
    
    <td>
      The relevant document feature is disabled.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        storage
      </code>
    </td>
    
    <td>
      Jobs Base could not read or store service ID settings or numbers. Check the service card tables and oxmysql.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unavailable
      </code>
    </td>
    
    <td>
      The document or provider could not complete the request.
    </td>
  </tr>
</tbody>
</table>

Access and provider hooks can return additional reasons. For an external card, `true` means
the provider handoff was accepted; the provider controls what appears on screen.

<span id="showowndocumentdocumenttype">



</span>

<span id="showplayerdocumentdocumenttype-targetserverid">



</span>

<span id="presentowndocumentdocumenttype-recipientserverid">



</span>



## Legacy exports

Existing scripts can keep using these names with their original arguments:

<table>
<thead>
  <tr>
    <th>
      Legacy export
    </th>
    
    <th>
      Same action as
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ShowOwnDocument(documentType)
      </code>
    </td>
    
    <td>
      <code>
        ViewOwnDocument
      </code>
      
      : look at your own document on your screen.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ShowPlayerDocument(documentType, targetServerId)
      </code>
    </td>
    
    <td>
      <code>
        InspectPlayerDocument
      </code>
      
      : inspect the selected player's document on your screen.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        PresentOwnDocument(documentType, recipientServerId)
      </code>
    </td>
    
    <td>
      <code>
        PresentOwnDocumentToPlayer
      </code>
      
      : show your own document on the recipient's screen.
    </td>
  </tr>
</tbody>
</table>

After importing Jobs Base, these client functions are also available on `Sky_Jobs`, for example
`Sky_Jobs.ViewOwnDocument("identity")`.
See [Player Documents](/docs/base/jobs-base/features/player-documents) for card settings and
[Service IDs and Numbers](/docs/base/jobs-base/features/service-ids-and-numbers) for service ID setup.
