Screenshots
Quick Start
Section titled “Quick Start”Capture a screenshot from the server and receive a base64 data URI.
exports.screencapture:serverCapture(source, { encoding = 'webp', maxWidth = 1920, maxHeight = 1080,}, function(data) print(data)end)Capture a screenshot and receive a binary blob in JavaScript or TypeScript.
exports.screencapture.serverCapture( source, { encoding: 'webp' }, (data: Buffer) => { // Store, upload, or process the image buffer. }, 'blob',);Upload a screenshot directly to a remote API.
exports.screencapture:remoteUpload(source, 'https://api.fivemanage.com/api/v3/file', { encoding = 'webp', headers = { ['Authorization'] = 'your-api-key' }, formField = 'file', filename = 'incident-shot',}, function(response) print(response.data.url)end, 'blob')serverCapture(source, options, callback, dataType?)
Section titled “serverCapture(source, options, callback, dataType?)”Captures a screenshot for a player and passes the image data to the callback.
| Parameter | Type | Required | Description |
|---|---|---|---|
source |
number |
Yes | Player source to capture. |
options |
CaptureOptions |
Yes | Capture options. |
callback |
function |
Yes | Called with the captured image data. |
dataType |
'base64' | 'blob' |
No | Callback format. Defaults to 'base64'. |
remoteUpload(source, url, options, callback, dataType?)
Section titled “remoteUpload(source, url, options, callback, dataType?)”Captures a screenshot for a player and uploads it to a remote URL.
| Parameter | Type | Required | Description |
|---|---|---|---|
source |
number |
Yes | Player source to capture. |
url |
string |
Yes | Remote upload endpoint. |
options |
CaptureOptions |
Yes | Capture and upload options. |
callback |
function |
Yes | Called with the remote API response. |
dataType |
'base64' | 'blob' |
No | Upload format. Defaults to 'base64'. |
Screenshot Options
Section titled “Screenshot Options”| Field | Type | Default | Description |
|---|---|---|---|
encoding |
'webp' | 'jpg' | 'png' |
'webp' |
Image encoding format. |
maxWidth |
number |
1920 |
Maximum capture width in pixels. |
maxHeight |
number |
1080 |
Maximum capture height in pixels. |
headers |
object |
{} |
HTTP headers for remote upload requests. |
formField |
string |
'file' |
FormData field name for uploads. |
filename |
string |
Generated by the upload target | Upload file name without extension. |
fileName |
string |
Compatibility alias used by screenshot-basic style calls. |
Client Compatibility Exports
Section titled “Client Compatibility Exports”Prefer server-side remoteUpload because client-side upload exposes upload details to the client. Compatibility exports are available for existing integrations.
exports['screencapture']:requestScreenshotUpload('https://api.fivemanage.com/api/v3/file', 'file', { headers = { ['Authorization'] = 'your-api-key' }, encoding = 'webp',}, function(data) local response = json.decode(data) print(response.url)end)exports['screencapture']:requestScreenshot({ encoding = 'jpg' }, function(data) print(data)end)