Jump to content

how to receive fps


IIYAMA

Recommended Posts

  
local iFPS = 0 
local iFrames = 0 
  
function GetFPS( ) 
    return iFPS 
end 
  
addEventHandler( 'onClientRender', root, 
    function() 
        iFrames = iFrames + 1 
    end 
) 
  
  
setTimer( function() iFPS = iFrames; iFrames = 0 end, 1000, 0 ) 
  

Updated

So you need just call function GetFPS. Also you should modify this code for yourself.

Link to comment
  Kenix said:
No problem.

Instead of using laggy timers, you can also use getTickCount() in the onClientRender function itself.

edit:

local iFPS = 0 
local iFrames = 0 
  
function GetFPS( ) 
    return iFPS 
end 
  
addEventHandler( 'onClientRender', root, 
    function() 
        iFrames = iFrames + 1 
        if getTickCount () %800 < 15 then 
            iFPS = iFrames; iFrames = 0 
        end 
    end 
) 

Link to comment
  
local iFPS = 0 
local iFrames = 0 
local iStartTick = getTickCount() 
  
function GetFPS( ) 
    return iFPS 
end 
  
addEventHandler( 'onClientRender', root, 
    function() 
        iFrames = iFrames + 1 
        if getTickCount() - iStartTick >= 1000 then 
            iFPS = iFrames 
            iFrames = 0 
            iStartTick = getTickCount() 
        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...