Jump to content

scoreboard


ViRuZGamiing

Recommended Posts

Okay,

So i know this,

pName = getPlayerName (thePlayer) 
pPing = getPlayerPing(thePlayer) 
acc = getPlayerAccount(thePlayer) 
if acc and not isGuestAccount(acc) then  
team = getPlayerTeam(thePlayer) 
if team then 
setAccountData(acc, "team", getTeamName(team)) 

Playtime I will figure out but how to draw this data on a dxDrawRectangle?

Link to comment
local text_h = dxGetFontHeight(1,"bankgothic") 
  
addEventHandler("onClientRender",root, 
function () 
  
 local name_X = 350 
 local team_X = 700 
 local ping_X = 950 
 local name_Y = 200 
 local namend_Y = 700 
  
 if not getKeyState("tab") then return end  
  
 dxDrawRectangle(250, 100, 800, 600, tocolor(0, 100, 255, 150), true) 
 dxDrawText("Belgium-Reallife", 250, 100, 1050, 200, tocolor(255, 255, 255, 255), 2.00, "bankgothic", "center", "center", false, false, true, false, false) 
 dxDrawLine(250, 200, 1050, 200, tocolor(255, 255, 255, 255), 1, true) 
 dxDrawLine(550, 200, 550, 700, tocolor(255, 255, 255, 255), 1, true) 
 dxDrawLine(850, 200, 850, 700, tocolor(255, 255, 255, 255), 1, true) 
 --dxDrawText("Team1", 550, 200, 850, 700, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
 --dxDrawText("Ping1", 850, 200, 1050, 700, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
  
  if name_Y  > namend_Y then return end  
  for i,player in pairs(getElementsByType("player")) do 
  dxDrawText(getPlayerName(player),name_X,name_Y,name_X*1.2,name_Y*1.2,tocolor ( 255, 255, 255, 255 ), 1.0, "pricedown" ) 
  name_Y = name_Y + text_h*1.5 
  end 
end) 

This is what I got, it works but the text is drawed behind the rectangle, how to fix?

Link to comment
local text_h = dxGetFontHeight ( 1, "bankgothic" ) 
  
addEventHandler("onClientRender",root, 
    function ( ) 
        local name_X = 350 
        local team_X = 700 
        local ping_X = 950 
        local name_Y = 200 
        local namend_Y = 700 
  
        if ( not getKeyState ( "tab" ) ) then 
            return 
        end 
  
        if ( name_Y > namend_Y ) then 
            return 
        end 
   
        dxDrawRectangle(250, 100, 800, 600, tocolor(0, 100, 255, 150), false) 
        dxDrawText("Belgium-Reallife", 250, 100, 1050, 200, tocolor(255, 255, 255, 255), 2.00, "bankgothic", "center", "center", false, false, true, false, false) 
        dxDrawLine(250, 200, 1050, 200, tocolor(255, 255, 255, 255), 1, false) 
        dxDrawLine(550, 200, 550, 700, tocolor(255, 255, 255, 255), 1, false) 
        dxDrawLine(850, 200, 850, 700, tocolor(255, 255, 255, 255), 1, false) 
        --dxDrawText("Team1", 550, 200, 850, 700, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
        --dxDrawText("Ping1", 850, 200, 1050, 700, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
  
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            dxDrawText ( getPlayerName ( player ), name_X, name_Y, name_X * 1.2, name_Y * 1.2, tocolor ( 255, 255, 255, 255 ), 1.0, "pricedown" ) 
            name_Y = ( name_Y + text_h * 1.5 ) 
        end 
    end 
) 

Link to comment

LOL, maybe something went wrong with copying but indeed it works now.

Can I also do this;

        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            dxDrawText ( getPlayerName ( player ), name_X, name_Y, name_X * 1.2, name_Y * 1.2, tocolor ( 255, 255, 255, 255 ), 1.0, "pricedown" ) 
            name_Y = ( name_Y + text_h * 1.5 ) 
        end 

For Ping?

Link to comment

I tried this but didn't work;

        for _, player in ipairs ( getPlayerPing( thePlayer ) ) do 
            dxDrawText ( getPlayerPing( thePlayer ), ping_X, name_Y, name_X * 1.2, name_Y * 1.2, tocolor ( 255, 255, 255, 255 ), 1.0, "pricedown" ) 
            name_Y = ( name_Y + text_h * 1.5 ) 
        end 

Link to comment

Could this work?

        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            dxDrawText ( getPlayerPing(getLocalPlayer()), ping_X, name_Y, ping_X * 1.2, name_Y * 1.2, tocolor ( 255, 255, 255, 255 ), 1.0, "bankgothic" ) 
            name_Y = ( name_Y + text_h * 1.5 ) 
        end 

Link to comment

That'll only obtain the ping from the local player.

local text_h = dxGetFontHeight ( 1, "bankgothic" ) 
  
addEventHandler("onClientRender",root, 
    function ( ) 
        local name_X = 350 
        local team_X = 700 
        local ping_X = 950 
        local name_Y = 200 
        local namend_Y = 700 
  
        if ( not getKeyState ( "tab" ) ) then 
            return 
        end 
  
        if ( name_Y > namend_Y ) then 
            return 
        end 
  
        dxDrawRectangle(250, 100, 800, 600, tocolor(0, 100, 255, 150), false) 
        dxDrawText("Belgium-Reallife", 250, 100, 1050, 200, tocolor(255, 255, 255, 255), 2.00, "bankgothic", "center", "center", false, false, true, false, false) 
        dxDrawLine(250, 200, 1050, 200, tocolor(255, 255, 255, 255), 1, false) 
        dxDrawLine(550, 200, 550, 700, tocolor(255, 255, 255, 255), 1, false) 
        dxDrawLine(850, 200, 850, 700, tocolor(255, 255, 255, 255), 1, false) 
        --dxDrawText("Team1", 550, 200, 850, 700, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
        --dxDrawText("Ping1", 850, 200, 1050, 700, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
  
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            dxDrawText ( getPlayerName ( player ), name_X, name_Y, name_X * 1.2, name_Y * 1.2, tocolor ( 255, 255, 255, 255 ), 1.0, "pricedown" ) 
            dxDrawText ( tostring ( getPlayerPing ( player ) ), ping_X, name_Y, ping_X * 1.2, name_Y * 1.2, tocolor ( 255, 255, 255, 255 ), 1.0, "pricedown" ) 
            name_Y = ( name_Y + text_h * 1.5 ) 
        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...