Jump to content

Spectators with team color


VTX

Recommended Posts

Hey guys!

This is a part of a spectator script I have:

  
setTimer(function() 
        local specList = {} 
        for k,v in ipairs(getElementsByType("player")) do 
            local target = getCameraTarget(v) 
            if target and (target ~= v) then 
                if not specList[target] then 
                    specList[target] = {} 
                end 
                specList[target][#specList[target]+1] = getPlayerName(v) 
            end 
        end 
  

How can I add the team color to the player's name?

Link to comment

Something like this?

setTimer(function() 
        local specList = {} 
        for k,v in ipairs(getElementsByType("player")) do 
            local target = getCameraTarget(v) 
            if target and (target ~= v) then 
                if not specList[target] then 
                    specList[target] = {} 
                end 
                local team = getPlayerTeam(v) 
                if team then 
                    local r, g, b = getTeamColor(team) 
                    specList[target][#specList[target]+1] = string.format("#%.2X%.2X%.2X", r, g, b)..getPlayerName(v) 
                else 
                    specList[target][#specList[target]+1] = string.format("#%.2X%.2X%.2X", 255, 255, 255)..getPlayerName(v) 
                end 
            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...