Jump to content

Ayuda con scoreboard


Recommended Posts

Buenas noches chicos este es mi primer post y me gustaria saber si me pueden ayudar a crear un anti-hexa
El scoreboard lo saque de Internet y la verdad no se mucho sobre esto :'$

Gracias por su atención 
 

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

@-Rex- Se refiere a que los nombres de los jugadores no aparezcan así: #ff0000:v, sino ya con el color: :v

@Venerable solo tienes que marcar como verdadero el argumento "colorCoded" que trae dxDrawText, algo así: 

dxDrawText ( "Jogadores:  "..tostring(#playersTable).." | "..tostring(max_players), baseX-640, baseY+60, baseX+width, baseY+30, tocolor(255,255,255), 1, "default-bold", "center", false, false, false, true, false)

Has lo mismo con los otros textos

Link to comment
On 2017-5-20 at 11:38, Hit+ said:

@-Rex- Se refiere a que los nombres de los jugadores no aparezcan así: #ff0000:v, sino ya con el color: :v

@Venerable solo tienes que marcar como verdadero el argumento "colorCoded" que trae dxDrawText, algo así: 


dxDrawText ( "Jogadores:  "..tostring(#playersTable).." | "..tostring(max_players), baseX-640, baseY+60, baseX+width, baseY+30, tocolor(255,255,255), 1, "default-bold", "center", false, false, false, true, false)

Has lo mismo con los otros textos

Si era eso lo que quería, gracias por la ayuda

@-Rex- Perdón por no explicarme mejor xD

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