MitnickP56 Posted February 9, 2016 Share Posted February 9, 2016 Hi, I tried to make fps checker. smth like Nick his fps = (fps) . but with fps<=35 I wanna change 10.0001 to 10 Nick fps; 30.00333 -> Nick fps: 30 with timer 1 sec Code: local fps = false function getCurrentFPS() -- Setup the useful function return fps end setTimer(getCurrentFPS, 1000, 0) local function updateFPS(msSinceLastFrame) -- FPS are the frames per second, so count the frames rendered per milisecond using frame delta time and then convert that to frames per second. fps = (1 / msSinceLastFrame) * 1000 for _, v in ipairs(getElementsByType("player")) do local state = getElementData (v, "state") if state == "alive" then local pokazfps = getCurrentFPS() if (pokazfps <= 35) then outputChatBox(getPlayerName(v).." #fffffffps"..pokazfps, 213, 255, 255, true) end end end end addEventHandler("onClientPreRender", root, updateFPS) This code show: Link to comment
Enargy, Posted February 9, 2016 Share Posted February 9, 2016 fps = math.floor(1 / msSinceLastFrame) * 1000 Link to comment
Bonus Posted February 9, 2016 Share Posted February 9, 2016 The for-part doesn't make sense. getCurrentFPS only gives the FPS of the local player. Also don't use ipairs in a code like that! I see that s*it everywhere ... guys, ipairs is SLOW. Use for i=1, #players (fastest) or pairs instead, but don't use ipairs when the order doesn't matter (and here it clearly doesn't matter) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now