Wiki

Clone wiki

EFLC-MP LUA / setTimer

Description

Creates a timer that will call a function of your choice every X milliseconds

Parameters

String functionName, Int interval, Int repetitions
String functionName: Name of the callback function

Int interval: call interval in milliseconds

Int repetitions: Amount of times this timer will be called. Special: 0=Infinite, 1=Once.

Extra Params: You can give this function additional params that will be used to call your function

Return values

Int timerId

Example

#!lua
function simpleTimer()
    print("Hello world")
end
print("Timer Id: " .. setTimer("simpleTimer", 3000, 0)) --Calls simpleTimer every 3 seconds

function extraParamsFunction(str, floating, integer)
end
setTimer("extraParamsFunction", 1000, 5, "Some string", 111.1, 333) --Calls extraParamsFunction with additional params

Updated