Jump to content

getTickCount?


Mann56

Recommended Posts

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 by Guest
Link to comment

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...