From 4a8c95189fe4544f12ab2e2a0d1a58f965cd0dc9 Mon Sep 17 00:00:00 2001 From: Sylundef Date: Thu, 9 Nov 2017 14:57:13 +0100 Subject: [PATCH] Use mecano account when isMecanoJobOnly = true --- server/main.lua | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/server/main.lua b/server/main.lua index 45c410b2..3e27d1fe 100644 --- a/server/main.lua +++ b/server/main.lua @@ -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')