Jump to content

[Help]setTimer


thisdp

Recommended Posts

  • Scripting Moderators

I want to create a 25 ms loop but I noticed one problem.

  
local timer = {} 
addEvent("onClient25MsLoop",true) 
timer[1] = setTimer(function() 
    timer[2] = setTimer(function() 
        triggerEvent("onClient25MsLoop",root) 
    end,50,0) 
end,50,1) 
timer[3] = setTimer(function() 
    timer[4] = setTimer(function() 
        triggerEvent("onClient25MsLoop",root) 
    end,50,0) 
end,75,1) 
  
addEventHandler("onClient25MsLoop",root,function() 
    outputChatBox(getTickCount())                   ----------every output should differ by 25 ms 
end) 
  
setTimer(function() 
    killTimer(timer[2]) 
    killTimer(timer[4]) 
end,2000,1) 
  

Well,I set two 50-ms-loop timers.One with 50 ms delay and the other with 75 ms delay(they differ by 25 ms).At first several milliseconds,they work prefect,but after a second,they go wrong.

The 25-ms-difference become invalid.

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