Guest User

Untitled

a guest
Oct 22nd, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. FPSLimit = 70
  2. FPSMax = 1
  3.  
  4. function onClientResourceStart ( resource )
  5.     if ( guiFPSLabel == nil ) then
  6.         FPSLimit = 255 / FPSLimit
  7.         guiFPSLabel = guiCreateLabel ( 0.003, 0.983, 0.26, 0.1, "FPS: 0", true )
  8.         guiSetFont (guiFPSLabel,"clear-normal")
  9.         FPSCalc = 0
  10.         FPSTime = getTickCount() + 1000
  11.         addEventHandler ( "onClientRender", getRootElement (), onClientRender )
  12.     end
  13. end
  14. addEventHandler ( "onClientResourceStart", getRootElement (), onClientResourceStart )
  15.  
  16. function onClientRender ( )
  17.     if ( getTickCount() < FPSTime ) then
  18.         FPSCalc = FPSCalc + 1
  19.     else
  20.         if ( FPSCalc > FPSMax ) then FPSLimit = 255 / FPSCalc FPSMax = FPSCalc end
  21.         guiSetText ( guiFPSLabel, "FPS: "..FPSCalc)
  22.         guiLabelSetColor ( guiFPSLabel, 255 - math.ceil ( FPSCalc * FPSLimit ), math.ceil ( FPSCalc * FPSLimit ), 0 )
  23.         FPSCalc = 0
  24.         FPSTime = getTickCount() + 1000
  25.     end
  26. end
Add Comment
Please, Sign In to add comment