Need Help on Payment

Hey :slight_smile:

Maybe anybody could Help. I try to change my Payment System for the Government Job.
I want to Pay specific Jobs (Jobs should be in Config) from the Government Account.

Anybody see the fail?

ESX.StartPayCheck = function()
function payCheck()
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

		if salary > 0 then
			if job == 'unemployed' then 
				xPlayer.addAccountMoney('bank', salary)
				TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('received_paycheck'), _U('received_help', salary), 'CHAR_BANK_MAZE', 9)
			elseif Config.EnableSocietyPayouts then -- possibly a society				

				if job == Config.PayfromState then
					TriggerEvent('esx_addonaccount:getSharedAccount', "society_state", 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('received_paycheck'), _U('received_salary', salary), 'CHAR_BANK_MAZE', 9)
						else
							TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), '', _U('company_nomoney'), 'CHAR_BANK_MAZE', 1)
							end
						end)
					end
				else
				TriggerEvent('esx_society:getSociety', xPlayer.job.name, function (society)
				end
				
					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('received_paycheck'), _U('received_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
						xPlayer.addAccountMoney('bank', salary)
						TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('received_paycheck'), _U('received_salary', salary), 'CHAR_BANK_MAZE', 9)
					end
				end)
			else -- generic job
				xPlayer.addAccountMoney('bank', salary)
				TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('received_paycheck'), _U('received_salary', salary), 'CHAR_BANK_MAZE', 9)
			end
		end
	end
	SetTimeout(Config.PaycheckInterval, payCheck)
end
SetTimeout(Config.PaycheckInterval, payCheck)

end

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.