Use mecano account when isMecanoJobOnly = true

This commit is contained in:
Sylundef
2017-11-09 14:57:13 +01:00
parent 4f6fdf5a50
commit 4a8c95189f
+28 -11
View File
@@ -4,17 +4,34 @@ local Vehicles = nil
RegisterServerEvent('esx_lscustom:buyMod')
AddEventHandler('esx_lscustom:buyMod', function(price)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
price = tonumber(price)
if price > xPlayer.getMoney() then
TriggerClientEvent('esx_lscustom:cancelInstallMod', _source)
TriggerClientEvent('esx:showNotification', _source, _U('not_enough_money'))
else
xPlayer.removeMoney(price)
TriggerClientEvent('esx_lscustom:installMod', _source)
TriggerClientEvent('esx:showNotification', _source, _U('purchased'))
end
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
price = tonumber(price)
if Config.IsMecanoJobOnly == true then
local societyAccount = nil
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mecano', function(account)
societyAccount = account
end)
if price < societyAccount.money then
TriggerClientEvent('esx_lscustom:installMod', _source)
TriggerClientEvent('esx:showNotification', _source, _U('purchased'))
societyAccount.removeMoney(price)
else
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'))
xPlayer.removeMoney(price)
else
TriggerClientEvent('esx_lscustom:cancelInstallMod', _source)
TriggerClientEvent('esx:showNotification', _source, _U('not_enough_money'))
end
end
end)
RegisterServerEvent('esx_lscustom:refreshOwnedVehicle')