#QBX_CORE PAYCHECK

1 messages · Page 1 of 1 (latest)

versed ferry
#

The problem is not the config since it is working a certain amount of time

merry shale
#

probaly due to the Okok stuff

neon tusk
versed ferry
#

Seems like qbx_core doesn't like paycheckTimeout over 10

#

Strange..

versed ferry
#

[ script:qbx_core] SCRIPT ERROR: @qbx_core/server/loops.lua:33: attempt to index a nil value

#

This is the error how can I fix it

#

local config = require 'config.server'

local function removeHungerAndThirst(src, player)
local playerState = Player(src).state
if not playerState.isLoggedIn then return end
local newHunger = playerState.hunger - config.player.hungerRate
local newThirst = playerState.thirst - config.player.thirstRate

player.Functions.SetMetaData('thirst', math.max(0, newThirst))
player.Functions.SetMetaData('hunger', math.max(0, newHunger))

player.Functions.Save()

end

CreateThread(function()
local interval = 60000 * config.updateInterval
while true do
Wait(interval)
for src, player in pairs(QBX.Players) do
removeHungerAndThirst(src, player)
end
end
end)

local function pay(player)
local job = player.PlayerData.job
print(("[DEBUG] Processing paycheck for %s (%s, grade %s)"):format(
player.PlayerData.charinfo and player.PlayerData.charinfo.firstname or "Unknown",
job.name,
job.grade.level
))

local payment = GetJob(job.name).grades[job.grade.level].payment or job.payment
print("[DEBUG] Calculated payment:", payment)

if payment <= 0 then 
    print("[DEBUG] Payment <= 0, no paycheck.")
    return 
end

if not GetJob(job.name).offDutyPay and not job.onduty then 
    print("[DEBUG] Employee not on duty and offDutyPay disabled -> no paycheck.")
    return 
end

if not config.money.paycheckSociety then
    print("[DEBUG] config.money.paycheckSociety = false -> direct player payment")
    config.sendPaycheck(player, payment)
    return
end

local account = config.getSocietyAccount(job.name)
if not account then
    print("[DEBUG] No society account found for:", job.name, "-> direct player payment")
    config.sendPaycheck(player, payment)
    return
end

print("[DEBUG] Society account:", account, " | Payment:", payment)

if account < payment then
    print("[DEBUG] Society too poor to pay:", job.name)
    Notify(player.PlayerData.source, locale('error.company_too_poor'), 'error')
    return
end

print("[DEBUG] Society withdrawal and player payment:", payment)
config.removeSocietyMoney(job.name, payment)
config.sendPaycheck(player, payment)

end

CreateThread(function()
local interval = 60000 * config.money.paycheckTimeout
print("[DEBUG] Paycheck thread started with interval:", interval, "ms")
while true do
Wait(interval)
print("[DEBUG] Starting paycheck cycle")
for _, player in pairs(QBX.Players) do
pay(player)
end
end
end)

This is my server/loops.lua:33

neon tusk
#

About the jobs?