Merge pull request #12 from Sylundef/master

Use mecano account when isMecanoJobOnly = true
This commit is contained in:
Jérémie N'gadi
2017-12-02 19:23:52 +01:00
committed by GitHub
+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')