Closed bandgeekndb closed 2 years ago
Try this
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'][Player.PlayerData.job.grade].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('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
end
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
end
else
Player.Functions.AddMoney('bank', payment)
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
Awesome, appreciate the code suggestion! I forgot to add that I was happy to PR a change, just wanted to verify that it wasn't intended behavior for some reason, but looks like you've got it covered. I'll try this out, verify there are no issues, and report back. Thank you!
Btw this might throw an error
[Player.PlayerData.job.grade].payment
if it does then try
[tostring(Player.PlayerData.job.grade.level)].payment
The second snippet worked, thank you. Do you want a PR for this change?
Yeah thanks
Describe the bug The paycheck function reads the player's job payment amount from the PlayerData object. But, if you adjust the payments in jobs.lua after setting a player's job, the player will not see that updated payment amount until their job is reassigned using /setjob.
To Reproduce Steps to reproduce the behavior:
Expected behavior The player continues to see their old salary until someone resets their job.
Desired behavior Instead, the PaycheckInterval() function should get the payment from the jobs.lua based on the player's assigned job.
Questions (please complete the following information):
qb-
to something custom? [e.g. yes/no] NOAdditional context Add any other context about the problem here.