Citizen.CreateThread Doesn't work serverside

All “Citizen.CreateThread” doesn’t work when is on serverside, have you an idea ?
Tahnks

Define “not working”.

Any example code?

Don’t think it’s supposed to work on the server. AFAIK, Citizen. functions are only defined in the Lua files for the client.

1 Like

Since FxServer I believe it’s work serverside (Essential and MySQL Async use “Citizen.CreateThread” serverside :confused:
Exactly my problem is that the init.lua of MySQL Async does not work :

AddEventHandler('onServerResourceStart', function (resource)
    if resource == "mysql-async" then
        exports['mysql-async']:mysql_configure()

        Citizen.CreateThread(function ()
            Citizen.Wait(0)
            TriggerEvent('onMySQLReady')
        end)
    end
end)

If I make a test like :

AddEventHandler('onServerResourceStart', function (resource)
    if resource == "mysql-async" then
        exports['mysql-async']:mysql_configure()
		print("TEST 1")
        Citizen.CreateThread(function ()
			print("TEST 2")
            Citizen.Wait(0)
			print("TEST 3")
            TriggerEvent('onMySQLReady')
        end)
    end
end)

Only “TEST 1” are printed

Just tried using the following code server side:

Citizen.CreateThread(function()
    print('1')
    Citizen.Wait(0)
    print('2')
end)

Works fine for me…

Edit: even running your code works fine for me.

Oh, I have 2 server with EXACT server files, on my server 1 it’s work, and on my server 2 it’s doesn’t, the 2 servers are not on the same machine, server 1 on a dedicated server and the server 2 on a vps, do you have an idea ? Thanks

This seems to be something I encountered on certain Linux distros.

I have Unbuntu 16.04 on both :confused:

No idea… have you tried to make a new server (new folder, new downloaded files)? Maybe that’ll solve something?

This was happening to me as well, just rebooted the box and it started working again…

Already had this issue, I just updated FXS to the newest version, work like a charm