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?:
tablestored with the file
Returns
{ id: string, url: string }ornil, 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:
numberthe player's server idmetadata?:
tablestored with the filetimeoutMs?:
numberdefaults to Screenshot timeout in Settings > Players and items
Returns
{ id: string, url: string }ornil, 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:
stringraw base64 or a data URIoptions?:
tablefilename?:
stringthe file name; makes the address fixed (images are stored as.webp)path?:
stringthe foldermetadata?:
tableplayerSource/targetSourcename the playersretentionExempt?:
booleankeep forever
Returns
{ id: string, url: string }ornil, 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 outoptions?:
tablepath?:
stringthe foldermetadata?:
tablestored with the fileexpiresIn?:
numberseconds the link worksretentionExempt?:
booleankeep forever
Returns
stringthe upload URL (multipart form, fieldfile) ornil, error
GetFile
Reads a file's record.
Parameters
idOrUrl:
stringthe file id, its URL, or<path>/<filename>of a named file
Returns
{ id, url, originalUrl, filename, type, size, metadata }ornil, error
DeleteFile
Deletes a file; its link stops working.
Parameters
idOrUrl:
stringthe file id, its URL, or<path>/<filename>of a named file
Returns
booleanorfalse, error
UploadImage (JavaScript)
Uploads a Buffer from a JavaScript resource. A fileName gives the file a fixed address, like filename of UploadBase64.
Parameters
buffer:
Bufferoptions?:
{ 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?:
stringdefaultwhen left outlevel?:
stringdebug,info,warnorerror,infowhen left outmessage:
anyturned into textmetadata?:
tableplayerSource/targetSourcename the players
Info, Warn, Error
Log with the level in the name.
Parameters
dataset?:
stringmessage:
anymetadata?:
table
LogMessage
Writes to the default dataset (fmsdk's name).
Parameters
level:
stringmessage:
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:
stringthe character id (QB citizenid, ESX identifier)actionType:
"add"or"remove"amount:
numberaccountType?:
stringcash,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?:
stringnilfor deaths without a player killervictimCitizenid:
stringdeathType:
stringornumber
logChat
Adds a message to the Chat page. The default chat resource and tgiann-chat are logged on their own.
Parameters
citizenid:
stringmessage:
stringchatType?:
stringnormalwhen 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[]