Using the Log System

This page will outline how you can integrate the Admin Panel's built-in logging system to your FiveM server.

Implementing Custom Log Types

There is currently no UI to manage custom log types, but we will cover manually creating log types by executing database queries on your FiveM server's database.

Simple Users

Use this code snippet as a template. In this example we create a log type for a store robbery.

INSERT INTO `adminpanel_log_types` (`name`, `label`, `log_logs`, `type`)
VALUES ('storerobbery', 'Store Robbery', 'Y', 'character');

Now let's send a log to the panel, from the server sided exports.ivs_adminpanel.CreateLog

local robber = source
exports.ivs_adminpanel.CreateLog(robber, 'storerobbery', string.format('%s Robbed a store', robber))

Advanced Users

Understanding the adminpanel_log_types database table:

  • name: Internal name for the log type

    • This is what you use when calling Panel.Functions.CreateLog (covered later)

  • label: A more read-able format of the name value (what will show on the panel)

  • log_logs: "Y" or "N".

    • Y - This will save logs to the database

    • N - Will NOT save logs to the database, and will only send them to configured discord webhooks.

  • type : "staff", "character", or "user"

    • "staff" - Should be used for actions made by a staff member. This will require the stafflogs permission to view from the panel.

    • "character" and "user" Fundamentally, the same, but player should be used for character-based actions, and user should be used for more administrative actions.

      • Think of user when banning, kicking, muting, etc.

      • Think of character when robbing a bank, finishing a job, etc.

Template Variables (Hyperlinking)

The Admin Panel supports template variables that automatically convert into clickable links when viewed on the Admin Panel. These variables link to specific pages such as player profiles, character profiles, or punishment records.

Variable Types

Player Links: {@USERID}

  • Links to a player's profile page

  • Displays the player's name as clickable text

  • Example: {@123} becomes a clickable link to player ID 123

  • Note: Use the player's Admin Panel ID, obtainable via the ivs_adminpanel export GetPlayerIdFromSrc

Character Links: {@@CHARACTERID}

  • Links to a character's profile page

  • Displays the character's name as clickable text

  • Example: {@@abc123} becomes a clickable link to character ID abc123

  • Note: Use the citizenid (QBCore/QBOX) or identifier (ESX) as the character ID

Punishment Links: {!PUNISHMENTID}

  • Links to a punishment record in the management interface

  • Displays the punishment type as clickable text

  • Example: {!456} becomes a clickable link to punishment ID 456

Usage Example:

local killerId = exports.ivs_adminpanel.GetPlayerIdFromSrc(killerSource) -- assuming killerSource is defined
local victimId = exports.ivs_adminpanel.GetPlayerIdFromSrc(victimSource) -- assuming victimSource is defined
local killerCharId = "abc123"  -- Killer's character ID (citizenid/identifier)
local victimCharId = "def456"  -- Victim's character ID (citizenid/identifier)
local weapon = "WEAPON_PISTOL"

local message = "{@@" .. killerCharId .. "} ({@" .. killerId .. "}) killed {@@" .. victimCharId .. "} ({@" .. victimId .. "}) with " .. weapon
exports.ivs_adminpanel(killerId, "player_kill", message, killerCharId)

This creates a log entry that displays as: "John Doe (PlayerName123) killed Jane Smith (PlayerName456) with WEAPON_PISTOL" Where both character names and player names are clickable links leading to their respective profile pages.

Last updated