Vehicle Shops

Vehicle Shops is a single resource to solve vehicle shop requirements for roleplay servers.

Info

This resource provides multiple highly-configurable vehicle shop types, aiming to satisfy all requirements for personal vehicle purchases in your roleplay server.

  • Multiple shop types (NUI showroom, generic context menu shop, persistent showroom shops).

  • Character, job and group access restrictors for each shop.

  • Class/category restrictors for each shop.

  • Further configuration available by editing: - vehicles database table on ESX, adding a shop column. - Modifying the QBCore.Shared.Vehicles list shop var. - NOTE: You can restrict it to an individual shop, or any/all shops with none or all.

  • Automatic key item generation (ti_vehicleKeys).

  • Flexible finance system.

  • Ability to test-drive vehicles.

Setup

Config

All of the config vars found below are stored within the config.lua file.

config = {
    -- Automatic plate generation length (max 8)
    plateLength = 7,

    -- Max test drive time in minutes
    testDriveTime = 0.5,

    -- Command to repay finance
    repayFinanceCommand = "vehicle:repayFinance",
}

Shop Creation

All shop configuration can be found in the shops.lua file.

For shop-type specific config options, and for more information on creating new shops, read the documentation

Labels

All labels and translations can be found within the labels.lua file.

labels = {
    invalidInterior = "Invalid interior.",
    notEnoughMoney = "Not enough money.",
    ...
}

Usage

  • Some basic options are found within the config.lua file (as listed above).

  • All translations are handled in the labels.lua file.

  • For a working example on how to create a shop of any given type (nui, menu, showroom), check out the shop.lua file. All new shop definitions should be added here.

  • Class restrictions use the same indexes found here: https://docs.fivem.net/natives/?_0x29439776AAA00A62, or you can use -1 to allow all classes at a shop.

  • After you have executed the SQL query below, depending on your framework, you can either: * QB-Core: Modify the shared/vehicles.lua file, changing all shop vars. * ESX: Modify the shop column in the vehicles database table. Modifying the shop will restrict access beyond just classes. You can use "all" or "none" to bypass this restriction.

SQL

The default ESX or QB-Core vehicles and player_vehicles table scheme are expected.

Ensure those tables are already added to your database, and execute the query below respective of your framework.

QB-Core

ALTER TABLE `player_vehicles` ADD `paymentamount` INT(32)      DEFAULT 0;
ALTER TABLE `player_vehicles` ADD `financeshop`   VARCHAR(100) DEFAULT "";
ALTER TABLE `player_vehicles` ADD `paymentsleft`  INT(32)      DEFAULT 0;
ALTER TABLE `player_vehicles` ADD `financetime`   INT(32)      DEFAULT 0;
ALTER TABLE `player_vehicles` ADD `balance`       INT(32)      DEFAULT 0;

CREATE TABLE IF NOT EXISTS `vehicle_shops` (
  `id` varchar(50) NOT NULL DEFAULT '',
  `funds` int(11) NOT NULL DEFAULT 0,
  `stock` longtext NOT NULL DEFAULT '[]',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ESX

ALTER TABLE `owned_vehicles` ADD `paymentamount` INT(32)      DEFAULT 0;
ALTER TABLE `owned_vehicles` ADD `financeshop`   VARCHAR(100) DEFAULT "";
ALTER TABLE `owned_vehicles` ADD `paymentsleft`  INT(32)      DEFAULT 0;
ALTER TABLE `owned_vehicles` ADD `financetime`   INT(32)      DEFAULT 0;
ALTER TABLE `owned_vehicles` ADD `balance`       INT(32)      DEFAULT 0;
ALTER TABLE `vehicles`       ADD `shop`          VARCHAR(100) DEFAULT "all";

CREATE TABLE IF NOT EXISTS `vehicle_shops` (
  `id` varchar(50) NOT NULL DEFAULT '',
  `funds` int(11) NOT NULL DEFAULT 0,
  `stock` longtext NOT NULL DEFAULT '[]',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Conflicting Resources

  • None known currently, though we would recommend avoiding anything that also modifies the above database columns.

Dependencies

    qb-core AND qb-menu
es_extended AND esx_context

Last updated