Hello, I think there is a possibly a new bug with the latest server builds. On 3348, the following code works properly:
server.lua:
Citizen.CreateThread(function()
Wait(2000)
while true do
Wait(1)
-- do stuff
end
end)
AddEventHandler("onResourceStart", function(resource)
if (resource == GetCurrentResourceName()) then
print("Time:", GetGameTimer())
Wait(1000)
print("Time:", GetGameTimer())
TriggerClientEvent("testEvent", -1)
end
end)
client.lua:
RegisterNetEvent("testEvent")
AddEventHandler("testEvent", function()
print("Event triggered.")
end)
fxmanifest.lua:
-- Resource Metadata
fx_version "cerulean"
games {"gta5"}
client_scripts {
"client.lua"
}
server_script "server.lua"
However, on 3382 and 3394, it appears to skip the Wait(1000) in the onResourceStart event like itâs not there. Hereâs the server output:
cfx> restart test
Stopping resource test
Creating script environments for test
Time: 1229469
Started resource test
Time: 1229474
and the client event never gets triggered.
However, if I change the server file to
Citizen.CreateThread(function()
Wait(2000)
while true do
Wait(1)
-- do stuff
end
end)
AddEventHandler("onResourceStart", function(resource)
if (resource == GetCurrentResourceName()) then
Citizen.CreateThread(function()
print("Time:", GetGameTimer())
Wait(1000)
print("Time:", GetGameTimer())
TriggerClientEvent("testEvent", -1)
end)
end
end)
, the event triggers properly and the server output is as follows:
cfx> restart test
Stopping resource test
Creating script environments for test
Started resource test
Time: 1381215
Time: 1382232
Is this an intended change? Thanks.