Jump to content

scoreboard


ViRuZGamiing

Recommended Posts

Posted

Hello,

Tell me what I need to make a scoreboard from scratch with username, group, playtime and ping

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
getPlayerName 
getPlayerPing 
getElementData( player, group ) --Needs an additional script to set the group element data. 
getElementData( player, playtime ) --Needs an additional script to set the play time element data. 

s.epicrow.com:22003.png

Posted

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?

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

Another thing;

getPlayerName gets only 1 name, right? I need every player on the scoreboard.

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
for i,player in pairs(getElementsByType("player")) do 
  dxDraw(getPlayerName(player), ......) 
end 

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

It doesn't need to be better,

I want to have a scoreboard having an Image instead of an Rectangle, and no setting button also.

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

You need the start Y poz, then draw player name , then increase Y by the used font Height*1.5 , then draw the next player , and again increase Y and ...

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

Bandi I will try some stuff out 'as I know you are very experienced with dxDrawings' and post the code in here.

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
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?

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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?

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

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 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

Use the same loop as for names, and add a new dxDrawText which draws the player ping.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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