Database

To set up the F&M Garage system, you need to make some changes to your server database. Execute the provided queries on your database.

You can either copy the query from here or import the file included in the script.

The file is located at: /config/database.sql

/config/databse.sql
CREATE TABLE IF NOT EXISTS `owned_vehicles` (
    `plate` VARCHAR(12) NOT NULL COLLATE 'utf8mb3_general_ci',
    PRIMARY KEY (`plate`) USING BTREE
)
COLLATE='utf8mb3_general_ci'
ENGINE=InnoDB;

ALTER TABLE `owned_vehicles`
    ADD COLUMN IF NOT EXISTS `owner` VARCHAR(60) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
    ADD COLUMN IF NOT EXISTS `vehicle` LONGTEXT NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
    ADD COLUMN IF NOT EXISTS `type` VARCHAR(20) NOT NULL DEFAULT 'car' COLLATE 'utf8mb3_general_ci',
    ADD COLUMN IF NOT EXISTS `job` VARCHAR(20) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
    ADD COLUMN IF NOT EXISTS `stored` TINYINT(4) NOT NULL DEFAULT '0',
    ADD COLUMN IF NOT EXISTS `parking` VARCHAR(60) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
    ADD COLUMN IF NOT EXISTS `pound` VARCHAR(60) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
    ADD COLUMN IF NOT EXISTS `glovebox` LONGTEXT NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
    ADD COLUMN IF NOT EXISTS `trunk` LONGTEXT NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
    ADD COLUMN IF NOT EXISTS `model` TEXT NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci';

Important


This script uses the model column from the owned_vehicles table to retrieve the vehicle name. If your vehicle shop script doesn't save this information to the database, you should update it accordingly.

Changing SQL queries


To modify the SQL queries, navigate to the /server/database.lua file. Here, you can change all queries used in the server scripts.

Note: You cannot change the variables passed to the functions.

Here is default content of this file.

database.lua
function getVehicleOwnerIdentifier(plate)
    local result = MySQL.single.await('SELECT owner FROM owned_vehicles WHERE plate = ?', {plate})
    return result
end

function storeVehicle(plate, vehProps)
    local result = MySQL.update.await('UPDATE owned_vehicles SET stored = ?, vehicle = ? WHERE plate = ?', {1, json.encode(vehProps), plate})
end

function getPlayerVehicles(identifier, garageType)
    local vehicles = MySQL.query.await('SELECT * FROM owned_vehicles WHERE owner = ? AND type = ? AND stored = ?', {identifier, garageType, 1})
    return vehicles
end

function changeVehicleStatus(plate, status)
    local result = MySQL.update.await('UPDATE owned_vehicles SET stored = ? WHERE plate = ?', {status, plate})
    return result
end

function getPlayerImpound(identifier)
    local impound = MySQL.query.await('SELECT * FROM owned_vehicles WHERE owner = ? AND stored = ?', {identifier, 0})
    return impound
end

Last updated