Jump to content

Team Blip Colors


proracer

Recommended Posts

function teamBlipColor(source) 
local r,g,b 
local playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(source) 
local attachedElements = getAttachedElements(source) 
if (attachedElements) then 
    if (playerTeam) then 
        for k,v in ipairs(attachedElements) do 
            if getElementType(v) == "blip" then 
    r,g,b = getTeamColor(playerTeam)         
    setBlipColor(v, tonumber(r), tonumber(g), tonumber(b), 255) 
            end 
        end 
    end 
end 
end 
addCommandHandler("teamcolor", teamBlipColor) 

It's meant for Race gamemode.No errors, does nothing.

Link to comment
function teamBlipColor(source) 
local r,g,b 
playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(source) 
local attachedElements = getAttachedElements(source) 
if attachedElements and playerTeam then 
        for k,v in ipairs(attachedElements) do 
            if getElementType(v) == "blip" then 
              local r,g,b = getTeamColor(playerTeam)         
              local setBlipColor(v, r, g, b, 255) 
            end 
        end 
end 
end 
addCommandHandler("teamcolor", teamBlipColor) 
  
  

What's that?
local playerTeam = getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam(source) 
  
 

Forum bug.

Link to comment

I guess this function is supposed to color all blips of players in the team color of the player?

Did you check if the player is really in a team? Add some debug messages to check, where it stops.

Also, I think getAttachedElements always returns a table. You should rather check, if the table has values in it, e.g.:

if #attachedElements > 0 then 

Link to comment

Ok this is the last code.

function teamBlipColor(source) 
local r,g,b 
playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(source) 
local attachedElements = getAttachedElements(source) 
if attachedElements and playerTeam then 
        for k,v in ipairs(attachedElements) do 
            if getElementType(v) == "blip" then 
        if #attachedElements > 0 then 
              local r,g,b = getTeamColor(playerTeam)        
              setBlipColor(v, r, g, b, 255) 
        end 
            end 
        end 
end 
end 
addCommandHandler("teamcolor", teamBlipColor) 

It still does nothing and no errors.I will add some debug messages tommorow as I am tired now.If anyone see's where is the problem than please tell me :D

Link to comment
function teamBlipColor(source) 
playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(source) 
local attachedElements = getAttachedElements(source) 
if attachedElements and #attachedElements > 0 and playerTeam then 
        for k,v in ipairs(attachedElements) do 
            outputChatBox("The No. "..tostring(k).." element is a "..getElementType(v)..".") 
            if getElementType(v) == "blip" then 
              local r,g,b = getTeamColor(playerTeam)        
              setBlipColor(v, r, g, b, 255) 
              outputChatBox ("Your blip set its color rightly!") 
            end 
        end 
end 
end 
addCommandHandler("teamcolor", teamBlipColor) 
  
  

You could use too:

setElementID 
getElementByID 

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