Jump to content

FPS


iPrestege

Recommended Posts

Hello, can some one help me here ? :

FPSLimit = 46 
FPSMax = 1 
function onClientResourceStart(resource) 
  if FPSLabel == nil then 
    FPSLimit = 255 / FPSLimit 
    FPSLabel = guiCreateLabel(8, 190, 55000, 19, "Your FPS: 0", false, info) 
    FPSCalc = 0 
    FPSTime = getTickCount() + 1000 
    addEventHandler("onClientRender", getRootElement(), onClientRender) 
  end 
end 

addEventHandler("onClientResourceStart", getRootElement(), onClientResourceStart) 
function onClientRender() 
  if getTickCount() < FPSTime then 
    FPSCalc = FPSCalc + 1 
  else 
    if FPSMax < FPSCalc then 
      FPSLimit = 255 / FPSCalc 
      FPSMax = FPSCalc 
    end 
    guiSetText(FPSLabel, "Your FPS: " .. FPSCalc) 
    guiLabelSetColor(FPSLabel, 255, 246, 15 - math.ceil(FPSCalc * FPSLimit), math.ceil(FPSCalc * FPSLimit), 0) 
    FPSCalc = 0 
    FPSTime = getTickCount() + 1000 
  end 
end 

Link to comment

Client side

  
FPSLimit = 46 
FPSMax = 1 
local guiFPSLabel = nil 
  
function onClientResourceStart ( resource ) 
    if ( guiFPSLabel == nil ) then 
        FPSLimit = 255 / FPSLimit 
        guiFPSLabel = guiCreateLabel ( 0.03, 0.97, 0.1, 0.1, "FPS: 0", true ) 
        FPSCalc = 0 
        FPSTime = getTickCount() + 1000 
        addEventHandler ( "onClientRender", getRootElement (), onClientRender ) 
    end 
end 
addEventHandler ( "onClientResourceStart", getRootElement (), onClientResourceStart ) 
  
function onClientRender ( ) 
    if ( getTickCount() < FPSTime ) then 
        FPSCalc = FPSCalc + 1 
    else 
        if ( FPSCalc > FPSMax ) then FPSLimit = 255 / FPSCalc FPSMax = FPSCalc end 
        guiSetText ( guiFPSLabel, "FPS: "..FPSCalc.." Max: "..FPSMax ) 
        guiLabelSetColor ( guiFPSLabel, 255 - math.ceil ( FPSCalc * FPSLimit ), math.ceil ( FPSCalc * FPSLimit ), 0 ) 
        FPSCalc = 0 
        FPSTime = getTickCount() + 1000 
    end 
end 
  

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