[FXServer] Unable to make server side threads

So a few days ago I was no longer able to make or use threads server side on FXServer. I am able to use Citizen.Wait but not the threads. When I first started using FXServer they worked perfectly fine but now whenever I use them any code inside the thread doesn’t run. I also have been getting this error which may link to the problem.

[   1715328] Exception loading assembly I18N: System.IO.FileNotFoundException: Unable to find the specified file.

[   1715328] 

[   1715328] 

[   1715328] Server stack trace: 

[   1715328]   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 

[   1715328]   at (wrapper cominterop) CitizenFX.Core.IScriptHost:OpenHostFile (string)

[   1715328]   at (wrapper cominterop-invoke) CitizenFX.Core.IScriptHost:OpenHostFile (string)

[   1715328]   at CitizenFX.Core.MonoScriptRuntime+WrapScriptHost.OpenHostFile (System.String fileName) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\MonoScriptRuntime.cs:254 

[   1715328]   at (wrapper remoting-invoke-with-check) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:OpenHostFile (string)

[   1715328]   at (wrapper xdomain-dispatch) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:OpenHostFile (object,byte[]&,byte[]&,string)

[   1715328] 

[   1715328] Exception rethrown at [0]: 

[   1715328]   at (wrapper xdomain-invoke) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:OpenHostFile (string)

[   1715328]   at CitizenFX.Core.InternalManager.LoadAssembly (System.String name) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\InternalManager.cs:115 

Any help will be much appreciated.

Can you disable all your scripts except the default FiveM ones? Or post the CreateThread segment of your client.lua?

Yeh here you go

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(600000)
		for k,v in pairs(player) do
			if playerLoginData[k]['isActive'] then		
				MySQL.Async.execute('UPDATE player_data SET money = @money, bankbalance = @bank, jailtime = @jailtime, skin = @skin, weapons = @weapons, skinvariations = @variations, inventory = @inventory, chartype = @chartype, arrests = @arrest, tickets = @ticket, reasons = @reason, warrants = @warrant, bill = @bill WHERE charid = @charid', {['@money'] = v.money, ['@bank'] = v.bankBalance, ['@jailtime'] = v.jailTime, ['@skin'] = v.skin, ['@weapons'] = v.weapons, ['@variations'] = v.skinVariations, ['@inventory'] = v.inventory, ['@chartype'] = v.charType, ['@charid'] = v.charId, ['@arrest'] = v.arrests, ['@ticket'] = v.tickets, ['@reason'] = v.reasons, ['@warrant'] = v.warrants, ['@bill'] = v.bill}, function(result) end)
			end
		end
	end
end)

The thread doesn’t actually do anything acts like it doesn’t exist

RegisterServerEvent('grabDataFromCharId')
AddEventHandler('grabDataFromCharId', function(player, charid)
	local identifier = GetPlayerIdentifiers(player)
	Citizen.CreateThread(function()
		for k,v in ipairs(playerLogin) do	
			if v.identifier == tostring(identifier[1]) and v.charId == tonumber(charid) and not f[player] then
				for a,b in pairs(playerDetails) do
					if b.identifier == identifier[1] then
						permLevel = a
					end
				end
				TriggerEvent('setPlayerData', player, playerLoginData[k], k, permLevel)
				TriggerClientEvent('setPlayerSeed', player, timeToUse)
				f[player] = true
				selectStatus[player] = true
			end
		end
	end)
	if not f[player] then
		TriggerClientEvent('chatMessage', player, '', {255, 255, 255}, "This is not your character")
		TriggerClientEvent('resetPlayerSelection', player)
	end
end)

I also tried putting in something like this same thing code inside thread doesn’t run at all. Even if I do a fresh install of FXServer threads still don’t work

Just gonna bump this. Anyone able to help?

You do realize that that first block of code you wrote will wait for 10 minutes before doing something for the first time right? Because you put the Wait statement in front.

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(1000) -- Every second
		Citizen.Trace("\nwew")
	end
end)

Correctly gives

on the latest FXServer.

Yes I know but they are not working. Any code put inside threads doesn’t work for example on the second piece of code it will always say not your character and you will be stuck at the login screen until I remove the thread. I even tried the piece of code you posted and on a fresh install of FXServer nothing seems to work at all

That’s your own mistake, as threads don’t wait for completion: quite the opposite, you use them because you don’t want to wait for completion.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.