Skip to content

Database Setup

This page explains the database tables used by 0r-multicharacterv3 and how to set them up.

๐Ÿ“Š Required Tables#

Table: 0r_multicharacterv3#

Stores additional character slot data for each player.

sql
CREATE TABLE IF NOT EXISTS `0r_multicharacterv3` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `identifier` VARCHAR(100) NOT NULL,
    `character_slot` INT(11) NOT NULL DEFAULT 0,
    PRIMARY KEY (`id`),
    UNIQUE KEY `identifier` (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ColumnTypeDescription
idINTAuto-increment primary key
identifierVARCHAR(100)Player's license2 identifier
character_slotINTAdditional slots (added to default)

Table: 0r_multicharacterv3_code#

Stores redeemable codes for extra character slots.

sql
CREATE TABLE IF NOT EXISTS `0r_multicharacterv3_code` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `code` VARCHAR(100) NOT NULL,
    `slot` INT(11) NOT NULL DEFAULT 1,
    PRIMARY KEY (`id`),
    UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ColumnTypeDescription
idINTAuto-increment primary key
codeVARCHAR(100)Unique redeemable code
slotINTNumber of slots the code gives

๐Ÿš€ Quick Setup#

Using the SQL File#

  1. Locate insert-me.sql in the resource folder
  2. Open your database management tool
  3. Execute the entire SQL file

Manual Creation#

Run these queries in your database:

sql
-- Create character slot table
CREATE TABLE IF NOT EXISTS `0r_multicharacterv3` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `identifier` VARCHAR(100) NOT NULL,
    `character_slot` INT(11) NOT NULL DEFAULT 0,
    PRIMARY KEY (`id`),
    UNIQUE KEY `identifier` (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Create redeemable codes table
CREATE TABLE IF NOT EXISTS `0r_multicharacterv3_code` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `code` VARCHAR(100) NOT NULL,
    `slot` INT(11) NOT NULL DEFAULT 1,
    PRIMARY KEY (`id`),
    UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

๐ŸŽฎ Framework-Specific Tables#

The script also interacts with your framework's existing tables:

QBCore / QBox#

TableUsage
playersCharacter data storage
playerskinsCharacter appearance

ESX#

TableUsage
usersCharacter data storage
(skin in users table)Character appearance

You don't need to modify framework tables. The script uses them as-is.


๐Ÿ  Optional: House Data (QBCore Only)#

If you use qb-houses, the script reads from:

sql
-- Used for house garage config
SELECT * FROM houselocations

Make sure your houselocations table exists if using housing.


๐Ÿ”ง Character Deletion Tables#

When a character is deleted, the script removes data from configured tables. Default tables in config/database.lua:

QBCore Tables#

lua
['qb-core'] = {
    { table = 'players', column = 'citizenid', type = 'citizenid' },
    { table = 'playerskins', column = 'citizenid', type = 'citizenid' },
    { table = 'player_vehicles', column = 'citizenid', type = 'citizenid' },
    { table = 'player_houses', column = 'citizenid', type = 'citizenid' },
    { table = 'player_gangs', column = 'citizenid', type = 'citizenid' },
    -- Add more as needed
}

ESX Tables#

lua
['es_extended'] = {
    { table = 'users', column = 'identifier', type = 'citizenid' },
    { table = 'user_accounts', column = 'identifier', type = 'citizenid' },
    { table = 'user_inventory', column = 'identifier', type = 'citizenid' },
    -- Add more as needed
}

๐Ÿ“ Adding Custom Codes#

To add redeemable slot codes manually:

sql
-- Add a single-use code that gives 1 slot
INSERT INTO 0r_multicharacterv3_code (code, slot) VALUES ('FREESLOT2024', 1);

-- Add a code that gives 3 slots
INSERT INTO 0r_multicharacterv3_code (code, slot) VALUES ('VIP3SLOTS', 3);

Players can redeem these codes in the character selection UI.