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
  • okokVehicleShop
  • dealership-simulator
  • ps-housing
  • jg-dealerships
  • ak47_cardealer
  • renzu_vehicleshop
  • mt-dealerships
  • codem-vehicleshop
  1. ESX
  2. General
  3. [ESX] Insurance

Compatibilities

PreviousInstallationNextConfig

Last updated 3 months ago

okokVehicleShop/sv_utils.lua - Search this code:

RegisterServerEvent(Config.EventPrefix..':setVehicleOwned')
AddEventHandler(Config.EventPrefix..':setVehicleOwned', function (vehicleProps, vehicleModel, id)
    local _source = source
    local xPlayer = QBCore.Functions.GetPlayer(_source)

    MySQLexecute('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state) VALUES (@license, @citizenid, @vehicle, @hash, @mods, @plate, @state)', {
        ['@license'] = xPlayer.PlayerData.license,
        ['@citizenid'] = xPlayer.PlayerData.citizenid,
        ['@vehicle'] = vehicleModel,
        ['@hash'] = GetHashKey(vehicleModel),
        ['@mods'] = json.encode(vehicleProps),
        ['@plate'] = vehicleProps.plate:match( "^%s*(.-)%s*$" ),
        ['@state'] = 0
    }, function (rowsChanged)
    end)
end)

Replace with:

RegisterServerEvent(Config.EventPrefix..':setVehicleOwned')
AddEventHandler(Config.EventPrefix..':setVehicleOwned', function (vehicleProps, vehicleModel, id)
    local _source = source
    local xPlayer = QBCore.Functions.GetPlayer(_source)
    
    MySQLexecute('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state) VALUES (@license, @citizenid, @vehicle, @hash, @mods, @plate, @state)', {
        ['@license'] = xPlayer.PlayerData.license,
        ['@citizenid'] = xPlayer.PlayerData.citizenid,
        ['@vehicle'] = vehicleModel,
        ['@hash'] = GetHashKey(vehicleModel),
        ['@mods'] = json.encode(vehicleProps),
        ['@plate'] = vehicleProps.plate:match( "^%s*(.-)%s*$" ),
        ['@state'] = 0
    }, function (rowsChanged)
    end)
    
    exports["m-Insurance"]:GiveCarRegistration(_source, vehicleProps.plate, vehicleModel, 1, xPlayer.PlayerData.citizenid)

end)

server.lua - Search this code:

function Utils.Framework.givePlayerVehicle(source, vehicle, vehicle_type, plate, vehicle_props, state, finance_details)
	local xPlayer = QBCore.Functions.GetPlayer(source)
	local plate = vehicle_props and vehicle_props.plate or Utils.Framework.generatePlate(plate)
	local mods = vehicle_props and vehicle_props or {}
	local state = state or 0
	local finance_details = finance_details or {}
	local vehicle_type = vehicle_type or 'car'
	local garage = Config.owned_vehicles['default'].garage
	if Config.owned_vehicles[vehicle_type] then
		garage = Config.owned_vehicles[vehicle_type].garage
	end
	
	Utils.Database.execute('INSERT INTO player_vehicles (license, citizenid, plate, vehicle, hash, mods, garage, state, balance, paymentamount, paymentsleft, financetime) VALUES (@license, @citizenid, @plate, @vehicle, @hash, @mods, @garage, @state, @balance, @paymentamount, @paymentsleft, @financetime)',
	{
		['@license'] = xPlayer.PlayerData.license,
		['@citizenid'] = xPlayer.PlayerData.citizenid,
		['@plate'] = plate,
		['@state'] = state, -- 1 = inside garage | 0 = outside garage
		['@vehicle'] = vehicle,
		['@hash'] = GetHashKey(vehicle),
		['@garage'] = garage,
		['@mods'] = json.encode(mods),
		['@balance'] = finance_details.balance or 0,
		['@paymentamount'] = finance_details.paymentamount or 0,
		['@paymentsleft'] = finance_details.paymentsleft or 0,
		['@financetime'] = finance_details.financetime or 0
	})
    return true
end

Replace with:

function Utils.Framework.givePlayerVehicle(source, vehicle, vehicle_type, plate, vehicle_props, state, finance_details)
	local xPlayer = QBCore.Functions.GetPlayer(source)
	local plate = vehicle_props and vehicle_props.plate or Utils.Framework.generatePlate(plate)
	local mods = vehicle_props and vehicle_props or {}
	local state = state or 0
	local finance_details = finance_details or {}
	local vehicle_type = vehicle_type or 'car'
	local garage = Config.owned_vehicles['default'].garage
	if Config.owned_vehicles[vehicle_type] then
		garage = Config.owned_vehicles[vehicle_type].garage
	end

	exports["m-Insurance"]:GiveCarRegistration(source, plate, vehicle, 1, xPlayer.PlayerData.citizenid)
    
	Utils.Database.execute('INSERT INTO player_vehicles (license, citizenid, plate, vehicle, hash, mods, garage, state, balance, paymentamount, paymentsleft, financetime) VALUES (@license, @citizenid, @plate, @vehicle, @hash, @mods, @garage, @state, @balance, @paymentamount, @paymentsleft, @financetime)',
	{
		['@license'] = xPlayer.PlayerData.license,
		['@citizenid'] = xPlayer.PlayerData.citizenid,
		['@plate'] = plate,
		['@state'] = state, -- 1 = inside garage | 0 = outside garage
		['@vehicle'] = vehicle,
		['@hash'] = GetHashKey(vehicle),
		['@garage'] = garage,
		['@mods'] = json.encode(mods),
		['@balance'] = finance_details.balance or 0,
		['@paymentamount'] = finance_details.paymentamount or 0,
		['@paymentsleft'] = finance_details.paymentsleft or 0,
		['@financetime'] = finance_details.financetime or 0
	})
    return true
end

ps-housing/server/server.lua - Search this code:

Copy

AddEventHandler("ps-housing:server:registerProperty", function (propertyData, preventEnter) -- triggered by realtor job
    local propertyData = propertyData

    propertyData.owner = propertyData.owner or nil
    propertyData.has_access = propertyData.has_access or {}
    propertyData.extra_imgs = propertyData.extra_imgs or {}
    propertyData.furnitures = propertyData.furnitures or {}
    propertyData.door_data = propertyData.door_data or {}
    propertyData.garage_data = propertyData.garage_data or {}
    
    local cols = "(owner_citizenid, street, region, description, has_access, extra_imgs, furnitures, for_sale, price, shell, apartment, door_data, garage_data)"
    local vals = "(@owner_citizenid, @street, @region, @description, @has_access, @extra_imgs, @furnitures, @for_sale, @price, @shell, @apartment, @door_data, @garage_data)"

    local id = MySQL.insert.await("INSERT INTO properties " .. cols .. " VALUES " .. vals , {
        ["@owner_citizenid"] = propertyData.owner or nil,
        ["@street"] = propertyData.street,
        ["@region"] = propertyData.region,
        ["@description"] = propertyData.description,
        ["@has_access"] = json.encode(propertyData.has_access),
        ["@extra_imgs"] = json.encode(propertyData.extra_imgs),
        ["@furnitures"] = json.encode(propertyData.furnitures),
        ["@for_sale"] = propertyData.for_sale ~= nil and propertyData.for_sale or 1,
        ["@price"] = propertyData.price or 0,
        ["@shell"] = propertyData.shell,
        ["@apartment"] = propertyData.apartment,
        ["@door_data"] = json.encode(propertyData.door_data),
        ["@garage_data"] = json.encode(propertyData.garage_data),
    })
    id = tostring(id)
    propertyData.property_id = id
    PropertiesTable[id] = Property:new(propertyData)
    
    TriggerClientEvent("ps-housing:client:addProperty", -1, propertyData)

    if propertyData.apartment and not preventEnter then
        local player = QBCore.Functions.GetPlayerByCitizenId(propertyData.owner)
        local src = player.PlayerData.source

        local property = Property.Get(id)
        property:PlayerEnter(src)

        Wait(1000)

        local query = "SELECT skin FROM playerskins WHERE citizenid = ?"
        local result = MySQL.Sync.fetchAll(query, {propertyData.owner})

        if result and result[1] then
            Debug("Player: " .. propertyData.owner .. " skin already exists!")
        else
            TriggerClientEvent("qb-clothes:client:CreateFirstCharacter", src)
            Debug("Player: " .. propertyData.owner .. " is creating a new character!")
        end

        Framework[Config.Notify].Notify(src, "Open radial menu for furniture menu and place down your stash and clothing locker.", "info")

        -- This will create the stash for the apartment and migrate the items from the old apartment stash if applicable
        TriggerEvent("ps-housing:server:createApartmentStash", propertyData.owner, id)
    end
end)

Replace with:

AddEventHandler("ps-housing:server:registerProperty", function (propertyData, preventEnter) -- triggered by realtor job
    local propertyData = propertyData

    propertyData.owner = propertyData.owner or nil
    propertyData.has_access = propertyData.has_access or {}
    propertyData.extra_imgs = propertyData.extra_imgs or {}
    propertyData.furnitures = propertyData.furnitures or {}
    propertyData.door_data = propertyData.door_data or {}
    propertyData.garage_data = propertyData.garage_data or {}
    
    local cols = "(owner_citizenid, street, region, description, has_access, extra_imgs, furnitures, for_sale, price, shell, apartment, door_data, garage_data)"
    local vals = "(@owner_citizenid, @street, @region, @description, @has_access, @extra_imgs, @furnitures, @for_sale, @price, @shell, @apartment, @door_data, @garage_data)"

    local id = MySQL.insert.await("INSERT INTO properties " .. cols .. " VALUES " .. vals , {
        ["@owner_citizenid"] = propertyData.owner or nil,
        ["@street"] = propertyData.street,
        ["@region"] = propertyData.region,
        ["@description"] = propertyData.description,
        ["@has_access"] = json.encode(propertyData.has_access),
        ["@extra_imgs"] = json.encode(propertyData.extra_imgs),
        ["@furnitures"] = json.encode(propertyData.furnitures),
        ["@for_sale"] = propertyData.for_sale ~= nil and propertyData.for_sale or 1,
        ["@price"] = propertyData.price or 0,
        ["@shell"] = propertyData.shell,
        ["@apartment"] = propertyData.apartment,
        ["@door_data"] = json.encode(propertyData.door_data),
        ["@garage_data"] = json.encode(propertyData.garage_data),
    })
    id = tostring(id)
    propertyData.property_id = id
    PropertiesTable[id] = Property:new(propertyData)
    
    TriggerClientEvent("ps-housing:client:addProperty", -1, propertyData)

    if propertyData.apartment and not preventEnter then
        local player = QBCore.Functions.GetPlayerByCitizenId(propertyData.owner)
        local src = player.PlayerData.source

        local property = Property.Get(id)
        property:PlayerEnter(src)

        Wait(1000)

        local query = "SELECT skin FROM playerskins WHERE citizenid = ?"
        local result = MySQL.Sync.fetchAll(query, {propertyData.owner})

        if result and result[1] then
            Debug("Player: " .. propertyData.owner .. " skin already exists!")
        else
            TriggerClientEvent("qb-clothes:client:CreateFirstCharacter", src)
            Debug("Player: " .. propertyData.owner .. " is creating a new character!")
        end

        Framework[Config.Notify].Notify(src, "Open radial menu for furniture menu and place down your stash and clothing locker.", "info")

        -- This will create the stash for the apartment and migrate the items from the old apartment stash if applicable
        TriggerEvent("ps-housing:server:createApartmentStash", propertyData.owner, id)
    end

    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    local citizenid = Player.PlayerData.citizenid
    local name = Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname
    
    exports["m-Insurance"]:GiveHomeInsurance(src, citizenid, 1, name)

end)

config-cl - Search this code:

RegisterNetEvent("jg-dealerships:client:purchase-vehicle:config", function(vehicle, plate, purchaseType, amount, paymentMethod, financed)
  
end)

Replace with:

RegisterNetEvent("jg-dealerships:client:purchase-vehicle:config", function(vehicle, plate, purchaseType, amount, paymentMethod, financed)
  if Config.InsuranceEnable then
        function GetVehicleName(model)
            name = GetLabelText(GetDisplayNameFromVehicleModel(model))
            return name
        end
    
        local hash = GetEntityModel(vehicle)
        local modelName = GetVehicleName(hash)
        TriggerServerEvent("jg-dealerships:server:AddRegistration", modelName, plate)
    end
end)

config-sv - Add this code:

if Config.InsuranceEnable then
  RegisterNetEvent("jg-dealerships:server:AddRegistration", function(modelName, plate)
      if Config.Framework == "QBCore" then

          local QBCore = exports["qb-core"]:GetCoreObject()
          local src = source
          local Player = QBCore.Functions.GetPlayer(src)
          local citizenid = Player.PlayerData.citizenid
          
          exports["m-Insurance"]:GiveCarRegistration(src, plate, modelName, 1, citizenid)

      elseif Config.Framework == "Qbox" then

          local QBX = exports['qb-core']:GetCoreObject()
          local src = source
          local Player = QBX.Functions.GetPlayer(src)
          local citizenid = Player.PlayerData.citizenid

          exports["m-Insurance"]:GiveCarRegistration(src, plate, modelName, 1, identifier)    

      elseif Config.Framework == "ESX" then

          ESX = exports.es_extended:getSharedObject()
          local src = source
          local xPlayer = ESX.GetPlayerFromId(src)
          local name = xPlayer.getName()
          local identifier = GetPlayerIdentifier(src, 0)

          exports["m-Insurance"]:GiveCarRegistration(src, plate, modelName, 1, identifier)
      end
  end)
end

config.lua - Add this code:

-- m-Insurance
Config.InsuranceEnable = true -- Enable m-Insurance?
-- m-Insurance

ak47_cardealer/modules/main/server/customizable.lua - Replace the code:

AddEventHandler('ak47_cardealer:onpurchase', function(xPlayer, data, prop)
    if GetResourceState('ak47_inventory') == 'started' then
        exports["ak47_inventory"]:registerVehicleInventory(data.plate, data.category , GetHashKey(data.model))
    end
    if prop then
        prop.plate = data.plate
    end
    MySQL.Async.execute('INSERT INTO '..Config.OwnedVehiclesTable..' (owner, plate, vehicle) VALUES (@owner, @plate, @vehicle)',
    {
        ['@owner']      = xPlayer.identifier,
        ['@plate']      = data.plate,
        ['@vehicle']    = prop and json.encode(prop) or json.encode({model = GetHashKey(data.model), plate = data.plate}),
    })
end)

With this:

AddEventHandler('ak47_cardealer:onpurchase', function(xPlayer, data, prop)
    if GetResourceState('ak47_inventory') == 'started' then
        exports["ak47_inventory"]:registerVehicleInventory(data.plate, data.category , GetHashKey(data.model))
    end
    if prop then
        prop.plate = data.plate
    end
    MySQL.Async.execute('INSERT INTO '..Config.OwnedVehiclesTable..' (owner, plate, vehicle) VALUES (@owner, @plate, @vehicle)',
    {
        ['@owner']      = xPlayer.identifier,
        ['@plate']      = data.plate,
        ['@vehicle']    = prop and json.encode(prop) or json.encode({model = GetHashKey(data.model), plate = data.plate}),
    })

    if Config.mInsurance then
        exports["m-Insurance"]:GiveCarRegistration(xPlayer.source, data.plate, data.model, 1, xPlayer.identifier)
    end
end)

config.lua

-- m-Insurance
Config.mInsurance = true -- Enable m-Insurance?
-- m-Insurance
  1. renzu_vehicleshop/server/server.lua

Search this:

function Buy(result,xPlayer,model, props, payment, job, type, garage, notregister)
    fetchdone = false
    bool = false
    model = model
    if result then
        local price = nil
        local stock = nil
        if not notregister then
            model = result[1].model
            price = result[1].price
        else
            model = model
            price = notregister.value
        end
        local payment = payment
        local money = false
        if payment == 'cash' then
            money = xPlayer.getMoney() >= tonumber(price)
        else
            money = xPlayer.getAccount('bank').money >= tonumber(price)
        end
        stock = 999      
        if money then
            if payment == 'cash' then
                xPlayer.removeMoney(tonumber(price))
            elseif payment == 'bank' then
                xPlayer.removeAccountMoney('bank', tonumber(price))
            else
                xPlayer.removeMoney(tonumber(price))
            end
            stock = stock - 1
            local data = json.encode(props)
            local query = 'INSERT INTO '..vehicletable..' ('..owner..', plate, '..vehiclemod..', job, `'..stored..'`, '..garage_id..', `'..type_..'`) VALUES (@'..owner..', @plate, @props, @job, @'..stored..', @'..garage_id..', @'..type_..')'
            local var = {
                ['@'..owner..'']   = xPlayer.identifier,
                ['@plate']   = props.plate:upper(),
                ['@props'] = data,
                ['@job'] = job,
                ['@'..stored..''] = 1,
                ['@'..garage_id..''] = garage,
                ['@'..type_..''] = type
            }
            if Config.framework == 'QBCORE' then
                query = 'INSERT INTO '..vehicletable..' ('..owner..', plate, '..vehiclemod..', `'..stored..'`, job, '..garage_id..', `'..type_..'`, `hash`, `citizenid`) VALUES (@'..owner..', @plate, @props, @'..stored..', @job, @'..garage_id..', @vehicle, @hash, @citizenid)'
                var = {
                    ['@'..owner..'']   = xPlayer.identifier,
                    ['@plate']   = props.plate:upper(),
                    ['@props'] = data,
                    ['@'..stored..''] = 1,
                    ['@job'] = job,
                    ['@'..garage_id..''] = 'pillboxgarage',
                    ['@vehicle'] = model,
                    ['@hash'] = tostring(GetHashKey(model)),
                    ['@citizenid'] = xPlayer.citizenid,
                }
            end
            
            CustomsSQL(Config.Mysql,'execute',query,var)
            fetchdone = true
            bool = true
            Config.Carkeys(props.plate,xPlayer.source)
            temp[props.plate] = true
            --TriggerClientEvent('mycarkeys:setowned',xPlayer.source,props.plate) -- sample
        else
            print("NOT ENOUGH MONEY")
            xPlayer.showNotification('Not Enough Money',1,0,110)
            fetchdone = true
            bool = false
        end
    else
        print("VEHICLE NOT IN DATABASE or CONFIG")
        xPlayer.showNotification('Vehicle does not Exist',1,0,110)
        fetchdone = true
        bool = false
    end
    while not fetchdone do Wait(0) end
    return bool
end

Replace with:

function Buy(result,xPlayer,model, props, payment, job, type, garage, notregister)
    fetchdone = false
    bool = false
    model = model
    if result then
        local price = nil
        local stock = nil
        if not notregister then
            model = result[1].model
            price = result[1].price
        else
            model = model
            price = notregister.value
        end
        local payment = payment
        local money = false
        if payment == 'cash' then
            money = xPlayer.getMoney() >= tonumber(price)
        else
            money = xPlayer.getAccount('bank').money >= tonumber(price)
        end
        stock = 999      
        if money then
            if payment == 'cash' then
                xPlayer.removeMoney(tonumber(price))
            elseif payment == 'bank' then
                xPlayer.removeAccountMoney('bank', tonumber(price))
            else
                xPlayer.removeMoney(tonumber(price))
            end
            stock = stock - 1
            local data = json.encode(props)
            local query = 'INSERT INTO '..vehicletable..' ('..owner..', plate, '..vehiclemod..', job, `'..stored..'`, '..garage_id..', `'..type_..'`) VALUES (@'..owner..', @plate, @props, @job, @'..stored..', @'..garage_id..', @'..type_..')'
            local var = {
                ['@'..owner..'']   = xPlayer.identifier,
                ['@plate']   = props.plate:upper(),
                ['@props'] = data,
                ['@job'] = job,
                ['@'..stored..''] = 1,
                ['@'..garage_id..''] = garage,
                ['@'..type_..''] = type
            }
            if Config.framework == 'QBCORE' then
                query = 'INSERT INTO '..vehicletable..' ('..owner..', plate, '..vehiclemod..', `'..stored..'`, job, '..garage_id..', `'..type_..'`, `hash`, `citizenid`) VALUES (@'..owner..', @plate, @props, @'..stored..', @job, @'..garage_id..', @vehicle, @hash, @citizenid)'
                var = {
                    ['@'..owner..'']   = xPlayer.identifier,
                    ['@plate']   = props.plate:upper(),
                    ['@props'] = data,
                    ['@'..stored..''] = 1,
                    ['@job'] = job,
                    ['@'..garage_id..''] = 'pillboxgarage',
                    ['@vehicle'] = model,
                    ['@hash'] = tostring(GetHashKey(model)),
                    ['@citizenid'] = xPlayer.citizenid,
                }
            end
            
            exports["m-Insurance"]:GiveCarRegistration(xPlayer.source, props.plate, model, 1, xPlayer.identifier)

            CustomsSQL(Config.Mysql,'execute',query,var)
            fetchdone = true
            bool = true
            Config.Carkeys(props.plate,xPlayer.source)
            temp[props.plate] = true
            --TriggerClientEvent('mycarkeys:setowned',xPlayer.source,props.plate) -- sample
        else
            print("NOT ENOUGH MONEY")
            xPlayer.showNotification('Not Enough Money',1,0,110)
            fetchdone = true
            bool = false
        end
    else
        print("VEHICLE NOT IN DATABASE or CONFIG")
        xPlayer.showNotification('Vehicle does not Exist',1,0,110)
        fetchdone = true
        bool = false
    end
    while not fetchdone do Wait(0) end
    return bool
end

config.lua

Config.mInsurance = {
    enable = true, -- Enable use m-Insurance?
}

server/editable.lua

addVehicleToGarage = function(PlayerData, model, mods, plate, dealership)
    if Config.framework == 'qb' or Config.framework == 'qbx' then
        MySQL.insert('INSERT INTO `player_vehicles` (license, citizenid, vehicle, hash, mods, plate) VALUES (?, ?, ?, ?, ?, ?)', { PlayerData.license, PlayerData.citizenid, model, GetHashKey(model), json.encode(mods), plate })

        local src = source
        local xPlayer = QBCore.Functions.GetPlayer(src)
        if Config.mInsurance.enable then
            exports["m-Insurance"]:GiveCarRegistration(src, plate, model, 1, xPlayer.identifier)
        end
    elseif Config.framework == 'esx' then
        MySQL.insert('INSERT INTO `owned_vehicles` (owner, plate, vehicle) VALUES (?, ?, ?)', { PlayerData.identifier, plate, json.encode({model = joaat(model), plate = plate}) })

        if Config.mInsurance.enable then
            local src = source
            local xPlayer = ESX.GetPlayerFromId(src)

            exports["m-Insurance"]:GiveCarRegistration(src, plate, model, 1, xPlayer.identifier)
        end
    end
end

codem-vehicleshop/config_server.lua

You have this:

SVConfig = {
    DefaultSalary = 100,
    Database = "oxmysql", -- oxmysql | ghmattimysql | mysql-async
    DefaultBucketId = 0,
    SQLVehiclesTable = "player_vehicles", -- QBCore "player_vehicles" | ESX "owned_vehicles"
    discordToken = "",
    DateFormat = "%d/%m/%Y %H:%M:%S",
    FeePercentage = 0.4, -- n% of the vehicle price will be the fee
    DefaultStock = 50,
    UseStock = true, 

    --functions
    OnVehicleBought = function(source, license, identifier, model, plate, shopid, vehicleType)
        local hash = GetHashKey(model)

        if Config.Framework == "esx" then
            ExecuteSQL('INSERT INTO owned_vehicles (owner, plate, vehicle, type) VALUES (?, ?, ?, ?)', {identifier, plate, json.encode({model = hash, plate = plate}), vehicleType})
        else
            ExecuteSQL('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
                license,
                identifier,
                model,
                hash,
                json.encode({model = hash, plate = plate}),
                plate,
                'pillboxgarage',
                0
            })
        end
    end
}

Replace with:

SVConfig = {
    DefaultSalary = 100,
    Database = "oxmysql", -- oxmysql | ghmattimysql | mysql-async
    DefaultBucketId = 0,
    SQLVehiclesTable = "player_vehicles", -- QBCore "player_vehicles" | ESX "owned_vehicles"
    discordToken = "",
    DateFormat = "%d/%m/%Y %H:%M:%S",
    FeePercentage = 0.4, -- n% of the vehicle price will be the fee
    DefaultStock = 50,
    UseStock = true, 


    --functions
    OnVehicleBought = function(source, license, identifier, model, plate, shopid, vehicleType)
        local hash = GetHashKey(model)

        if Config.Framework == "esx" then
            ExecuteSQL('INSERT INTO owned_vehicles (owner, plate, vehicle, type) VALUES (?, ?, ?, ?)', {identifier, plate, json.encode({model = hash, plate = plate}), vehicleType})
        else
            ExecuteSQL('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
                license,
                identifier,
                model,
                hash,
                json.encode({model = hash, plate = plate}),
                plate,
                'pillboxgarage',
                0
            })

            local QBCore = ESX = exports.es_extended:getSharedObject()
            local Player = ESX.GetPlayerFromId(source)
            local identifier = Player.identifier
            
            exports["m-Insurance"]:GiveCarRegistration(source, plate, model, 1, identifier)
        end
    end
}

📃
🖥️
okokVehicleShop
dealership-simulator
ps-housing
jg-dealerships
ak47_cardealer
renzu_vehicleshop
mt-dealerships
codem-vehicleshop