Paycheck transactions
Change it carefully!
ESX
IF NOT USE our police / ambulance job script.
File es_extended/server/paycheck.lua
if salary > 0 then
if job == 'unemployed' then -- unemployed
xPlayer.addAccountMoney('bank', salary, "Welfare Check")
TriggerClientEvent('brutal_banking:client:AddTransaction', player, salary, 'add', 'Salary')
TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'), TranslateCap('received_help', salary),
'CHAR_BANK_MAZE', 9)
elseif Config.EnableSocietyPayouts then -- 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, "Paycheck")
account.removeMoney(salary)
TriggerClientEvent('brutal_banking:client:AddTransaction', player, salary, 'add', 'Salary')
TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'),
TranslateCap('received_salary', salary), 'CHAR_BANK_MAZE', 9)
else
TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), '', TranslateCap('company_nomoney'), 'CHAR_BANK_MAZE', 1)
end
end)
else -- not a society
xPlayer.addAccountMoney('bank', salary, "Paycheck")
TriggerClientEvent('brutal_banking:client:AddTransaction', player, salary, 'add', 'Salary')
TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'), TranslateCap('received_salary', salary),
'CHAR_BANK_MAZE', 9)
end
end)
else -- generic job
xPlayer.addAccountMoney('bank', salary, "Paycheck")
TriggerClientEvent('brutal_banking:client:AddTransaction', player, salary, 'add', 'Salary')
TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'), TranslateCap('received_salary', salary),
'CHAR_BANK_MAZE', 9)
end
end
NEW QBCORE
File qb-core/server/functions.lua
function PaycheckInterval()
if next(QBCore.Players) then
for _, Player in pairs(QBCore.Players) do
if Player then
local payment = QBShared.Jobs[Player.PlayerData.job.name]['grades'][tostring(Player.PlayerData.job.grade.level)].payment
if not payment then payment = Player.PlayerData.job.payment end
if Player.PlayerData.job and payment > 0 and (QBShared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
if QBCore.Config.Money.PayCheckSociety then
local account = exports['qb-management']:GetAccount(Player.PlayerData.job.name)
if account ~= 0 then -- Checks if player is employed by a society
if account < payment then -- Checks if company has enough money to pay society
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('error.company_too_poor'), 'error')
else
Player.Functions.AddMoney('bank', payment)
exports['qb-management']:RemoveMoney(Player.PlayerData.job.name, payment)
TriggerClientEvent('brutal_banking:client:AddTransaction', Player.PlayerData.source, payment, 'add', 'Salary')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
end
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('brutal_banking:client:AddTransaction', Player.PlayerData.source, payment, 'add', 'Salary')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
end
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('brutal_banking:client:AddTransaction', Player.PlayerData.source, payment, 'add', 'Salary')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
end
end
end
end
end
SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckInterval)
end
OLD QBCORE
File qb-core/server/functions.lua
function PaycheckLoop()
local Players = QBCore.Functions.GetQBPlayers()
for _, Player in pairs(Players) do
local payment = Player.PlayerData.job.payment
if Player.PlayerData.job and payment > 0 and (QBShared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
if QBCore.Config.Money.PayCheckSociety then
local account = exports['qb-bossmenu']:GetAccount(Player.PlayerData.job.name)
if account ~= 0 then -- Checks if player is employed by a society
if account < payment then -- Checks if company has enough money to pay society
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('error.company_too_poor'), 'error')
else
Player.Functions.AddMoney('bank', payment)
TriggerEvent('qb-bossmenu:server:removeAccountMoney', Player.PlayerData.job.name, payment)
TriggerClientEvent('brutal_banking:client:AddTransaction', Player.PlayerData.source, payment, 'add', 'Salary')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
TriggerEvent('okokBanking:AddTransferTransactionFromSocietyToP', payment, "salary", "Salary", Player.PlayerData.citizenid, Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname)
end
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('brutal_banking:client:AddTransaction', Player.PlayerData.source, payment, 'add', 'Salary')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
TriggerEvent('okokBanking:AddTransferTransactionFromSocietyToP', payment, "salary", "Salary", Player.PlayerData.citizenid, Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname)
end
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('brutal_banking:client:AddTransaction', Player.PlayerData.source, payment, 'add', 'Salary')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
TriggerEvent('okokBanking:AddTransferTransactionFromSocietyToP', payment, "salary", "Salary", Player.PlayerData.citizenid, Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname)
end
end
end
SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckLoop)
end
Last updated