Jump to content

Something about getTickCount


drk

Recommended Posts

When you add this function to the ResourceStart-event and for example when you type /count you can substract both milliseconds. Then you know how much time passed between the start event and typing the command.

Thank you, I understand now this shit xD

Link to comment
function value1(player) 
    val1 = getTickCount() 
    setElementData(player,"value1",tonumber(val1)) 
end 
addCommandHandler("val1",value1) 
  
function value2(player) 
    val2 = getTickCount() 
    setElementData(player,"value2",tonumber(val2)) 
end 
addCommandHandler("val2",value2) 
  
function timeVal1val2(player) 
    local valu1 = getElementData(player,"value1") 
    local valu2 = getElementData(player,"value2") 
    local substract = valu1-valu2 
    outputChatBox(substract.." milliseconds passed") 
end 
addCommandHandler("getTimeBetweenVal1andVal2",timeVal1val2) 

Here is an example anyway ;D

I wrote too slow -.-

Link to comment

Oh damn.. I was too slow :P Nvm this post.. Hehe.

Hi guys!

I've seen something about getTickCount on wiki but I can't understand why it's needed to subtract start tick count and end tick count like here:

https://wiki.multitheftauto.com/wiki/GetTickCount

Someone can explain me?

Example:

  
local startTick = getTickCount() -- That will give me the current TickCount: Lets say It's: 8394573485734 
  
-- A little later, we do pretty much the same thing again. 
local endTick = getTickCount() -- Lets say It's: 8394573985734 now 
  
local tick = endTick - startTick -- This would be 500000 milliseconds. Thats the time that has passed between startTick and endTick. 
  
-- If you want you can convert this to hours like: 
local hours = ( ( endTick / 1000 ) / 60 ) / 60 
  
print( hours )  
-- >> 0.138888889 
  

Edited by Guest
Link to comment
function value1(player) 
    val1 = getTickCount() 
    setElementData(player,"value1",tonumber(val1)) 
end 
addCommandHandler("val1",value1) 
  
function value2(player) 
    val2 = getTickCount() 
    setElementData(player,"value2",tonumber(val2)) 
end 
addCommandHandler("val2",value2) 
  
function timeVal1val2(player) 
    local valu1 = getElementData(player,"value1") 
    local valu2 = getElementData(player,"value2") 
    local substract = valu1-valu2 
    outputChatBox(substract.." milliseconds passed") 
end 
addCommandHandler("getTimeBetweenVal1andVal2",timeVal1val2) 

Here is an example anyway ;D

I wrote too slow -.-

When you add this function to the ResourceStart-event and for example when you type /count you can substract both milliseconds. Then you know how much time passed between the start event and typing the command.

Thank you, I understand now this :~ xD

xD

Link to comment
Oh damn.. I was too slow :P Nvm this post.. Hehe.
Hi guys!

I've seen something about getTickCount on wiki but I can't understand why it's needed to subtract start tick count and end tick count like here:

https://wiki.multitheftauto.com/wiki/GetTickCount

Someone can explain me?

Example:

  
local startTick = getTickCount() -- That will give me the current TickCount: Lets say It's: 8394573485734 
  
-- A little later, we do pretty much the same thing again. 
local endTick = getTickCount() -- Lets say It's: 8394573985734 now 
  
local tick = endTick - startTick -- This would be 500000 milliseconds. Thats the time that has passed between startTick and endTick. 
  
-- If you cant to convert this to hours, you can do: 
local hours = ( ( endTick / 1000 ) / 60 ) / 60 
  
print( hours )  
-- >> 0.138888889 
  

I understood already, anyway thanks.

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...