Dont let model be changed, as it cant be changed in LS anyways and is used to cheat

Co-Authored-By: danishrp <danishrp@users.noreply.github.com>
This commit is contained in:
ElPumpo
2019-09-18 18:39:21 +02:00
parent 85835090f5
commit 96f9dab2a8
+24 -12
View File
@@ -1,6 +1,7 @@
ESX = nil
local Vehicles
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
local Vehicles = nil
RegisterServerEvent('esx_lscustom:buyMod')
AddEventHandler('esx_lscustom:buyMod', function(price)
@@ -9,11 +10,12 @@ AddEventHandler('esx_lscustom:buyMod', function(price)
price = tonumber(price)
if Config.IsMechanicJobOnly then
local societyAccount
local societyAccount = nil
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
societyAccount = account
end)
if price < societyAccount.money then
TriggerClientEvent('esx_lscustom:installMod', _source)
TriggerClientEvent('esx:showNotification', _source, _U('purchased'))
@@ -22,9 +24,7 @@ AddEventHandler('esx_lscustom:buyMod', function(price)
TriggerClientEvent('esx_lscustom:cancelInstallMod', _source)
TriggerClientEvent('esx:showNotification', _source, _U('not_enough_money'))
end
else
if price < xPlayer.getMoney() then
TriggerClientEvent('esx_lscustom:installMod', _source)
TriggerClientEvent('esx:showNotification', _source, _U('purchased'))
@@ -33,21 +33,33 @@ AddEventHandler('esx_lscustom:buyMod', function(price)
TriggerClientEvent('esx_lscustom:cancelInstallMod', _source)
TriggerClientEvent('esx:showNotification', _source, _U('not_enough_money'))
end
end
end)
RegisterServerEvent('esx_lscustom:refreshOwnedVehicle')
AddEventHandler('esx_lscustom:refreshOwnedVehicle', function(myCar)
MySQL.Async.execute('UPDATE `owned_vehicles` SET `vehicle` = @vehicle WHERE `plate` = @plate',
{
['@plate'] = myCar.plate,
['@vehicle'] = json.encode(myCar)
})
AddEventHandler('esx_lscustom:refreshOwnedVehicle', function(vehicleProps)
local xPlayer = ESX.GetPlayerFromId(source)
MySQL.Async.fetchAll('SELECT vehicle FROM owned_vehicles WHERE plate = @plate', {
['@plate'] = vehicleProps.plate
}, function(result)
if result[1] then
local vehicle = json.decode(result[1].vehicle)
if vehicleProps.model == vehicle.model then
MySQL.Async.execute('UPDATE owned_vehicles SET vehicle = @vehicle WHERE plate = @plate', {
['@plate'] = vehicleProps.plate,
['@vehicle'] = json.encode(vehicleProps)
})
else
print(('esx_lscustom: %s attempted to upgrade vehicle with mismatching vehicle model!'):format(xPlayer.identifier))
end
end
end)
end)
ESX.RegisterServerCallback('esx_lscustom:getVehiclesPrices', function(source, cb)
if Vehicles == nil then
if not Vehicles then
MySQL.Async.fetchAll('SELECT * FROM vehicles', {}, function(result)
local vehicles = {}