setTimer
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function allows you to trigger a function after a number of milliseconds have elapsed. You can call one of your own functions or a built-in function. For example, you could set a timer to spawn a player after a number of seconds have elapsed.
The hidden global variable sourceTimer contains the currently executing timer userdata
The hidden global variable source becomes nil inside a timer function. You need to declare it on the function arguments if you need to use it.
The speed at which a client side timer runs can be completely unreliable if a client is maliciously modifying their operating system speed, timers could run much faster or slower.
Writing the following code can cause performance issues. Use onClientPreRender instead. setTimer(theFunction, 0, 0)
OOP Syntax Help! I don't understand this!
- Constructor: Timer(...)
Syntax
timer setTimer ( function theFunction, int timeInterval, int timesToExecute, var arguments... )Required Arguments
- theFunction: The function you wish the timer to call.
- timeInterval: MISSING_PARAM_DESC
- timesToExecute: MISSING_PARAM_DESC
- arguments...: MISSING_PARAM_DESC
Returns
- timer: value
Returns a timer pointer if the timer was set successfully, false if the arguments are invalid or the timer could not be set.
Code Examples
This example will output some text after a small delay.
-- define function to be calledfunction delayedChat ( text ) outputChatBox ( "Delayed text: " .. text )end
-- set a timer so the function is called after 1 secondsetTimer ( delayedChat, 1000, 1, "Hello, World!" )See Also
Utility Functions
- addDebugHook
- bitAnd
- bitArShift
- bitExtract
- bitLRotate
- bitLShift
- bitNot
- bitOr
- bitReplace
- bitRRotate
- bitRShift
- bitTest
- bitXor
- createTrayNotification
- debugSleep
- decodeString
- deref
- downloadFile
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getFPSLimit
- getKeyboardLayout
- getLocalization
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getProcessMemoryStats
- getRealTime
- getServerIp
- getTickCount
- getTimerDetails
- getTimers
- gettok
- getUserdataType
- getVersion
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isShowCollisionsEnabled
- isShowSoundEnabled
- isTimer
- isTimerPaused
- isTransferBoxAlwaysVisible
- isTransferBoxVisible
- isTrayNotificationEnabled
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- ref
- removeDebugHook
- resetTimer
- setClipboard
- setDevelopmentMode
- setFPSLimit
- setTimer
- setTimerPaused
- setTransferBoxVisible
- setWindowFlashing
- sha256
- showCol
- showSound
- split
- teaDecode
- teaEncode
- tocolor
- toJSON
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub