Skip to content

Exports and Events ​

Use exports and lifecycle events when another resource needs to talk to LenoReports. Use hooks when you own the server and want to override access or react inside this resource.

Lifecycle events are server-local (TriggerEvent / AddEventHandler). Do not use RegisterNetEvent for them.

Client exports ​

ExportReturnsDescription
OpenPlayer()booleanForce-open the player report UI (hooks + permission checks)
OpenStaff()booleanForce-open the staff reports UI
Close()—Close the reports UI
IsOpen()open, modeopen is boolean; mode is 'player', 'staff', or nil

Server exports ​

ExportReturnsDescription
IsStaff(source)booleanWhether the player is staff
IsStaffOnDuty(source)booleanStaff and currently on duty
SetStaffDuty(source, onDuty)ok, onDutyOrErrSet duty (onDuty must be a boolean). Fires staffDutyChanged
CreateReport(source, data)reportId | false, err?Create a report (category, subject, description; optional involved / nearby)
ClaimReport(staffSource, reportId)payload | false, err?Claim an open report as staff
CloseReport(staffSource, reportId, reason?)payload | false, err?Close as staff. Defaults to Resolved; supported reasons and the Other limitation are listed below.
GetReport(reportId)report | nil, err?Compact report DTO (no mark-read side effect)
GetReports(filter?)tableFilter: status (default open, or all), category, assignee, author, limit (max 100)
GetOpenCount()numberCount of open reports
GetPlayerActiveReports(source)tableOpen reports authored by that player

Common err values include: forbidden, invalid_id, not_found, already_claimed, hook_blocked, cooldown, max_active, invalid_category, invalid_subject, invalid_description, invalid_onDuty.

CreateReport data ​

source is the online author's server ID. Use a category key from Config.Categories, such as player_report, bug_report, or other with the default configuration. The value player is not a default category and returns invalid_category.

subject and description are required strings and are subject to the configured report limits. Optional involved and nearby arrays contain online server IDs; they do not contain citizen IDs or ESX identifiers. Creating through the export still applies the server creation hook and report limits.

CloseReport reasons ​

ReasonEquivalent database key
Resolved (default)resolved
No Responseno_response
Player Offlineplayer_offline
Duplicateduplicate

The current export accepts only (staffSource, reportId, reason). It has no argument for a custom note. Other / other therefore returns false, 'invalid_reason', because that reason requires a note. To close with a custom reason, use Other and enter the note in the staff UI.

Withdrawn is reserved for the author withdrawing their report through the player UI; it is not accepted by this staff export. Passing a fourth argument does not add note support.

lua
-- Server: staffSource is an online staff member's server ID.
local result, err = exports['leno_reports']:CloseReport(staffSource, reportId, 'Resolved')
if not result then
    print('CloseReport failed', err)
end

Server lifecycle events ​

EventArguments
leno_reports:reportCreatedreportId, author { source, id, name }, category, payload { subject, description, authorId, authorName }
leno_reports:reportClaimedreportId, staff { source, id, name }
leno_reports:reportClosedreportId, reason, staff { source, id, name } (player withdraw uses the author as actor)
leno_reports:reportMessagereportId, meta { id, role, author, authorPlayerId, text, photo, timestamp, senderSource }
leno_reports:staffDutyChangedsource, identifier, onDuty

Usage examples ​

lua
-- Client: open / close from another resource (pause menu, phone, …)
if exports['leno_reports']:OpenPlayer() then
    -- UI opened
end

local open = exports['leno_reports']:IsOpen()
if open then
    exports['leno_reports']:Close()
end
lua
-- Server: create a report and react when any report is created
local reportId, err = exports['leno_reports']:CreateReport(source, {
    category = 'player_report', -- Config.Categories[].key
    subject = 'Cheating',
    description = 'Suspected aimbot near Legion Square.',
})
if not reportId then
    print('CreateReport failed', err)
end

AddEventHandler('leno_reports:reportCreated', function(reportId, author, category, payload)
    print(('Report #%s by %s [%s]'):format(reportId, author.name, category))
end)

Server hooks (ReportsHooks) ​

Defined in server/main.lua. Override these functions to change access or react to lifecycle events inside this resource.

HookPurpose
IsStaff(source)Whether the player is staff (default: Bridge.IsAdmin)
CanOpenStaff(source)May open staff menu (default: IsStaff)
CanOpenPlayer(source)May open player menu (default: true)
CanCreateReport(source, data)Return false to block create
OnReportCreated(source, reportId, data)After successful create
OnReportClosed(source, reportId, reason, data)After successful close
OnDiscordLog(event, data)Return false to cancel Discord log; table to override embed; nil for default

Example:

lua
function ReportsHooks.CanOpenPlayer(source)
    -- e.g. block players in certain jobs
    return true
end

function ReportsHooks.OnReportCreated(source, reportId, data)
    print(('Report #%s created by %s'):format(reportId, source))
end

Client hooks (ReportsClientHooks) ​

Defined in client/main.lua.

HookPurpose
BeforeOpenPlayer / BeforeOpenStaffGate UI open
CanTakeScreenshotGate screenshot capture
BeforeCreateReportGate client-side create
GetOpenDeniedMessageCustom deny message
OnUiOpen / OnUiCloseUI lifecycle

Internal net events ​

These are used by the resource UI. Prefer public exports/events or hooks for integrations — do not rely on internal events unless you know the payload contract.

EventDirectionRole
leno_reports:notifyServer → clientGeneric toast
leno_reports:staffNotifyServer → clientStaff toast + last-report tracking
leno_reports:chatMessageServer → clientLive ticket chat
leno_reports:reportUpdateServer → clientQueue / detail refresh
leno_reports:staffChatMessageServer → clientStaff chat push
leno_reports:staffDutyUpdateServer → clientDuty roster
leno_reports:adminTeleportServer → clientApply teleport
leno_reports:adminFreezeServer → clientApply freeze

ox_lib callbacks ​

Server registers callbacks under the leno_reports:* namespace (create, queue, claim, close, screenshots, statistics, staff chat, …). These power the NUI and are not a stable public API for other resources.