Skip to content

CreateLoop

Create a while true do loop, in the callback send the loopId

Argument Data Type Needed Default Description
Function function - The code executed in the loop
Time number 5 The time express in millisenconds (ms) of the execution
Returns
Data Type Description
loopId The id of the loop

Dont need to be called every frame


Example

Without time:

CreateLoop(function(loopId)
    print("Test")
end)
With time:
CreateLoop(function()
    print("Test")
end, 500)

Old method
Citizen.CreateThread(function()
    while true do
        print("Test")
        Citizen.Wait(5)
    end
end)
Old problem

In the old method if you forgot to insert Citizen.Wait(ms) the ALL server will crash
I created it because i was sick of the thousands of times my server crashed, Thanks FiveM 😉


Last update: April 12, 2022
Created: June 27, 2021