Jump to content

help me scoreboard color code


Akranes123

Recommended Posts

Hola, buenas noticias para todos, espero que estés muy bien.

Quiero que me ayude con esto estoy editando un marcador y cuando lo activo y entro en mi servidor con mi seudónimo por ejemplo, # FF0000Akranes el código se ve en el marcador Quiero que me ayude con ese pequeño error por favor, no sé cómo hacer que se vaya sin los códigos

 

 

 

        --
        -- Update the scoreboard content
        --
        local currentTick = getTickCount()
        if (currentTick - scoreboardTicks.lastUpdate > scoreboardTicks.updateInterval and (scoreboardToggled or scoreboardForced)) or forceScoreboardUpdate then
            forceScoreboardUpdate = false
            scoreboardContent = {}
            local index = 1
            
            local sortTableIndex = 1
            local sortTable = {}
            
            local players = getElementsByType( "player" )
            for key, player in ipairs( players ) do
                if not getPlayerTeam( player ) or not (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) or serverInfo.forcehideteams then
                    sortTable[sortTableIndex] = {}
                    for key, column in ipairs( scoreboardColumns ) do
                        local content
                        if column.name == "name" then
                            local playerName = getPlayerName( player )
                            if serverInfo.allowcolorcodes then
                                if string.find( playerName, "#%x%x%x%x%x%x" ) then
                                    local colorCodes = {}
                                    while( string.find( playerName, "#%x%x%x%x%x%x" ) ) do
                                        local startPos, endPos = string.find( playerName, "#%x%x%x%x%x%x" )
                                        if startPos then
                                            colorCode = string.sub( playerName, startPos, endPos )
                                            table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } )
                                            playerName = string.gsub( playerName, "#%x%x%x%x%x%x", "", 1 )
                                        end
                                    end
                                    content = { playerName, colorCodes }
                                else
                                    content = playerName
                                end
                            else
                                content = playerName
                            end
                        elseif column.name == "ping" then
                            content = getPlayerPing( player )
                        else
                            content = getElementData( player, column.name )
                        end
                        content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content )
                        if column.textFunction then
                            if content and column.name == "name" and type( content ) == "table" then
                                content[1] = column.textFunction( content[1], player )
                            else
                                content = column.textFunction( content, player )
                            end
                        end
                        sortTable[sortTableIndex][column.name] = content
                        sortTable[sortTableIndex]["__SCOREBOARDELEMENT__"] = player
                    end
                    sortTableIndex = sortTableIndex + 1
                end
            end
            if sortBy.what ~= "__NONE__" then table.sort( sortTable, scoreboardSortFunction ) end
            for key, value in ipairs( sortTable ) do
                scoreboardContent[index] = value
                index = index + 1
            end
            
            if (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) and not serverInfo.forcehideteams then
                -- And then the teams
                local teamSortTableIndex = 1
                local teamSortTable = {}
                sortTableIndex = 1
                sortTable = {}
                local teams = getElementsByType( "team" )
                for key, team in ipairs( teams ) do

                    -- Add teams to sorting table first
                    teamSortTable[teamSortTableIndex] = {}    
                    for key, column in ipairs( scoreboardColumns ) do
                        local content
                        if column.name == "name" then
                            local teamName = getTeamName( team )
                            local teamMemberCount = #getPlayersInTeam( team )
                            teamName = iif( teamName, tostring( teamName ), "-" )
                            teamMemberCount = iif( teamMemberCount, tostring( teamMemberCount ), "0" )
                            teamName = teamName .. " (" .. teamMemberCount .. " player" .. iif( teamMemberCount == "1", "", "s" ) .. ")"
                            if serverInfo.allowcolorcodes then
                                if string.find( teamName, "#%x%x%x%x%x%x" ) then
                                    local colorCodes = {}
                                    while( string.find( teamName, "#%x%x%x%x%x%x" ) ) do
                                        local startPos, endPos = string.find( teamName, "#%x%x%x%x%x%x" )
                                        if startPos then
                                            colorCode = string.sub( teamName, startPos, endPos )
                                            table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } )
                                            teamName = string.gsub( teamName, "#%x%x%x%x%x%x", "", 1 )
                                        end
                                    end
                                    content = { teamName, colorCodes }
                                else
                                    content = teamName
                                end
                            else
                                content = teamName
                            end
                        else
                            content = getElementData( team, column.name )
                        end
                        content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content )
                        if column.textFunction then
                            if content and column.name == "name" and type( content ) == "table" then
                                content[1] = column.textFunction( content[1], team )
                            else
                                content = column.textFunction( content, team )
                            end
                        end
                        teamSortTable[teamSortTableIndex][column.name] = content
                        teamSortTable[teamSortTableIndex]["__SCOREBOARDELEMENT__"] = team
                    end
                    teamSortTableIndex = teamSortTableIndex + 1
                    
                    -- and then the players
                    sortTableIndex = 1
                    sortTable[team] = {}
                    local players = getPlayersInTeam( team )
                    for key, player in ipairs( players ) do
                        sortTable[team][sortTableIndex] = {}
                        for key, column in ipairs( scoreboardColumns ) do
                            local content
                            if column.name == "name" then
                                local playerName = getPlayerName( player )
                                if serverInfo.allowcolorcodes then
                                    if string.find( playerName, "#%x%x%x%x%x%x" ) then
                                        local colorCodes = {}
                                        while( string.find( playerName, "#%x%x%x%x%x%x" ) ) do
                                            local startPos, endPos = string.find( playerName, "#%x%x%x%x%x%x" )
                                            if startPos then
                                                colorCode = string.sub( playerName, startPos, endPos )
                                                table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } )
                                                playerName = string.gsub( playerName, "#%x%x%x%x%x%x", "", 1 )
                                            end
                                        end
                                        content = { playerName, colorCodes }
                                    else
                                        content = playerName
                                    end
                                else
                                    content = playerName
                                end
                            elseif column.name == "ping" then
                                content = getPlayerPing( player )
                            else
                                content = getElementData( player, column.name )
                            end
                            content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content )
                            if column.textFunction then
                                if content and column.name == "name" and type( content ) == "table" then
                                    content[1] = column.textFunction( content[1], player )
                                else
                                    content = column.textFunction( content, player )
                                end
                            end
                            sortTable[team][sortTableIndex][column.name] = content
                            sortTable[team][sortTableIndex]["__SCOREBOARDELEMENT__"] = player
                        end
                        sortTableIndex = sortTableIndex + 1
                    end
                    if sortBy.what ~= "__NONE__" then table.sort( sortTable[team], scoreboardSortFunction ) end
                end
                if sortBy.what ~= "__NONE__" then table.sort( teamSortTable, scoreboardSortFunction ) end
                for key, content in ipairs( teamSortTable ) do
                    local team = content["__SCOREBOARDELEMENT__"]
                    scoreboardContent[index] = content
                    index = index + 1
                    
                    for key, value in ipairs( sortTable[team] ) do
                        scoreboardContent[index] = value
                        index = index + 1
                    end
                end
            end
            scoreboardTicks.lastUpdate = currentTick
        end
        

 

Edited by jhxp
Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...