drk Posted April 9, 2012 Posted April 9, 2012 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? EPT Team Server Development: 0% Learning C++ | C++ is amazing
BriGhtx3 Posted April 9, 2012 Posted April 9, 2012 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. Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
drk Posted April 9, 2012 Author Posted April 9, 2012 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 EPT Team Server Development: 0% Learning C++ | C++ is amazing
BriGhtx3 Posted April 9, 2012 Posted April 9, 2012 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 -.- Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
unknooooown Posted April 9, 2012 Posted April 9, 2012 (edited) Oh damn.. I was too slow 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 April 9, 2012 by Guest
drk Posted April 9, 2012 Author Posted April 9, 2012 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 :~ EPT Team Server Development: 0% Learning C++ | C++ is amazing
drk Posted April 9, 2012 Author Posted April 9, 2012 Oh damn.. I was too slow 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. EPT Team Server Development: 0% Learning C++ | C++ is amazing
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