fix(paychecks): Get account the right way

This commit is contained in:
BerkieBb
2022-01-07 02:59:42 +01:00
committed by GitHub
parent 206853b660
commit 5d9e52ce55
+11 -12
View File
@@ -185,22 +185,21 @@ 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
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
if Player.PlayerData.job and Player.PlayerData.job.onduty and payment > 0 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, 'The company you\'re employed at doesn\'t have enough money to pay for your salary', 'error')
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
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
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, ('You received your paycheck of $%s'):format(payment))