Add paychecks from society account

Added config option for paychecks to be taken from society account when the player is employed by a society.
This commit is contained in:
bmf1418
2022-01-01 15:18:32 -06:00
parent 47867b22c0
commit 9a251cd160
2 changed files with 20 additions and 2 deletions
+19 -2
View File
@@ -186,8 +186,25 @@ function PaycheckLoop()
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
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, ('You received your paycheck of $%s'):format(payment))
if QBCore.Config.Money.PayCheckSociety then
QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', Player.PlayerData.source, function(account)
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, 'The company you\'re employeed at is too poor to pay out your salary')
else
Player.Functions.AddMoney('bank', payment)
TriggerEvent('qb-bossmenu:server:removeAccountMoney', Player.PlayerData.job.name, payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, ('You received your paycheck of $%s'):format(payment))
end
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, ('You received your paycheck of $%s'):format(payment))
end
end, Player.PlayerData.job.name)
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, ('You received your paycheck of $%s'):format(payment))
end
end
end
SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckLoop)