Skip to the content
Docs

Database

On this page6

The script creates and updates its own tables. You do not import anything.

It is automatic

At every start the script does this:

  1. It runs sql/install.sql from its own folder. Tables that are missing are created. Tables that exist are left alone.
  2. It adds columns that a newer version needs, but only when they are missing.
  3. When there are no ranks yet (the first start), it creates the default ranks from Config.DefaultRanks.
  4. After an update with new permissions, it gives them to the default ranks. This happens once (see Updating).

Then the console shows:

Code
[5code-adminpanel] database ready.

Shortly after that, and then once a day, the script deletes old log lines. See Old log lines.

The tables

Eighteen tables. All names start with adminpanel_.

Ranks and staff

TableWhat it holds
adminpanel_ranksThe ranks: name, power and permissions.
adminpanel_staffWhich player holds which rank.
adminpanel_staff_seenName and rank of every staff member the panel has seen. Lists use it to show a name, for example under "Banned by".

Bans, warnings and jail

TableWhat it holds
adminpanel_bansEvery ban: the player, the reason, who banned, until when, and whether it was revoked.
adminpanel_warnsEvery warning: the player, the reason, who warned, and whether it was revoked.
adminpanel_jailPlayers who are in admin jail right now: time left, reason, and where to put them back.

Tickets and sits

TableWhat it holds
adminpanel_reportsThe tickets: who opened them, who handles them, open or resolved.
adminpanel_report_messagesThe conversation of each ticket.
adminpanel_report_peopleThe people of a ticket: the reporter and the players staff added.
adminpanel_sit_positionsWhere each person stood before a sit, so they can be put back.

Players

TableWhat it holds
adminpanel_activityOne row per player: first seen, last login, last seen, playtime and their identifiers.
adminpanel_player_notesStaff notes and alerts on players.

Logs and statistics

TableWhat it holds
adminpanel_logsThe log: staff actions, bans, warnings, kicks, tickets, joins and leaves. Lines older than Config.LogKeepDays days (default 90) are removed by the script.
adminpanel_stats_dailyThe highest number of players and staff online, per day.
adminpanel_stats_hourlyPlayers and staff online, per hour of the day.
adminpanel_stats_seenWhich players were online, per day. Rows older than 120 days are removed by the script.
adminpanel_stats_first_seenThe first day each player was seen. The dashboard uses it for "new players".

Housekeeping

TableWhat it holds
adminpanel_metaSmall notes the script keeps for itself, for example which one-time update is already done.

Good to know

  • Players are stored by their Rockstar license. A ban, a warning, a note or a rank follows the person, whatever character they play.
  • IP addresses are not stored.
  • Your framework's tables are only read. The offline search and the offline profile read the player table of your framework (players on QBCore and Qbox, users on ESX). The script does not write to it. Money, jobs and items are changed through your framework and your inventory, like any other script does.
  • Nothing is dropped. The script never deletes a table or a column, also not in an update.

Old log lines

adminpanel_logs also holds every join and leave, so it grows on a busy server. The script cleans it by itself.

Key in config.luaDefaultMeaning
Config.LogKeepDays90Log lines older than this many days are deleted. 0 keeps everything.
  • The clean-up runs shortly after every start, then once a day.
  • It only touches adminpanel_logs. Bans, warnings and tickets are in their own tables and are never deleted.
  • A config.lua without the line counts as 90.
  • When lines were deleted, the console shows for example: [5code-adminpanel] logs: 1250 line(s) older than 90 day(s) deleted.
  • The dashboard statistics read the last 90 days of the log. With a smaller value, older days show smaller numbers. See Dashboard.

The setting is explained on General.

Backups

Export every table that starts with adminpanel_. With HeidiSQL or phpMyAdmin: select the tables and use Export. On a command line:

Code
mysqldump -u YOUR_DB_USER -p YOUR_DB_NAME > backup.sql

That command saves the whole database, including the panel's tables.

Updates

An update changes the database by itself at the first start. What exactly happens is on the Updating page.