Server-Side

Server Exports

Below are all the useful exports that you can use in other resources, be sure to read their descriptions.


registerToPickup

---@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

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

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

end)

removePhoto

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

getMyPhotos

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

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

getMyDocuments

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

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

giveDocument

---@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)
Example Usage

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

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

invalidateDocument

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

isAnyDocumentValid

---@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)
Example Usage (with ox_inventory)
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

Last updated

Was this helpful?