Mann56 Posted June 6, 2015 Share Posted June 6, 2015 It says on wiki @ getTickCount that "This function returns amount of time that your system has been running in milliseconds" , but how can we use this function? I mean how can we use this function? As i don't see it's use anywhere... Thanks... Link to comment
Mr_Moose Posted June 6, 2015 Share Posted June 6, 2015 (edited) First of all you may notice that this function is available both on the server and the clients. By getting the tick count when a task is started, and then subtract that time from the current tick count when a task is finished you'll get the time it took to execute that task. This is certainly useful to measure performance on your system, which may help you to find bad resources that has a high CPU usage for instance. It can also be used for basic timing operations (using the method described above) like having a label, informing the players how much time it took to load something. Maybe you want to measure playtime to track the player stats on your server, there are many ways this function can be used. If you're creative Edit: corrected a few spelling errors. Edited June 7, 2015 by Guest Link to comment
Noki Posted June 7, 2015 Share Posted June 7, 2015 To elaborate on what Mr Moose said, let me give you some code. local plrTbl = {} function foo(plr) if (plrTbl[plr]) and ((getTickCount() - plrTbl[plr]) < 1000) then outputChatBox("Too soon!") else outputChatBox("Not even spamming") local plrTbl[plr] = getTickCount() end end addCommandHandler("bar", foo) Link to comment
Mann56 Posted June 7, 2015 Author Share Posted June 7, 2015 Thank you Mr.Moose and Noki Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now