Step 5

Database installation

For this step we recommend you to wipe the vehicles of your server in case you don't have basic knowledge to implement the necessary columns. If you have basic programming skills you can play with this code.

Completely add the sql in your database and don't forget to add any.

Do not continue to the next step without running the sql we mentioned otherwise you will never be able to use the garage correctly.

ALTER TABLE `users` ADD IF NOT EXISTS `shell_garage` TEXT NULL DEFAULT '';

CREATE TABLE IF NOT EXISTS `owned_vehicles` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `owner` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_bin',
    `tag` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_bin',
    `plate` VARCHAR(250) NOT NULL COLLATE 'utf8mb4_bin',
    `vehicle` LONGTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_bin',
    `type` VARCHAR(20) NOT NULL DEFAULT 'vehicle' COLLATE 'utf8mb4_bin',
    `garage` VARCHAR(200) NULL DEFAULT 'OUT' COLLATE 'utf8mb4_bin',
    `impound_data` TEXT NULL DEFAULT '' COLLATE 'utf8mb4_bin',
    `favorite` INT(3) NOT NULL DEFAULT '0',
    `stored` TINYINT(4) NULL DEFAULT '0',
    `jobVehicle` VARCHAR(50) NULL DEFAULT '' COLLATE 'utf8mb4_bin',
    `jobGarage` VARCHAR(50) NULL DEFAULT '' COLLATE 'utf8mb4_bin',
    PRIMARY KEY (`id`) USING BTREE
) COLLATE = 'utf8mb4_bin' ENGINE = InnoDB AUTO_INCREMENT = 1;

ALTER TABLE `owned_vehicles` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

DROP TABLE IF EXISTS `player_garages`;
CREATE TABLE `player_garages` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `owner` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
    `name` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
    `price` INT(11) NOT NULL,
    `coords` TEXT NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
    `shell` TEXT NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
    `type` VARCHAR(50) NULL DEFAULT 'vehicle' COLLATE 'utf8mb4_unicode_ci',
    `holders` TEXT NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
    `available` INT(11) NULL DEFAULT NULL,
    `job` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
    PRIMARY KEY (`id`) USING BTREE
) COLLATE = 'utf8mb4_unicode_ci' ENGINE = InnoDB AUTO_INCREMENT = 27;

You can add this sql if you want to not lose your current vehicles:

If you don't use the official esx owned_vehicles table and use a heavily modified one, skip this and use the new full column you see above.

This is only in case of inserting missing columns without losing information.

Note that if you want to save your current vehicles and want to only insert columns into owned_vehicles, you will still need to install the other sql from player_garages.

ALTER TABLE
    `owned_vehicles` DROP PRIMARY KEY;

ALTER TABLE
    `owned_vehicles`
ADD
    COLUMN IF NOT EXISTS `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
ADD
    COLUMN IF NOT EXISTS `tag` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_bin',
ADD
    COLUMN IF NOT EXISTS `impound_data` TEXT NULL DEFAULT '' COLLATE 'utf8mb4_bin',
ADD
    COLUMN IF NOT EXISTS `favorite` INT(3) NOT NULL DEFAULT '0',
ADD
    COLUMN IF NOT EXISTS `vehicle` LONGTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_bin',
ADD
    COLUMN IF NOT EXISTS `garage` VARCHAR(200) NULL DEFAULT 'OUT' COLLATE 'utf8mb4_bin',
ADD
    COLUMN IF NOT EXISTS `stored` TINYINT(4) NULL DEFAULT '0',
ADD
    COLUMN IF NOT EXISTS `type` VARCHAR(20) NOT NULL DEFAULT 'vehicle' COLLATE 'utf8mb4_bin',
ADD
    COLUMN IF NOT EXISTS `jobVehicle` VARCHAR(50) NULL DEFAULT '' COLLATE 'utf8mb4_bin',
ADD
    COLUMN IF NOT EXISTS `jobGarage` VARCHAR(50) NULL DEFAULT '' COLLATE 'utf8mb4_bin';

ALTER TABLE
    `owned_vehicles` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

Last updated