For the complete documentation index, see llms.txt. This page is also available as Markdown.

Exports

Guides with full examples: Screenshots and Uploads and Log API.

Client

TakeImage

Takes a screenshot of the player's own screen and uploads it straight to the media service. Limited to Player screenshots per minute (Settings > Players and items); 0 turns it off. Keys starting with _ in the metadata are dropped.

local result, reason = exports["tgiann-fivem-stats-script"]:TakeImage({ reason = "bug report" })

Parameters

  • metadata?: table stored with the file

Returns

  • { id: string, url: string } or nil, reason ("upload limit reached or media service is down")


IsPlayerAFK

Whether the local player is AFK right now.

local afk = exports["tgiann-fivem-stats-script"]:IsPlayerAFK()

Returns

  • boolean


ResetAFKTimer

Counts the player as active again, for example while they use a menu without moving.

Server

TakeServerImage

Takes a screenshot of a player's screen. Yields until the upload finishes or the timeout passes. The player becomes the file's player.

Parameters

  • src: number the player's server id

  • metadata?: table stored with the file

  • timeoutMs?: number defaults to Screenshot timeout in Settings > Players and items

Returns

  • { id: string, url: string } or nil, reason ("player not found", "screenshot timed out")


UploadBase64

Uploads a file sent as base64 or a data URI. With a filename the file gets a fixed address, <public address>/f/<path>/<filename>, and the same folder and name replaces it later.

Parameters

  • base64: string raw base64 or a data URI

  • options?: table

    • filename?: string the file name; makes the address fixed (images are stored as .webp)

    • path?: string the folder

    • metadata?: table playerSource / targetSource name the players

    • retentionExempt?: boolean keep forever

Returns

  • { id: string, url: string } or nil, error


RequestPresignedUrl

A single-use upload link for a client or a NUI. The uploader cannot change the folder, the metadata or keep forever, and the file always gets its own id.

Parameters

  • fileType?: string "image", "video" or "audio", any type when left out

  • options?: table

    • path?: string the folder

    • metadata?: table stored with the file

    • expiresIn?: number seconds the link works

    • retentionExempt?: boolean keep forever

Returns

  • string the upload URL (multipart form, field file) or nil, error


GetFile

Reads a file's record.

Parameters

  • idOrUrl: string the file id, its URL, or <path>/<filename> of a named file

Returns

  • { id, url, originalUrl, filename, type, size, metadata } or nil, error


DeleteFile

Deletes a file; its link stops working.

Parameters

  • idOrUrl: string the file id, its URL, or <path>/<filename> of a named file

Returns

  • boolean or false, error


UploadImage (JavaScript)

Uploads a Buffer from a JavaScript resource. A fileName gives the file a fixed address, like filename of UploadBase64.

Parameters

  • buffer: Buffer

  • options?: { fileName?: string, path?: string, metadata?: object, retentionExempt?: boolean }

Returns

  • Promise<{ id: string, url: string }>

Logs

Log

Writes a log line to the Server logs page. Never waits: lines are sent in batches. Lines below Lowest level kept (Settings > Logs) are dropped.

Parameters

  • dataset?: string default when left out

  • level?: string debug, info, warn or error, info when left out

  • message: any turned into text

  • metadata?: table playerSource / targetSource name the players


Info, Warn, Error

Log with the level in the name.

Parameters

  • dataset?: string

  • message: any

  • metadata?: table


LogMessage

Writes to the default dataset (fmsdk's name).

Parameters

  • level: string

  • message: any

Statistics

logMoney

Adds a money transaction to the Economy page. ESX addAccountMoney / removeAccountMoney and QB-Core OnMoneyChange are logged on their own; use this for money your scripts move outside the framework.

Parameters

  • citizenid: string the character id (QB citizenid, ESX identifier)

  • actionType: "add" or "remove"

  • amount: number

  • accountType?: string cash, bank...

  • description?: string


logKill

Adds a kill to the Combat page. Deaths are logged on their own; use this for kills your scripts handle themselves.

Parameters

  • killerCitizenid?: string nil for deaths without a player killer

  • victimCitizenid: string

  • deathType: string or number


logChat

Adds a message to the Chat page. The default chat resource and tgiann-chat are logged on their own.

Parameters

  • citizenid: string

  • message: string

  • chatType?: string normal when left out


IsPlayerAFK

Whether a player is AFK right now. The AFK time is AFK after in Settings > Players and items.

Returns

  • boolean


GetPlayerTotalAFKSeconds

AFK seconds of the player's current session.

Returns

  • number


GetAllAFKPlayers

Server ids of every player who is AFK right now.

Returns

  • number[]