Advertisement
Guest User

AutoLagTolerance.lua Fix

a guest
Mar 29th, 2017
1,549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1.  
  2. local AutoLagTolerance = CreateFrame( "Frame", "AutoLagTolerance" )
  3.  
  4. local currentTolerance = GetCVar( "SpellQueueWindow" )
  5. local lastUpdateTime = 0
  6.  
  7. local function AutoLagTolerance_OnUpdate ( self, elapsed )
  8. lastUpdateTime = lastUpdateTime + elapsed
  9.  
  10. -- Update once per second.
  11. if lastUpdateTime < 1.0 then
  12. return
  13. else
  14. lastUpdateTime = 0
  15. end
  16.  
  17. -- Retrieve the world latency.
  18. local newTolerance = select( 4, GetNetStats() )
  19.  
  20. -- Ignore an empty value.
  21. if newTolerance == 0 then
  22. return
  23. end
  24.  
  25. -- Prevent update spam.
  26. if newTolerance == currentTolerance then
  27. return
  28. else
  29. currentTolerance = newTolerance
  30. end
  31.  
  32. -- Adjust the "Lag Tolerance" slider.
  33. SetCVar( "SpellQueueWindow", newTolerance )
  34. end
  35.  
  36. local function AutoLagTolerance_OnEvent ( self, event, arg1, arg2, ... )
  37. if event == "PLAYER_ENTERING_WORLD" then
  38. SetCVar( "SpellQueueWindow", 1 )
  39. end
  40. end
  41.  
  42. AutoLagTolerance:SetScript( "OnUpdate", AutoLagTolerance_OnUpdate )
  43. AutoLagTolerance:SetScript( "OnEvent", AutoLagTolerance_OnEvent )
  44.  
  45. AutoLagTolerance:RegisterEvent( "PLAYER_ENTERING_WORLD" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement