Jump to content

Help with scoreboard


Recommended Posts

Good afternoon friends, I wanted to know if you can help me remove the colors of this scoreboard
I do not want the user's colors to appear, for example: #ff00ffVenerable


 

yA = 0 
local screenWidth, screenHeight = guiGetScreenSize() 
local sw, sh = guiGetScreenSize() 

scoreboardColumns = { 
    { name = "Nick", width = 160, data = function (element) return getPlayerName ( element ) end },
    { name = "Murders", width = 80, data = function (element) return ( getElementData ( element, "murders" ) or 0 ) end }, 
    { name = "Zombies Killed", width = 100, data = function (element) return ( getElementData ( element, "zombieskilled" ) or 0 ) end }, 
    { name = "Alive time", width = 80, data = function (element) return formatTimeFromMinutes(getElementData ( element, "alivetime" ) or 1 ) end }, 
    { name = "Gang", width = 100, data = function (element) return getElementData ( element, "gang" ) or "None" end }, 
    { name = "Ping", width = 60, data = function (element) return getPlayerPing ( element, "ping" ) or 0 end },
    { name = "Humanity", width = 100, data = function (element) return getElementData ( element, "humanity" ) or 0 end },
    { name = "FPS", width = 60, data = function (element) return getElementData ( element, "FPS" ) or 0 end },
} 

local serverName = "LIGHTZ 2017" -- название сервера
local topsize = 60 -- величина шляпы
local playersize = topsize-30 -- высота одной строки
local panelsize = playersize*1 -- величина панели

function calculateWidth()
    local width = 0
    for key, value in ipairs( ColumnName ) do
        width = width + value.width
    end
    for key, value in ipairs( ColumnStats ) do
        width = width + value.width
    end 
    return width + 60
end 

local max_players = 0
local ploff = 0
local width = calculateWidth()
local baseX = sw/2-width/2
local baseY = sh/2-(panelsize+topsize)/0.5
 
addEventHandler( "onClientRender", root,
function()
    if getKeyState( "tab" ) == false then ploff = 0; return end
    if getElementData(getLocalPlayer(),"logedin") then
        dxDrawRectangle ( baseX, baseY-40, width, topsize+40, tocolor(32,32,32) )
        dxDrawText ( serverName, baseX+53, baseY-45, baseX+width, baseY+topsize, tocolor(249,41,0), 2.6, "bankgothic" )
        dxDrawRectangle ( baseX, baseY+topsize, width, panelsize, tocolor(112,112,112,0) )          
        dxDrawLine ( baseX, baseY+30, baseX+width, baseY+30, tocolor(100,100,100),0.8 )
        dxDrawLine ( baseX, baseY+30, baseX, baseY+panelsize+topsize, tocolor(100,100,100),0.8 )
        dxDrawLine ( baseX, baseY+panelsize+topsize, baseX+width, baseY+panelsize+topsize, tocolor(100,100,100),0.8 )           
        local xoff = 60
        for i, v in ipairs ( ColumnName ) do
            dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
            dxDrawText ( v.name, baseX+xoff, baseY+70, baseX+xoff+v.width+10, baseY+topsize-30, tocolor(255,255,255), 1, "default-bold", "center", "center" )
            xoff = xoff+v.width
        end         
        for i, v in ipairs ( ColumnStats ) do
            dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
            dxDrawText ( v.name, baseX+xoff, baseY+60, baseX+xoff+v.width, baseY+topsize-30, tocolor(255,255,255), 1, "default-bold", "center", "center" )
            xoff = xoff+v.width
        end
        local playersTable = getElementsByType ( "player" )
        dxDrawText ( "Jogadores:  "..tostring(#playersTable).." | "..tostring(max_players), baseX-640, baseY+60, baseX+width, baseY+30, tocolor(255,255,255), 1, "default-bold", "center", "center" ) 
        local maxNum = #playersTable
        if maxNum > 10 then
            maxNum = 10
        end
        for i = 1, maxNum do
            dxDrawLine ( baseX, baseY+topsize+playersize*i, baseX+width, baseY+topsize+playersize*i, tocolor(100,100,100),0.5 )
            dxDrawText ( i+ploff, baseX, baseY+topsize+playersize*(i-1), baseX+25, baseY+topsize+playersize*i, tocolor(255,255,255), 1, "default-bold", "center", "center" )
            if playersTable[i+ploff] == localPlayer then
                dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(112,112,112,80) )
                else
                dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(112,112,112,150) )                  
            end
            local xoff = 60     
            for c, d in ipairs ( ColumnName ) do
                local data = d.data(playersTable[i+ploff])
                local r,g,b = 255,255,255
                dxDrawText ( data, baseX+xoff-40, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-10, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
                xoff = xoff+d.width
            end
                for c, d in ipairs ( ColumnStats ) do
                local data = d.data(playersTable[i+ploff])
                local r,g,b = 255,255,255
                if d.name == "Grupo:" and data == "Nenhum" then
                    r,g,b = 0,255,0
                    data = "sem grupo"
                end
                dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
                xoff = xoff+d.width
            end
        end
    end
end
)

function PlayerScrollMenu (key,keyState,arg)
    if getElementData(localPlayer,"logedin") and getKeyState( "F4" ) then
        if ( keyState == "down" ) then
            if arg == "up" then
                if ploff > 0 then
                    ploff=ploff-1
                end
            elseif arg == "down" then
                local playersTable = getElementsByType ( "player" )
                if ploff < #playersTable-10 then
                    ploff = ploff+1
                end
            end
        end
    end
end
bindKey ( "mouse_wheel_up", "down", PlayerScrollMenu, "up" )
bindKey ( "mouse_wheel_down", "down", PlayerScrollMenu, "down" )

function formatTimeFromMinutes(value)
    if value then
        local hours = math.floor(value/60)
        local minutes = math.round(((value/60) - math.floor(value/60))*100/(100/60))
        if minutes < 10 then minutes = "0"..minutes end
        value = hours..":"..minutes
        return value
    end
    return false
end

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

function sendMaxPlayersOnServer (players)
    max_players = players
end
addEvent("sendMaxPlayersOnServer",true)
addEventHandler("sendMaxPlayersOnServer",getLocalPlayer(),sendMaxPlayersOnServer)

 

Link to comment

There is an option in the scoreboard's settings in admin panel called "Allow colorcoded names" which makes color codes into actual colors when it's set to "true". So if a player has a nickname such as "#FF0000Mike" it will show up in the scoreboard as "Mike". 

 

PS: Just saw it's a custom scoreboard. Maybe try this at line 6:

{ name = "Nick", width = 160, data = function (element) return getPlayerName ( element ):gsub( '#%x%x%x%x%x%x', '' ) end },

 

Edited by koragg
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...