#Service App -> Jobs not refreshing

1 messages · Page 1 of 1 (latest)

cold fiber
#

Edit: When you restart the phone, the job will be displayed correctly

ivory drift
#

You've been told that it has never been instant?

cold fiber
#

But it does not change at all

#

Only after a restart of the phone

ivory drift
cold fiber
#

It is now 16:46 and I will change my job to ambulance without restarting the phone

#

I have the ambulance job now, lets wait

#

Job changed in the database already

ivory drift
cold fiber
ivory drift
#

But does it change?

cold fiber
#

Pretty much instantly

ivory drift
#

Can you check where it is defined, because it isn't in my esx

cold fiber
#

Where what is defined?

#

ESX.JobsPlayerCount?

ivory drift
#

Yea

cold fiber
#
function RefreshCompanies()
    if ESX.JobsPlayerCount then
        for i = 1, #Config.Companies.Services do
            local jobData = Config.Companies.Services[i]

            jobData.open = (ESX.JobsPlayerCount[jobData.job] or 0) > 0
        end

        return
    end

    local openJobs = {}

    if ESX.GetExtendedPlayers then
        local xPlayers = ESX.GetExtendedPlayers()

        for _, xPlayer in pairs(xPlayers) do
            openJobs[xPlayer.job.name] = true
        end

        print("^6[LB Phone] ^3[WARNING]^7: You are running an outdated version of ESX. The script will still work, but you should consider updating. (you can remove this warning in server/custom/frameworks/esx.lua)")
    else
        local xPlayers = ESX.GetPlayers()

        for _, source in pairs(xPlayers) do
            local job = ESX.GetPlayerFromId(source).job.name

            openJobs[job] = true
        end

        print("^6[LB Phone] ^3[WARNING]^7: You are running an extremely old version of ESX. The script will still work, but you should consider updating. (you can remove this warning in server/custom/frameworks/esx.lua)")
    end

    for i = 1, #Config.Companies.Services do
        local jobData = Config.Companies.Services[i]

        jobData.open = openJobs[jobData.job] or false
    end
end
#
-- Get open companies
local lastRefresh = 0
lib.RegisterCallback("phone:services:getOnline", function(_, cb)
    if (lastRefresh + 60) < os.time() and RefreshCompanies then
        RefreshCompanies()
        lastRefresh = os.time()
    end

    cb(Config.Companies.Services)
end)

This one also seems to be working correctly, at least it tries to use the function everytime you open the app & if its at least 60 sec ago you opened the app last time

#

As you can see, it did not refresh

#

I have the ambulance job. When I restart the phone now, it will be displayed correctly.

cold fiber
cold fiber
#

I replaced the GetJob & the RefreshCompanies functions with the ones from one phone version older, and it works

#

So it has to be the new functions

sly copper
#

otherwise you have ESX.JobsPlayerCount

cold fiber
#

I have the latest version of esx

#

1.10.5

cold fiber
sly copper
#

Then there's something wrong with your ESX not updating that table

#

or wait

#

nvm

#

or

#

idk

#

it's in server/main.lua

#

line 320

#

and a bunch of other lines

#

i actually might know why it isn't working

cold fiber
#

As I said, the old one works perfectly

sly copper
#

yeah i think i know why it isn't working

#

we'll push an update asap

cold fiber
sly copper
#

change it to this: ```lua
if ESX.JobsPlayerCount then
for i = 1, #Config.Companies.Services do
local jobData = Config.Companies.Services[i]
local jobKey = ("%s:count"):format(jobData.job)

    jobData.open = (GlobalState[jobKey] or 0) > 0
    debugprint("Job", jobData.job, "is open:", jobData.open)
end

return

end

#

and it should work

cold fiber
#

Yeah seems good

#

Thanks

sly copper
#

np, thanks for the good bug report 😄

abstract spear
abstract spear
cold fiber
abstract spear
#

ok well it was fast enough to not be noticeable

cold fiber
#

So if you open the app it only refreshes 60secs later when you open the app again

abstract spear
#

now you can close the app, close the phone run around and open it back up and sometimes its still not updated

sly copper
#

and from what i've seen you seem to be the only one with issues on qb-core

cold fiber
abstract spear
#

thats odd how im the only one being that i literally made ZERO changes to anything besides the phone update. So make it make sense.

cold fiber
abstract spear
#

cant say its my qbcore or files or server when literally nothing else was changed. I updated the phone checked it out and first thing I noticed was services app was acting up. Had reports about it almost instantly

sly copper
#

then please create a detailed bug report

#

but i also don't see how it could break (for only you? i might be wrong) when we haven't touched that part since August

abstract spear
#

Yea its definitly strange. So if neither of us made changes to qbcore files then I suppose theres no logical explanation as to why its happening.

sly copper
#

I have no idea why it's happening, so please create a detailed bug report with debug prints etc

#

I can take a look on my qb server later

abstract spear
#

If anything ill do a complete wipe of the phone and reset it back up again.