๐Ÿ–ฅ๏ธCompatibilities

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)

qb-vehicleshop/server.lua - Search this code:

RegisterNetEvent('qb-vehicleshop:server:buyShowroomVehicle', function(vehicle)
    local src = source
    vehicle = vehicle.buyVehicle
    local pData = QBCore.Functions.GetPlayer(src)
    local cid = pData.PlayerData.citizenid
    local cash = pData.PlayerData.money['cash']
    local bank = pData.PlayerData.money['bank']
    local vehiclePrice = QBCore.Shared.Vehicles[vehicle]['price']
    local plate = GeneratePlate()

    if cash > tonumber(vehiclePrice) then
        MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
            pData.PlayerData.license,
            cid,
            vehicle,
            GetHashKey(vehicle),
            '{}',
            plate,
            'pillboxgarage',
            0
        })
        TriggerClientEvent('QBCore:Notify', src, Lang:t('success.purchased'), 'success')
        TriggerClientEvent('qb-vehicleshop:client:buyShowroomVehicle', src, vehicle, plate)
        pData.Functions.RemoveMoney('cash', vehiclePrice, 'vehicle-bought-in-showroom')
    elseif bank > tonumber(vehiclePrice) then
        MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
            pData.PlayerData.license,
            cid,
            vehicle,
            GetHashKey(vehicle),
            '{}',
            plate,
            'pillboxgarage',
            0
        })
        TriggerClientEvent('QBCore:Notify', src, Lang:t('success.purchased'), 'success')
        TriggerClientEvent('qb-vehicleshop:client:buyShowroomVehicle', src, vehicle, plate)
        pData.Functions.RemoveMoney('bank', vehiclePrice, 'vehicle-bought-in-showroom')
    else
        TriggerClientEvent('QBCore:Notify', src, Lang:t('error.notenoughmoney'), 'error')
    end
end)

Replace with:

RegisterNetEvent('qb-vehicleshop:server:buyShowroomVehicle', function(vehicle)
    local src = source
    vehicle = vehicle.buyVehicle
    local pData = QBCore.Functions.GetPlayer(src)
    local cid = pData.PlayerData.citizenid
    local cash = pData.PlayerData.money['cash']
    local bank = pData.PlayerData.money['bank']
    local vehiclePrice = QBCore.Shared.Vehicles[vehicle]['price']
    local plate = GeneratePlate()

    if cash > tonumber(vehiclePrice) then
        MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
            pData.PlayerData.license,
            cid,
            vehicle,
            GetHashKey(vehicle),
            '{}',
            plate,
            'pillboxgarage',
            0
        })
        TriggerClientEvent('QBCore:Notify', src, Lang:t('success.purchased'), 'success')
        TriggerClientEvent('qb-vehicleshop:client:buyShowroomVehicle', src, vehicle, plate)
        pData.Functions.RemoveMoney('cash', vehiclePrice, 'vehicle-bought-in-showroom')
        exports["m-Insurance"]:GiveCarRegistration(src, plate, vehicle, 1, cid)
    elseif bank > tonumber(vehiclePrice) then
        MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
            pData.PlayerData.license,
            cid,
            vehicle,
            GetHashKey(vehicle),
            '{}',
            plate,
            'pillboxgarage',
            0
        })
        TriggerClientEvent('QBCore:Notify', src, Lang:t('success.purchased'), 'success')
        TriggerClientEvent('qb-vehicleshop:client:buyShowroomVehicle', src, vehicle, plate)
        pData.Functions.RemoveMoney('bank', vehiclePrice, 'vehicle-bought-in-showroom')
        exports["m-Insurance"]:GiveCarRegistration(src, plate, vehicle, 1, cid)
    else
        TriggerClientEvent('QBCore:Notify', src, Lang:t('error.notenoughmoney'), 'error')
    end
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

qb-ambulancejob/server/main.lua - Search this code:

RegisterNetEvent('hospital:server:SendToBed', function(bedId, isRevive)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    TriggerClientEvent('hospital:client:SendToBed', src, bedId, Config.Locations["beds"][bedId], isRevive)
    TriggerClientEvent('hospital:client:SetBed', -1, bedId, true)
    Player.Functions.RemoveMoney("bank", Config.BillCost , "respawned-at-hospital")
    exports['qb-management']:AddMoney("ambulance", Config.BillCost)
    TriggerClientEvent('hospital:client:SendBillEmail', src, Config.BillCost)
end)

Replace with:

RegisterNetEvent('hospital:server:SendToBed', function(bedId, isRevive)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    local citizenid = Player.PlayerData.citizenid

    TriggerClientEvent('hospital:client:SendToBed', src, bedId, Config.Locations["beds"][bedId], isRevive)
    TriggerClientEvent('hospital:client:SetBed', -1, bedId, true)

    exports['m-Insurance']:HasHealthInsurance(citizenid, function(hasInsurance)
        local billAmount = Config.BillCost
        local discount = 500

        if hasInsurance then
            billAmount = billAmount - discount
            Player.Functions.RemoveMoney("bank", billAmount, "respawned-at-hospital")
            exports['qb-management']:AddMoney("ambulance", billAmount)
        else
            Player.Functions.RemoveMoney("bank", Config.BillCost, "respawned-at-hospital")
            exports['qb-management']:AddMoney("ambulance", Config.BillCost)
        end

        TriggerClientEvent('hospital:client:SendBillEmail', src, Config.BillCost)
    end)
end)

QBCore.Functions.CreateCallback('ak47_qb_ambulancejob:hasmoney', function(source, cb, total)
    local xPlayer = QBCore.Functions.GetPlayer(source)
    local money = xPlayer.PlayerData.money['bank']

    if GetResourceState('m-Insurance') == 'started' then
        exports['m-Insurance']:HasHealthInsurance(xPlayer.PlayerData.citizenid, function(hasInsurance)
            if hasInsurance then
                local discount = 500
                local pay = total - discount

                if money >= pay and pay > 0 then
                    xPlayer.Functions.RemoveMoney("bank", pay, "respawned-at-hospital")
                    addSocietyMoney(pay)
                    cb(true)
                else
                    cb(false)
                end
            else
                if money >= total then
                    xPlayer.Functions.RemoveMoney('bank', total, "respawned-at-hospital")
                    addSocietyMoney(total)
                    cb(true)
                else
                    cb(false)
                end
            end
        end)
    else
        if money >= total then
            xPlayer.Functions.RemoveMoney('bank', total, "respawned-at-hospital")
            addSocietyMoney(total)
            cb(true)
        else
            cb(false)
        end
    end
end)

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

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 == "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 = exports["qb-core"]:GetCoreObject()
            local Player = QBCore.Functions.GetPlayer(source)
            
            exports["m-Insurance"]:GiveCarRegistration(source, plate, model, 1, Player.PlayerData.citizenid)
        end
    end
}

PS-MDT | Version: 2.7.3

  1. Open the file ui/app.js line 2639 to 2726 replace with this:

$("#dmv-search-input").keydown(async function (e) {
    if (e.keyCode === 13 && canSearchForVehicles == true) {
      let name = $("#dmv-search-input").val();
      if (name !== "") {
        canSearchForVehicles = false;
        $(".dmv-items").empty();
        $(".dmv-items").prepend(`<div class="profile-loader"></div>`);
  
        let result = await $.post(
          `https://${GetParentResourceName()}/searchVehicles`,
          JSON.stringify({
            name: name,
          })
        );
        if (result.length === 0) {
          $(".dmv-items").html(
            `
              <div class="profile-item" data-id="0">
                <div style="display: flex; flex-direction: column; margin-top: 2.5px; margin-left: 5px; width: 100%; padding: 5px;">
                  <div style="display: flex; flex-direction: column;">
                    <div class="profile-item-title">No Vehicles Matching that search</div>
                  </div>
                  <div class="profile-bottom-info"></div>
                </div>
              </div>
            `
          );
          canSearchForVehicles = true;
          return true;
        }
        $(".dmv-items").empty();
  
        let vehicleHTML = "";
  
        result.forEach((value) => {
          let paint = value.color;
          let impound = "red-tag";
          let bolo = "red-tag";
          let codefive = "red-tag";
          let stolen = "red-tag";
          let insurance = "red-tag";
          let registration = "red-tag";
  
          if (value.state == 'Impounded') {
            impound = "green-tag";
          }
  
          if (value.bolo) {
            bolo = "green-tag";
          }
  
          if (value.code) {
            codefive = "green-tag";
          }
  
          if (value.stolen) {
            stolen = "green-tag";
          }
  
          if (value.insurance === "Insured") {
            insurance = "green-tag";
          }
  
          if (value.registration === "Registered") {
            registration = "green-tag";
          }
  
          vehicleHTML += `
            <div class="dmv-item" data-id="${value.id}" data-dbid="${value.dbid}" data-plate="${value.plate}">
              <img src="${value.image}" class="dmv-image">
              <div style="display: flex; flex-direction: column; margin-top: 2.5px; margin-left: 5px; width: 100%; padding: 5px;">
                <div style="display: flex; flex-direction: column;">
                  <div class="dmv-item-title">${value.model}</div>
                  <div class="dmv-tags">
                    <div class="dmv-tag ${paint}-color">${value.colorName}</div>
                    <div class="dmv-tag ${impound}">Impound</div>
                    <div class="dmv-tag ${bolo}">BOLO</div>
                    <div class="dmv-tag ${stolen}">Stolen</div>
                    <div class="dmv-tag ${codefive}">Code 5</div>
                    <div class="dmv-tag ${insurance}">Insurance</div>
                    <div class="dmv-tag ${registration}">Registration</div>
                  </div>
                </div>
                <div class="dmv-bottom-info">
                  <div class="dmv-id">Plate: ${value.plate} ยท Owner: ${value.owner}</div>
                </div>
              </div>
            </div>
          `;
        });
  
        $(".dmv-items").html(vehicleHTML);
  
        canSearchForVehicles = true;
      }
    }
  });
  1. Open the server/main.lua line 1014 to 1066 and replace with:

QBCore.Functions.CreateCallback('mdt:server:SearchVehicles', function(source, cb, sentData)
	if not sentData then return cb({}) end
	local src = source
	local PlayerData = GetPlayerData(src)
	if not PermCheck(source, PlayerData) then return cb({}) end

	local Player = QBCore.Functions.GetPlayer(src)
	if Player then
		local JobType = GetJobType(Player.PlayerData.job.name)
		if JobType == 'police' or JobType == 'doj' then
			local vehicles = MySQL.query.await([[
				SELECT 
					pv.id, 
					pv.citizenid, 
					pv.plate, 
					pv.vehicle, 
					pv.mods, 
					pv.state, 
					p.charinfo 
				FROM 
					player_vehicles pv 
				LEFT JOIN players p ON pv.citizenid = p.citizenid
				WHERE 
					LOWER(pv.plate) LIKE :query OR LOWER(pv.vehicle) LIKE :query
				LIMIT 25
			]], {
				query = string.lower('%'..sentData..'%')
			})

			if not next(vehicles) then cb({}) return end

			for _, value in ipairs(vehicles) do
				local registrationResult = MySQL.query.await("SELECT plate FROM m_insurance_registration WHERE plate = ?", { value.plate })
				local insuranceResult = MySQL.query.await("SELECT plate FROM m_insurance_vehicles WHERE plate = ?", { value.plate })

				value.registration = next(registrationResult) and "Registered" or "Not Registered"
				value.insurance = next(insuranceResult) and "Insured" or "Not Insured"

				if value.state == 0 then
					value.state = "Out"
				elseif value.state == 1 then
					value.state = "Garaged"
				elseif value.state == 2 then
					value.state = "Impounded"
				end

				value.bolo = false
				local boloResult = GetBoloStatus(value.plate)
				if boloResult then
					value.bolo = true
				end

				value.code = false
				value.stolen = false
				value.image = "img/not-found.webp"
				local info = GetVehicleInformation(value.plate)
				if info then
					value.code = info['code5']
					value.stolen = info['stolen']
					value.image = info['image']
				end

				local ownerResult = json.decode(value.charinfo)
				value.owner = ownerResult['firstname'] .. " " .. ownerResult['lastname']
			end
			return cb(vehicles)
		end

		return cb({})
	end
end)

If you want the files with the correct code and you only replace:

Last updated