Citizen CreateThread seems to not work

Hello dear community,

I currently have an issue with a script server side. It seems that Citizen.CreateThread(…) is not launch.
The same script work well on my localhost server but once uploaded on our live server nothing happen.
EventHandlers work as expected, only the stuff with Citizen.CreateThread(…) don’t.

Do you know how I could debug that please ?
Thanks :slight_smile:

Put a “function() end” within it.

1 Like

Hi Twittchter,

I should have put some real code example. This code will do nothing :

Citizen.CreateThread(function()
    while true do
        print("hello")
        Citizen.Wait(1000)
    end
end)
1 Like

Show us your resource tree and your fxmanifest.lua, I’m pretty sure there’s something wrong there.

Hi ShahZaM,
thanks for your time. There is nothing wrong there since other code, that are not in an other thread, works fine.

For example this work fine :

AddEventHandler("onResourceStart", function(name)
    if name == GetCurrentResourceName() then
        local now = os.date('*t')
        print('server time is  : '..now.hour..'H'..now.min)
    end
end)

It is like a thread failed to be created but silently.

Please provide us with the full file as well as the resource tree, once again. Also what server artifacts are you using? Could you try the same piece of code in a completely new empty server. The only cause I see for this is as if your CPU is almost at the limit of creating threads so your OS doesn’t allow it, but again I highly doubt this XD

This issue occurs on a server hosted by nexus. I’m developper for a team that handle an RP server.

I took their script that do not work and I put it on my own localhost server, and it works well on it.
I found other server script on their server where a call to Citizen.CreateThread was made and I put some print into them : nothing.

So I created a new module where I only create a thread that print a log every 5 sec and same behaviour : on my localhost that works, on their server it does not ^^.

fxmanifest

And yes I don’t think the thread limit has been reached.
But I think it comes from the server host that may restricted thread usage.

That wouldn’t make sense, not at all. But try updating server artifacts.

In order to close this issue : at the endevery things worked, the server logs were just not displayed.
I changed the print() by triggering a client event and I saw that all was fine.