I'm working on a fivem script I want to create a thread that goes through teams every…
- User
I'm working on a fivem script I want to create a thread that goes through teams every few seconds and checks that both ['A'] and ['B'] are not equal to nil if both values aren't nil then it will trigger an event local teams = {['A']= nil, ['B']= nil}
Citizen.CreateThread(function() while true do for k,v in pairs(teams) do if v then end)
- Assistant
You're almost there. You can use a simple check inside your loop to see if both values are not
nil, and then trigger the event as needed. Also, make sure you have aWaitinside your loop to prevent freezing. Here's the modified script:local teams = {['A']= nil, ['B']= nil} Citizen.CreateThread(function() while true do if teams['A'] ~= nil and teams['B'] ~= nil then -- Trigger your event here end Wait(5000) -- Check every 5 seconds (5000 ms) end end)This script will continuously check every 5 seconds if both
teams['A']andteams['B']are notniland trigger an event when the condition is met.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.