đĨī¸Compatibilities
okokVehicleShop
okokVehicleShop/sv_utils.lua - Search this:
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'
}, 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'
}, function (rowsChanged)
end)
else
MySQLexecute('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (@owner, @plate, @vehicle)',
{
['@owner'] = xPlayer.identifier,
['@plate'] = vehicleProps.plate:match( "^%s*(.-)%s*$" ),
['@vehicle'] = json.encode(vehicleProps)
}, function (rowsChanged)
end)
end
end)
Replace with this:
RegisterServerEvent(Config.EventPrefix..':setVehicleOwned')
AddEventHandler(Config.EventPrefix..':setVehicleOwned', function (vehicleProps, model, id)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local name = xPlayer.getName()
local identifier = GetPlayerIdentifier(_source, 0)
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'
}, 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'
}, function (rowsChanged)
end)
else
MySQLexecute('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (@owner, @plate, @vehicle)',
{
['@owner'] = xPlayer.identifier,
['@plate'] = vehicleProps.plate:match( "^%s*(.-)%s*$" ),
['@vehicle'] = json.encode(vehicleProps)
}, function (rowsChanged)
end)
end
local metadata = { description = 'Name: '..name..' \nPlate: '..vehicleProps.plate..' \nModel: '..model }
exports.ox_inventory:AddItem(_source, 'car_registration', 1, metadata)
MySQLexecute('INSERT INTO m_insurance_registration (plate, model, registration,identifier) VALUES (?, ?, ?, ?)', {vehicleProps.plate, model, 1, identifier})
end)
esx_vehicleshop
esx_vehicleshop/server/main.lua - Search this code:
RegisterServerEvent('esx_vehicleshop:setVehicleOwned')
AddEventHandler('esx_vehicleshop:setVehicleOwned', function (vehicleProps)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (@owner, @plate, @vehicle)',
{
['@owner'] = xPlayer.identifier,
['@plate'] = vehicleProps.plate,
['@vehicle'] = json.encode(vehicleProps)
}, function (rowsChanged)
TriggerClientEvent('esx:showNotification', _source, _U('vehicle_belongs', vehicleProps.plate))
end)
end)
Replace with:
RegisterServerEvent('esx_vehicleshop:setVehicleOwned')
AddEventHandler('esx_vehicleshop:setVehicleOwned', function (vehicleProps)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local name = xPlayer.getName()
local identifier = GetPlayerIdentifier(_source, 0)
MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (@owner, @plate, @vehicle)',
{
['@owner'] = xPlayer.identifier,
['@plate'] = vehicleProps.plate,
['@vehicle'] = json.encode(vehicleProps)
}, function (rowsChanged)
TriggerClientEvent('esx:showNotification', _source, _U('vehicle_belongs', vehicleProps.plate))
end)
local metadata = { description = 'Name: '..name..' \nPlate: '..vehicleProps.plate..' \nModel: '..vehicle }
exports.ox_inventory:AddItem(src, 'car_registration', 1, metadata)
MySQL.insert('INSERT INTO m_insurance_registration (plate, model, registration, char_id) VALUES (?, ?, ?, ?)', {vehicleProps.plate, vehicle, 1, identifier})
end)
qs-housing/server/custom/misc/buyHouse.lua - Replace all code with this:
RegisterServerEvent('housing:server:buyHouse')
AddEventHandler('housing:server:buyHouse', function(house, isCredit)
local house = house
local src = source
local pData = GetPlayerFromId(src)
local houses = #getHousesByIdentifier(pData.identifier) or 0
local totalFees
if Config.LimitOfHouses == 0 or houses < Config.LimitOfHouses then
if not Config.Houses[house] or not house then return end
local price = tonumber(Config.Houses[house].price)
local brokerfee = (price * Config.Taxes.AgencyFee) / 100
local bankfee = (price * Config.Taxes.BankFee) / 100
local taxes = (price * Config.Taxes.TaxesFee) / 100
if Config.Decimals then
totalFees = tonumber(price + brokerfee + bankfee + taxes)
else
totalFees = math.floor(tonumber(price + brokerfee + bankfee + taxes))
end
local HousePrice = totalFees
local eq = math.floor(HousePrice / Config.NumberOfPayments)
local Balance = GetBankMoney(src)
local timer = Config.NumberOfPayments * Config.CreditTime
local seller
local result = MySQL.Sync.fetchAll('SELECT * FROM houselocations WHERE name = @name', {
['@name'] = house,
})
if result[1].houseID then
house_ID = result[1].houseID
else
updateidhouse(result[1].house)
end
if result and result[1] and result[1].creator then
seller = GetPlayerIdentifier(result[1].creator)
end
if (Balance >= HousePrice) or (isCredit and Balance >= eq) then -- here
local prices = isCredit and HousePrice - eq or 0
MySQL.Async.execute("INSERT INTO `player_houses` (`house`, `"..identifierTypes.."`, `insideId`, `keyholders`, `decorations`, `stash`, `houseID`, `outfit`, `logout`, `decorateStash`, `charge`, `credit`, `creditPrice`, `timer`) VALUES ('" .. house .. "','" .. pData.identifier .. "', NULL, NULL, '{}', NULL, '" .. house_ID .. "', NULL, NULL, NULL, NULL, '" ..prices.. "', '" .. eq .. "', '" .. Config.CreditTime .. "')",{})
local hous = MySQL.Sync.fetchAll('SELECT * FROM houselocations WHERE name = @name', { ['@name'] = house })
if hous and hous[1] then
local moneyToRealState = (HousePrice / 100) * Config.PercentageForSell
MySQL.Async.execute("UPDATE `houselocations` SET `owned` = 1, `creator` = '" .. '' .. "' WHERE `name` = '" .. house .. "'", {}, function()
DebugPrint('A house was bought for ' .. json.encode(HousePrice) .. ' and ' .. moneyToRealState .. ' was sent to the real estate')
RemoveBankMoney(src, isCredit and eq or HousePrice) -- 21% Extra house costs
if result and result[1] and result[1].creator and result[1].creator ~= '' and result[1].creator ~= nil then
if seller then
AddBankMoney(seller.source, moneyToRealState)
if Config.Smartphone then
TriggerClientEvent('housing:client:sellerMail', seller.source, Lang('HOUSING_SMARTPHONE_MESSAGE_TITLE'), Lang('HOUSING_SMARTPHONE_MESSAGE_SUBJECT'), Lang('HOUSING_SMARTPHONE_MESSAGE_COMPLETE') .. math.floor(moneyToRealState / 2))
end
else
AddOfflineBank(result[1].creator, moneyToRealState)
end
end
if seller and Config.Society then
local societyName = GetJobName(seller.source)
local societyPaid = math.floor(tonumber((HousePrice / 100) * Config.SocietyPorcentage))
buyHouseSocietyMoney(src, societyName, societyPaid)
DebugPrint('Added ' .. societyPaid .. ' to the ' .. societyName .. ' society with ' .. Config.Society)
else
DebugPrint('The seller and creator of this house no longer has a character on your server, therefore he did not receive any salary in society...')
::continue::
end
Config.Houses[house].owned = true
Config.Houses[house].identifier = pData.identifier
Config.Houses[house].keys = {}
UpdateHouseServer(house, Config.Houses[house])
TriggerClientEvent('housing:client:changeClosestHouse', -1, house)
if Config.Webhooks.buyhouse ~= '' or not Config.Webhooks.buyhouse then
sendToDiscordBuyHouse(Config.WebhookTranslates['buyhouse']['title'],
Config.WebhookTranslates['buyhouse']['player'] .. ' ' .. GetPlayerName(src) ..
Config.WebhookTranslates['buyhouse']['license'] .. ' ' .. pData.identifier ..
Config.WebhookTranslates['buyhouse']['coords'] .. ' ' .. json.encode(Config.Houses[house].coords.enter.x) .. ', ' .. json.encode(Config.Houses[house].coords.enter.y) .. ', ' .. json.encode(Config.Houses[house].coords.enter.z) ..
Config.WebhookTranslates['buyhouse']['price'] .. ' $' .. HousePrice ..
Config.WebhookTranslates['buyhouse']['realestateMoney'] .. ' $' .. moneyToRealState,
7393279)
end
----------------------------------
-- m-Insurance
local inventory = "qb" -- "qb" or "ox"
local months = 1 -- 1 Month only when you player buy a house
local now = os.time()
local nowFormatted = os.date('%Y-%m-%d %H:%M:%S')
local expiration = now + months * 30 * 24 * 60 * 60
local expirationFormatted = os.date('%Y-%m-%d %H:%M:%S', expiration)
local formattedTodayDate = os.date('%Y-%m-%d', now)
local formattedEndDate = os.date('%Y-%m-%d', expiration)
local citizenid = pData.PlayerData.citizenid
local info = {
name = GetPlayerName(src),
citizenid = citizenid,
date = formattedTodayDate,
expire = formattedEndDate,
}
if Inventory == "qb" then
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["home_insurance"], 'add')
pData.Functions.AddItem('home_insurance', 1, false, info)
elseif Inventory == "ox" then
local metadata = { description = 'Name: ' .. name .. ' \nCitizenID: ' .. citizenid .. ' \nDate: ' .. info.date .. ' \nExpire: ' .. info.expire }
exports.ox_inventory:AddItem(src, 'home_insurance', 1, metadata)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["home_insurance"], 'add')
end
MySQL.insert('INSERT INTO m_insurance_home (citizenid, creation_date, expire_date) VALUES (?, ?, ?)', {citizenid, nowFormatted, expirationFormatted})
-- m-Insurance
----------------------------------
end)
else
MySQL.Async.execute('INSERT INTO houselocations (name, label, coords, owned, price, tier, garage) VALUES (@name, @label, @coords, @owned, @price, @tier, @garage)', {
['@name'] = house,
['@label'] = house,
['@coords'] = json.encode(Config.Houses[house].coords),
['@owned'] = 1,
['@price'] = HousePrice,
['@tier'] = Config.Houses[house].tier,
['@garage'] = json.encode(Config.Houses[house].garage)
}, {}, function()
local moneyToRealState = (HousePrice / 100) * Config.PercentageForSell
RemoveBankMoney(src, isCredit and eq or HousePrice) -- 21% Extra house costs
DebugPrint('A house was bought for ' .. json.encode(HousePrice) .. ' and ' .. moneyToRealState .. ' was sent to the real estate')
if result and result[1] and result[1].creator and result[1].creator ~= '' and result[1].creator ~= nil then
if seller then
AddBankMoney(seller.source, moneyToRealState)
if Config.Smartphone then
TriggerClientEvent('housing:client:sellerMail', seller.source, Lang('HOUSING_SMARTPHONE_MESSAGE_TITLE'), Lang('HOUSING_SMARTPHONE_MESSAGE_SUBJECT'), Lang('HOUSING_SMARTPHONE_MESSAGE_COMPLETE') .. math.floor(moneyToRealState / 2))
end
else
AddOfflineBank(result[1].creator, moneyToRealState)
end
end
if seller and Config.Society then
local societyName = GetJobName(seller.source)
local societyPaid = math.floor(tonumber((HousePrice / 100) * Config.SocietyPorcentage))
buyHouseSocietyMoney(src, societyName, societyPaid)
DebugPrint('Added ' .. societyPaid .. ' to the ' .. societyName .. ' society with ' .. Config.Society)
else
DebugPrint('The seller and creator of this house no longer has a character on your server, therefore he did not receive any salary in society...')
::continue::
end
Config.Houses[house] = {
coords = Config.Houses[house].coords,
owned = true,
price = HousePrice,
locked = true,
adress = house,
tier = Config.Houses[house].tier,
garage = Config.Houses[house].garage,
decorations = Config.Houses[house].decorations or {},
mlo = {},
identifier = pData.identifier,
keys = {},
houseID = houseID,
}
UpdateHouseServer(house, Config.Houses[house])
TriggerClientEvent('housing:client:changeClosestHouse', -1, house)
if Config.WebhookEnable.buyhouse then
sendToDiscordBuyHouse(Config.WebhookTranslates['buyhouse']['title'],
Config.WebhookTranslates['buyhouse']['player'] .. ' ' .. GetPlayerName(src) ..
Config.WebhookTranslates['buyhouse']['license'] .. ' ' .. pData.identifier ..
Config.WebhookTranslates['buyhouse']['coords'] .. ' ' .. json.encode(Config.Houses[house].coords.enter.x) .. ', ' .. json.encode(Config.Houses[house].coords.enter.y) .. ', ' .. json.encode(Config.Houses[house].coords.enter.z) ..
Config.WebhookTranslates['buyhouse']['price'] .. ' $' .. HousePrice ..
Config.WebhookTranslates['buyhouse']['realestateMoney'] .. ' $' .. moneyToRealState,
7393279)
end
----------------------------------
-- m-Insurance
local inventory = "qb" -- "qb" or "ox"
local months = 1 -- 1 Month only when you player buy a house
local now = os.time()
local nowFormatted = os.date('%Y-%m-%d %H:%M:%S')
local expiration = now + months * 30 * 24 * 60 * 60
local expirationFormatted = os.date('%Y-%m-%d %H:%M:%S', expiration)
local formattedTodayDate = os.date('%Y-%m-%d', now)
local formattedEndDate = os.date('%Y-%m-%d', expiration)
local citizenid = pData.PlayerData.citizenid
local info = {
name = GetPlayerName(src),
citizenid = citizenid,
date = formattedTodayDate,
expire = formattedEndDate,
}
if Inventory == "qb" then
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["home_insurance"], 'add')
pData.Functions.AddItem('home_insurance', 1, false, info)
elseif Inventory == "ox" then
local metadata = { description = 'Name: ' .. name .. ' \nCitizenID: ' .. citizenid .. ' \nDate: ' .. info.date .. ' \nExpire: ' .. info.expire }
exports.ox_inventory:AddItem(src, 'home_insurance', 1, metadata)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["home_insurance"], 'add')
end
MySQL.insert('INSERT INTO m_insurance_home (citizenid, creation_date, expire_date) VALUES (?, ?, ?)', {citizenid, nowFormatted, expirationFormatted})
-- m-Insurance
----------------------------------
end)
end
DebugPrint('Home purchase for $' .. HousePrice .. '...')
else
TriggerClientEvent('housing:client:sendMessage', src, Lang('HOUSING_NOTIFICATION_NO_MONEY'), 'error')
end
else
TriggerClientEvent('housing:client:sendMessage', src, Lang('HOUSING_NOTIFICATION_HOUSE_LIMIT'), 'error')
end
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
local info = {}
info.name = Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname
info.plate = plate
info.model = modelName
if Config.Inventory == "qb" then
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["car_registration"], 'add')
Player.Functions.AddItem('car_registration', 1, false, info)
elseif Config.Inventory == "ox" then
local metadata = { description = 'Name: '..name..' \nPlate: '..plate..' \nModel: '..modelName }
exports.ox_inventory:AddItem(src, 'car_registration', 1, metadata)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["car_registration"], 'add')
end
MySQL.insert('INSERT INTO m_insurance_registration (plate, model, registration, citizenid) VALUES (?, ?, ?, ?)', {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)
local metadata = { description = 'Name: '..name..' \nPlate: '..plate..' \nModel: '..modelName }
exports.ox_inventory:AddItem(src, 'car_registration', 1, metadata)
MySQL.insert('INSERT INTO m_insurance_registration (plate, model, registration, char_id) VALUES (?, ?, ?, ?)', {plate, modelName, 1, identifier})
end
end)
end
config.lua - Add this code:
-- m-Insurance
Config.InsuranceEnable = true -- Enable m-Insurance?
Config.Inventory = "qb" -- "qb" or "ox"
-- m-Insurance
config.lua
Config.mInsurance = {
enable = true, -- Enable use m-Insurance?
inventory = "qb", -- "qb" or "ox" | If you use esx leave this "ox"
}
server/editable.lua
function addVehicleToGarage(PlayerData, vehicle, mods, plate)
if Config.Core == 'qb' then
MySQL.insert('INSERT INTO `player_vehicles` (license, citizenid, vehicle, hash, mods, plate) VALUES (?, ?, ?, ?, ?, ?)', { PlayerData.license, PlayerData.citizenid, vehicle, GetHashKey(vehicle), json.encode(mods), plate })
if Config.mInsurance.enable then
local info = {}
info.name = PlayerData.charinfo.firstname .. " " .. PlayerData.charinfo.lastname
info.plate = plate
info.model = vehicle
if Config.mInsurance.inventory == "qb" then
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["car_registration"], 'add')
xPlayer.Functions.AddItem('car_registration', 1, false, info)
elseif Config.mInsurance.inventory == "ox" then
local metadata = { description = 'Name: '..name..' \nPlate: '..plate..' \nModel: '..vehicle }
exports.ox_inventory:AddItem(src, 'car_registration', 1, metadata)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["car_registration"], 'add')
end
end
MySQL.insert('INSERT INTO m_insurance_registration (plate, model, registration, citizenid) VALUES (?, ?, ?, ?)', {plate, vehicle, 1, PlayerData.citizenid})
elseif Config.Core == 'esx' then
MySQL.insert('INSERT INTO `owned_vehicles` (owner, plate, vehicle) VALUES (?, ?, ?)', { PlayerData.identifier, plate, json.encode({model = joaat(vehicle), plate = plate}) })
if Config.mInsurance.enable then
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
local name = xPlayer.getName()
local identifier = GetPlayerIdentifierByType(src, "license")
local metadata = { description = 'Name: '..name..' \nPlate: '..plate..' \nModel: '..vehicle }
exports.ox_inventory:AddItem(src, 'car_registration', 1, metadata)
MySQL.insert('INSERT INTO m_insurance_registration (plate, model, registration, char_id) VALUES (?, ?, ?, ?)', {plate, vehicle, 1, identifier})
end
end
end
Last updated