mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
Improved paycheck system, added advanced notifications, see desc
- Improved paycheck system
- we now take society money if there is any, or else the employees wont get a salary at all
- now using ESX.ShowAdvancedNotifications
This commit is contained in:
+37
-19
@@ -1,29 +1,47 @@
|
||||
ESX.StartPayCheck = function()
|
||||
|
||||
function payCheck()
|
||||
function payCheck()
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
for i=1, #xPlayers, 1 do
|
||||
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
|
||||
local job = xPlayer.job.grade_name
|
||||
local salary = xPlayer.job.grade_salary
|
||||
|
||||
for i=1, #xPlayers, 1 do
|
||||
if salary > 0 then
|
||||
if job == 'unemployed' then -- unemployed
|
||||
xPlayer.addAccountMoney('bank', salary)
|
||||
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('recived_money'), _U('recived_help', salary), 'CHAR_BANK_MAZE', 9)
|
||||
elseif job == 'employee' then -- generic job, not a society
|
||||
xPlayer.addAccountMoney('bank', salary)
|
||||
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('recived_money'), _U('recived_salary', salary), 'CHAR_BANK_MAZE', 9)
|
||||
else -- possibly a society
|
||||
TriggerEvent('esx_society:getSociety', xPlayer.job.name, function (society)
|
||||
if society ~= nil then -- verified society
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function (account)
|
||||
if account.money >= salary then -- does the society money to pay its employees?
|
||||
xPlayer.addAccountMoney('bank', salary)
|
||||
account.removeMoney(salary)
|
||||
|
||||
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('recived_money'), _U('recived_salary', salary), 'CHAR_BANK_MAZE', 9)
|
||||
else
|
||||
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), '', _U('company_nomoney'), 'CHAR_BANK_MAZE', 1)
|
||||
end
|
||||
end)
|
||||
else -- not a society, use 'employee' as grade name!
|
||||
xPlayer.addAccountMoney('bank', salary)
|
||||
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('recived_money'), _U('recived_salary', salary), 'CHAR_BANK_MAZE', 9)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
|
||||
end
|
||||
|
||||
if xPlayer.job.grade_salary > 0 then
|
||||
xPlayer.addMoney(xPlayer.job.grade_salary)
|
||||
SetTimeout(Config.PaycheckInterval, payCheck)
|
||||
|
||||
if xPlayer.job.grade_name == 'interim' then
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('rec_help') .. '~g~$' .. xPlayer.job.grade_salary)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('rec_salary') .. '~g~$' .. xPlayer.job.grade_salary)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
SetTimeout(Config.PaycheckInterval, payCheck)
|
||||
|
||||
end
|
||||
|
||||
SetTimeout(Config.PaycheckInterval, payCheck)
|
||||
SetTimeout(Config.PaycheckInterval, payCheck)
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user