getTickCount
This page is incomplete! Help wanted!
Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.
This function returns amount of time that your system has been running in milliseconds. By comparing two values of getTickCount, you can determine how much time has passed (in milliseconds) between two events. This could be used to determine how efficient your code is, or to time how long a player takes to complete a task.
The value returned by this function client-side may not be reliable if a client is maliciously modifying their operating system speed.
Syntax
getTickCount ( )Code Examples
The below code is a good example on how to implement basic anti-spam protection for a command, for which using getTickCount is better than the regular timer functions.
local spam = {}
function setSkin(player, cmd, skin) if spam[player] and getTickCount() - spam[player] < 4000 then return outputChatBox("You cannot change skin that often!", player, 255, 0, 0) end
skin = skin and tonumber(skin)
if getElementModel(player) == skin or isPedDead(player) then return end
if skin and skin <= 99999 then -- what do we know about dynamic ped ID range? setElementModel(player, skin) spam[player] = getTickCount() else outputChatBox("Invalid skin ID!", player, 255, 0, 0) endendaddCommandHandler("skin", setSkin)
function cleanUp() if spam[source] then spam[source] = nil endendaddEventHandler("onPlayerQuit", root, cleanUp)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