# Server Exports

### registerToPickup

```lua
---@param {src: number}: player id
---@param {name: string}: document name (key from Config.Documents)
---@param {photoId: number}: photo id

---@return {serialNumber: string}
exports['vms_documentsv2']:registerToPickup(src, name, photoId, function(serialNumber)

end)
```

***

### pickupDocument

```lua
---@param {src: number}: player id
---@param {serialNumber: string}: 

---@return {success: boolean}
exports['vms_documentsv2']:pickupDocument(src, serialNumber, function(success)

end)
```

***

### removePhoto

```lua
---@param {identifier: string}: player identifier
---@param {photoId: number}: photo id
exports['vms_documentsv2']:removePhoto(identifier, photoId)
```

***

### getMyPhotos

```lua
---@param {identifier: string}: player identifier

---@return table
local photos = exports['vms_documentsv2']:getMyPhotos(identifier)
```

***

### getMyDocuments

```lua
---@param {identifier: string}: player identifier

---@return table
local documents = exports['vms_documentsv2']:getMyDocuments(identifier)
```

***

### giveDocument

```lua
---@param {src: number}: player id
---@param {name: string}: document name (key from Config.Documents)
---@param {photoId: number}: photo id
---@param {cancelCurrentActive: boolean}: Should it cancel the current active document?
exports['vms_documentsv2']:giveDocument(src, name, photoId, cancelCurrentActive)
```

<details>

<summary>Example Usage</summary>

Using this example, you will add a player's license and revoke the current one if he has a

```lua
local src = source
exports['vms_documentsv2']:giveDocument(src, 'driving_license', nil, true)
```

</details>

***

### invalidateDocument

```lua
---@param {identifier: string}: player identifier
---@param {serialNumber: string}: document serial number
exports['vms_documentsv2']:invalidateDocument(identifier, serialNumber)
```

***

### isAnyDocumentValid

```lua
---@param {identifier: string}: player identifier
---@param {name: string}: document name (key from Config.Documents)

---@return string | nil: Returns the serial number of the active document
local serialNumber = exports['vms_documentsv2']:isAnyDocumentValid(identifier, name)
```

<details>

<summary>Example Usage (with ox_inventory)</summary>

```lua
local src = source
local identifier = xPlayer.identifier

local validSerialNumber = exports['vms_documentsv2']:isAnyDocumentValid(identifier, 'driving_license')
---@return validSerialNumber: Serial number of the active document

local playerInvDocument = exports['ox_inventory']:Search(src, 'slots', 'driving_license', validSerialNumber)
---@return playerInvDocument: Searches the player's inventory to find an item with the assigned serial number of the active document

if playerInvDocument and playerInvDocument[1] and playerInvDocument[1].count >= 1 then
    -- If a document is found in inventory with a specific serial number, it does not delete the current document - we simply assign new metadata of active licenses
    local tempMetadata = playerInvDocument[1].metadata
      
    -- tempMetadata.drive_a = "A" --> Set when he has a motorcycle license
    -- tempMetadata.drive_b = "B" --> Set when he has a license to drive a car
    -- tempMetadata.drive_c = "C" --> Set when he has a license to drive a truck
    
    -- We assign new metadata to the current item
    exports['ox_inventory']:SetMetadata(src, playerInvDocument[1].slot, tempMetadata)
else
    -- If the required document is not found in inventory, we generate a new document for the player to receive into inventory
    exports['vms_documentsv2']:giveDocument(src, 'driving_license', nil, true)
end
```

</details>


---

# 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://docs.vames-store.com/assets/vms_documentsv2/developer-api/server-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.
