GetTickCount: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (→Example: new example) |
||
Line 10: | Line 10: | ||
==Example== | ==Example== | ||
This | This will start a timer displayed at the top of the screen displayed every frame. You can log any specific moment in time by outputting the currentCount variable. | ||
-- | <syntaxhighlight lang="lua">screenX,screenY = guiGetScreenSize() | ||
function startTheClock () | |||
if not systemUpTime then | |||
systemUpTime = getTickCount () --Store the system tick count, this will be 0 for us | |||
end | |||
currentCount = getTickCount () | |||
dxDrawRectangle (screenX *.40, screenY * .09, 250, 50, tocolor(0,0,0,150)) | |||
dxDrawText ( currentCount - systemUpTime, screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) | |||
end | |||
addEventHandler ( "onClientRender", root, startTheClock ) | |||
startTheClock()</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Utility functions}} | {{Utility functions}} |
Revision as of 21:23, 29 September 2012
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.
Syntax
int getTickCount ()
Returns
Returns an integer containing the number of milliseconds since the system the server is running on started. This has the potential to wrap-around.
Example
This will start a timer displayed at the top of the screen displayed every frame. You can log any specific moment in time by outputting the currentCount variable.
screenX,screenY = guiGetScreenSize() function startTheClock () if not systemUpTime then systemUpTime = getTickCount () --Store the system tick count, this will be 0 for us end currentCount = getTickCount () dxDrawRectangle (screenX *.40, screenY * .09, 250, 50, tocolor(0,0,0,150)) dxDrawText ( currentCount - systemUpTime, screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) end addEventHandler ( "onClientRender", root, startTheClock ) startTheClock()
See Also
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub
- bitAnd
- bitNot
- bitOr
- bitXor
- bitTest
- bitLRotate
- bitRRotate
- bitLShift
- bitRShift
- bitArShift
- bitExtract
- bitReplace