Jump to content

ScorePING&FPS


Recommended Posts

Hey, I'm wondering if this is totally wrong xD, I made a try to edit a scoreping & fps because I didn't like the display.

The problem is that the PING is not showing on the screen, only the letters 'PING'. The FPS is working 100%, the ping is the problem. I want it to work the same way. Could you edit a bit on this? if thats what it needs? (I doubt that.)

Thanks.

Client

local ping = getPlayerPing(getLocalPlayer()) 
local x, y = guiGetScreenSize ( ) 
  
r,g,b=0,0,0 
alpha=150 
  
  
local root = getRootElement() 
local player = getLocalPlayer() 
local counter = 0 
local starttick 
local currenttick 
addEventHandler("onClientRender",root, 
    function() 
        if not starttick then 
            starttick = getTickCount() 
        end 
        counter = counter + 1 
        currenttick = getTickCount() 
        if currenttick - starttick >= 1000 then 
            setElementData(player,"FPS",counter) 
            counter = 0 
            starttick = false 
        end 
    end 
) 
  
  
local root = getRootElement() 
local player = getLocalPlayer() 
local counter = 0 
local starttick 
local currenttick 
addEventHandler("onClientRender",root, 
    function() 
        if not starttick then 
            starttick = getTickCount() 
        end 
        counter = counter + 1 
        currenttick = getTickCount() 
        if currenttick - starttick >= 1000 then 
            setElementData(player,"PING",counter) 
            counter = 0 
            starttick = false 
        end 
    end 
) 
  
function drawStates () 
    addEventHandler ( "onClientRender", root, pingState ) 
    addEventHandler ( "onClientRender", root, fpsState ) 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, drawStates ) 
  
function pingState() 
    posx= x-30 
    posy= 20 
     
    dxDrawText ( getElementData(getLocalPlayer(),"PING"), posx2-12, posy2-6, x, y, tocolor ( 255, 255, 255, 255 ), 1.4, "default-bold" ) 
     
    dxDrawText ( "FPS", posx2-13, posy2+10, x, y, tocolor ( 255, 255, 255, 255 ), 1.0, "default-bold" ) 
    dxDrawText ( "PING", posx2+23, posy2+10, x, y, tocolor ( 255, 255, 255, 255 ), 1.0, "default-bold" ) 
end 
  
function fpsState() 
    posx2= x-55 
    posy2= 13 
  
    dxDrawText ( getElementData(getLocalPlayer(),"FPS"), posx2-12, posy2-6, x, y, tocolor ( 255, 255, 255, 255 ), 1.4, "default-bold" ) 
  
    dxDrawText ( "FPS", posx2-13, posy2+10, x, y, tocolor ( 255, 255, 255, 255 ), 1.0, "default-bold" ) 
    dxDrawText ( "PING", posx2+23, posy2+10, x, y, tocolor ( 255, 255, 255, 255 ), 1.0, "default-bold" ) 
end 
  

Server

addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
    function() 
        call(getResourceFromName("scoreboard"),"addScoreboardColumn","FPS") 
        call(getResourceFromName("scoreboard"),"addScoreboardColumn","PING") 
    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...