m-Scripts
  • m-Scripts Documentation
  • QBCore
    • Jobs
      • 🚗[QB] TunerJob
        • 🛠️Installation
        • ❓Common Questions
        • 🗒️Config
      • 🍞[QB] BeanMachine
        • 🛠️Installation
        • 🗒️Config
      • 🍔[QB] Burgershot
        • 🛠️Installation
        • 🗒️Config
      • 🍈[QB] CoolBeans
        • 🛠️Installation
        • 🗒️Config
      • 🚚[QB] Deliveries
        • 🛠️Installation
        • 📃Config
          • 📃config_functions
      • 🍎[QB] Farming
        • 🛠️Installation
        • 🗒️Config
      • 🐟[QB] Fishing
        • 🛠️Installation
        • 🗒️Config
          • 📄config_diving
          • 📄config_fishingnet
          • 📄config_fishingrod
          • 📄config_functions
          • 📄config_language
          • 📄config_seashells
          • 📄config_tournament
          • 📄config_upgrades
      • 🚛[QB] Garbage
        • 🛠️Installation
        • 🗒️Config
      • 🗝️[QB] GoldRush
        • 🛠️Installation
        • 🗒️Config
      • ⛰️[QB] Hunting
        • 🛠️Installation
        • 🗒️Config
      • 🪵[QB] Lumberjack
        • 🛠️Installation
        • 🗒️Config
      • ⛏️[QB] Mining
        • 🛠️Installation
        • 🗒️Config
      • 🛢️[QB] Oil Factory
        • 🛠️Installation
        • ❓Common Questions
        • 🗒️Config
      • ☕[QB] Pond Coffee
        • 🛠️Installation
        • ❓Common Questions
        • 🗒️Config
      • 🚚[QB] Trucker
        • 🛠️Installation
        • 🗒️Config
          • 📄Functions
          • 📄Language
      • 🥃[QB] Vanilla
        • 🛠️Installation
        • 🗒️Config
      • 🛻[QB] Mechanic Run
        • 🛠️Installation
        • 🗒️Config
      • 🥃[QB] Bahamas
        • 🛠️Installation
        • 📄Config
      • 🔫[QB] Ammunation
        • 🛠️Installation
        • 📄Config
      • 🐟[QB] Pearls
        • 🛠️Installation
        • 📄Config
      • 🔓[QB] Impound
        • 🛠️Installation
        • 📄Config
        • ✅Garages
      • 🚘[QB] Vehicleshop
        • 🛠️Installation
        • 📄Config
          • Functions
          • Job
          • Language
        • ❓Common Questions
    • General
      • 🏕️[QB] Camping
        • 🛠️Installation
        • 🗒️Config
          • Consumables
          • Language
      • 🎄[QB] Christmas
        • 🛠️Installation
        • 🗒️Config
      • 🎃[QB] Halloween
        • 🛠️Installation
        • 🗒️Config
      • 📔[QB] Insurance
        • 🛠️Installation
        • 🖥️Compatibilities
        • 🗒️Config
        • 🔁Server-Exports
      • 🏘️[QB] Vespucci
        • 🛠️Installation
        • 🗒️Config
          • Brewery
          • Digital Den
          • Masquerade
          • Pro Bikes
      • 🏖️[QB] Beach Activities
        • 🛠️Installation
        • 🗒️Config
      • 🚘[QB] Car Rental
        • 🛠️Installation
        • 📄Config
        • 🖥️Compatibilities
      • ✈️[QB] Sky Racing
        • 🛠️Installation
        • 📄Config
      • 🚘[QB] Car Wash
        • 🛠️Installation
        • 📄Config
      • 🪨[QB] Grinder
        • 🛠️Installation
        • 📄Config
      • 📹[QB] SpyCams & CCTV's
        • 🛠️Installation
        • 📄Config
      • 🏠[QB] Motel
        • 🛠️Installation
        • 📄Config
        • 🖥️Compatibilities
      • 🏚️[QB] Job Center
        • 📄Config
      • 🛠️[QB] Crafting
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
    • Illegal
      • 🔫[QB] Gangs
        • 🛠️Installation
        • 🗒️Config
      • 🔔[QB] Drug Selling
        • 🗒️Config
      • 🌱[QB] Drugs
        • 🛠️Installation
        • 🗒️Config
      • 🍯[QB] Craft Potion
        • 🛠️Installation
        • 🗒️Config
      • 🅱️[QB] Blackmarket
        • 🛠️Installation
        • 🗒️Config
          • config_functions
          • config_language
      • 🚗[QB] Car Thief
        • 🗒️Config
      • 🏠[QB] House Robbery
        • 🛠️Installation
        • 🗒️Config
      • 💎[QB] Jewelry
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • ®️[QB] Mini Robberys
        • 🛠️Installation
        • 🗒️Config
      • 💰[QB] MoneyWash
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • 🔫[QB] Rob NPC
        • 🛠️Installation
        • 🗒️Config
      • 🏃‍♂️[QB] Runs
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • ⛽[QB] Steal Fuel
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • 🏬[QB] Store Robbery
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • 🪛[QB] Scrapyard
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • 👾[QB] Territories
        • 🛠️Installation
        • 📄Config
          • Functions
      • 🏨[QB] GoPostal
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
          • S_utils
  • ESX
    • Jobs
      • 🚗[ESX] Tunerjob
        • ❗Dependencies
        • 🛠️Installation
          • ℹ️OX-Inventory
          • ℹ️QS-Inventory
        • 🗒️Config
          • BlacklistVehicles
          • Craft
          • Functions
          • Language
          • Targets
          • Wraps
          • Events
        • ❓Common Questions
      • 🚚[ESX] Trucker
        • 🛠️Installation
        • 🗒️Config
          • 📄Functions
          • 📄Language
      • 🪵[ESX] Lumberjack
        • 🛠️Installation
        • 🗒️Config
      • 🛻[ESX] Mechanic Run
        • 🛠️Installation
        • 🗒️Config
      • ⛏️[ESX] Mining
        • 🛠️Installation
        • 🗒️Config
      • 🎣[ESX] Fishing
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
          • Diving
          • Fishingnet
          • Fishingrod
          • Seashells
          • Tournament
          • Upgrades
    • General
      • 🚘[ESX] Car Rental
        • 🛠️Installation
        • 🗒️Config
      • 📃[ESX] Insurance
        • 🛠️Installation
        • 🖥️Compatibilities
        • 📄Config
        • 🔁 Server-Exports
      • 🚘[ESX] Car Wash
        • 🛠️Installation
        • 📄Config
      • 📹[ESX] SpyCams & CCTV's
        • 🛠️Installation
        • 📄Config
        • 🏠[ESX] Motel
          • 🛠️Installation
          • 📄Config
          • 🖥️Compatibilities
      • 🛠️[ESX] Crafting
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
      • 🎄[ESX] Christmas
        • 🛠️Installation
        • 📄Configs
    • Illegal
      • 🔫[ESX] Gangs
        • 🛠️Installation
        • 📄Config
        • ❓Common Questions
      • 🅱️[ESX] Blackmarket
        • 🛠️Installation
        • 🗒️Config
          • config_functions
          • config_language
      • 🏨[ESX] GoPostal
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
          • S_utils
  • Both Framework
    • Scripts
      • 🚗Car Rebuild
        • 🛠️Installation
        • 🗒️Config
      • 🗺️City Guide
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
      • 🛒Shops
        • 📄Config
        • 🛠️Installation
      • 🔁Reputation
        • 📄Config
        • 🛠️Installation
        • ⁉️Exports & Commands
          • Server Exports
          • Commands
      • 💤AFK System
        • 📄Configs
        • 🛠️Installation
      • 🚗Garages
        • 🛠️Installation
        • 📑User Guide
          • Create Garages
          • Create Private Garage
          • Impound & Auctions
          • Add vehicle to gang/job
          • Commands
      • ✈️Airplane Job
        • 🛠️Installation
        • 📃Configs
        • ℹ️Exports
      • 📋Scoreboard
        • 📃Config
      • 📦StorageUnits
        • 🛠️Installation
        • 📃Config
Powered by GitBook
On this page
  • Run the SQL:
  • Snippets for Vehicleshops:
  1. ESX
  2. General
  3. [ESX] Car Rental

Installation

Run the SQL:

CREATE TABLE `mCarRental_vehicles` (
  `rental_id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `plate` varchar(255) DEFAULT NULL,
  `label` varchar(255) DEFAULT NULL,
  `category` varchar(255) NOT NULL,
  `passengers` int(11) NOT NULL,
  `top_speed` int(11) NOT NULL,
  `price` int(11) NOT NULL,
  `owner` varchar(255) DEFAULT NULL,
  `owner_name` varchar(255) DEFAULT NULL,
  `rental_owner` varchar(255) DEFAULT NULL,
  `date_limit` varchar(255) DEFAULT NULL,
  `available` int(1) DEFAULT NULL
);

CREATE TABLE `mCarRental_history`(
  `identifier` varchar(255) NOT NULL,
  `identifier_name` varchar(255) NOT NULL,
  `vehicle_name` varchar(255) NOT NULL,
  `type` varchar(255) NOT NULL,
  `price` varchar(255) NOT NULL,
  `days` varchar(255) NOT NULL,
  `date` varchar(255) NOT NULL
);

ALTER TABLE owned_vehicles
ADD rental_owner VARCHAR(50) NOT NULL,
ADD rental_mods LONGTEXT NOT NULL,
ADD isRented int(1) NOT NULL;

ALTER TABLE users
ADD img_avatar LONGTEXT NOT NULL;

ALTER TABLE owned_vehicles
ADD model_name VARCHAR(50) NOT NULL;

Snippets for Vehicleshops:

  1. okokVehicleShop

Search Config.EventPrefix..':setVehicleOwned and replace with:

RegisterServerEvent(Config.EventPrefix..':setVehicleOwned')
AddEventHandler(Config.EventPrefix..':setVehicleOwned', function (vehicleProps, model, id)
  local _source = source
  local xPlayer = ESX.GetPlayerFromId(_source)

  if Config.Boats[model] == true then
      MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, type) VALUES (@owner, @plate, @vehicle, @type)', {
          ['@owner'] = xPlayer.identifier,
          ['@plate'] = vehicleProps.plate,
          ['@vehicle'] = json.encode(vehicleProps),
          ['@type'] = 'boat',
          ['@model_name'] = model
      }, function (rowsChanged)
      end)
  elseif Config.Aircrafts[model] == true then
      MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, type) VALUES (@owner, @plate, @vehicle, @type)', {
          ['@owner'] = xPlayer.identifier,
          ['@plate'] = vehicleProps.plate,
          ['@vehicle'] = json.encode(vehicleProps),
          ['@type'] = 'air',
          ['@model_name'] = model
      }, function (rowsChanged)
      end)
  else
      MySQLexecute('INSERT INTO owned_vehicles (owner, plate, vehicle, model_name) VALUES (@owner, @plate, @vehicle, @model_name)',
      {
          ['@owner'] = xPlayer.identifier,
          ['@plate'] = vehicleProps.plate:match( "^%s*(.-)%s*$" ),
          ['@vehicle'] = json.encode(vehicleProps),
          ['@model_name'] = model
      }, function (rowsChanged)
      end)    
  end
  1. esx_vehicleshop

Search: esx_vehicleshop:setVehicleOwnedPlayerId and replace with:

RegisterNetEvent('esx_vehicleshop:setVehicleOwnedPlayerId')
AddEventHandler('esx_vehicleshop:setVehicleOwnedPlayerId', function(playerId, vehicleProps, model, label)
    local xPlayer, xTarget = ESX.GetPlayerFromId(source), ESX.GetPlayerFromId(playerId)
    local modelName = getVehicleFromModel(model).name
    if xPlayer.job.name ~= 'cardealer' or not xTarget then
        return
    end

    MySQL.scalar('SELECT id FROM cardealer_vehicles WHERE vehicle = ?', {model},
    function(id)
        if not id then
            return
        end

        MySQL.update('DELETE FROM cardealer_vehicles WHERE id = ?', {id},
        function(rowsChanged)
            if rowsChanged == 1 then
                MySQL.insert('INSERT INTO owned_vehicles (owner, model_name, plate, vehicle) VALUES (?, ?, ?, ?)', {xTarget.identifier, modelName, vehicleProps.plate, json.encode(vehicleProps)},
                function(id)
                    xPlayer.showNotification(TranslateCap('vehicle_set_owned', vehicleProps.plate, xTarget.getName()))
                    xTarget.showNotification(TranslateCap('vehicle_belongs', vehicleProps.plate))
                end)

                MySQL.insert('INSERT INTO vehicle_sold (client, model, plate, soldby, date) VALUES (?, ?, ?, ?, ?)', {xTarget.getName(), label, vehicleProps.plate, xPlayer.getName(), os.date('%Y-%m-%d %H:%M')})
            end
        end)
    end)
end)

Search: esx_vehicleshop:buyVehicle and replace with:

ESX.RegisterServerCallback('esx_vehicleshop:buyVehicle', function(source, cb, model, plate)
    local xPlayer = ESX.GetPlayerFromId(source)
    local modelPrice = getVehicleFromModel(model).price
    local modelName = getVehicleFromModel(model).model
    if modelPrice and xPlayer.getMoney() >= modelPrice then
        xPlayer.removeMoney(modelPrice, "Vehicle Purchase")
        MySQL.insert('INSERT INTO owned_vehicles (owner, model_name, plate, vehicle) VALUES (?, ?, ?, ?)', {xPlayer.identifier, modelName, plate, json.encode({model = joaat(model), plate = plate})
        }, function(rowsChanged)
            xPlayer.showNotification(TranslateCap('vehicle_belongs', plate))
            ESX.OneSync.SpawnVehicle(joaat(model), Config.Zones.ShopOutside.Pos, Config.Zones.ShopOutside.Heading,{plate = plate}, function(vehicle)
                Wait(100)
                local vehicle = NetworkGetEntityFromNetworkId(vehicle)
                Wait(300)
                TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1)
            end)
            cb(true)
        end)
    else
        cb(false)
    end
end)
Previous[ESX] Car RentalNextConfig

Last updated 1 year ago

🚘
🛠️