Jump to content

[Ayuda] getTeamColor


Recommended Posts

Tengo un error en "getTeamColor" , ayuda?

local function playerJoin() 
    
    local r, g, b = getTeamColor(getPlayerTeam(source)) 
    local blip = createBlipAttachedTo(source, 0, 2, r, g, b, 255, 1) 
    setElementParent(blip, playerBlipRoot) 
    setTimer(updateBlipColor, 1000, 0, blip) --Upadate in 5 seconds, in case the server sets the color. 
end 
addEventHandler("onClientPlayerJoin", root, playerJoin) 

Link to comment
  • MTA Team
function playerJoin() 
    
    local r, g, b = getTeamColor(getPlayerTeam(source)) 
    local blip = createBlipAttachedTo(source, 0, 2, r, g, b, 255, 1) 
    setElementParent(blip, playerBlipRoot) 
    setTimer(updateBlipColor, 1000, 0, blip) --Upadate in 5 seconds, in case the server sets the color. 
end 
addEventHandler("onClientPlayerJoin", root, playerJoin) 

Link to comment
function playerJoin() 
    
    local r, g, b = getTeamColor(getPlayerTeam(source)) 
    local blip = createBlipAttachedTo(source, 0, 2, r, g, b, 255, 1) 
    setElementParent(blip, playerBlipRoot) 
    setTimer(updateBlipColor, 1000, 0, blip) --Upadate in 5 seconds, in case the server sets the color. 
end 
addEventHandler("onClientPlayerJoin", root, playerJoin) 

Gracias creo ya esta :D

Link to comment
  • MTA Team

Porque usas el evento onClientPlayerJoin...Aun no esta en ningun team..Proba usar esto:

  
function playerJoin() 
    
    local r, g, b = getTeamColor(getPlayerTeam(source)) 
    local blip = createBlipAttachedTo(source, 0, 2, r, g, b, 255, 1) 
    setElementParent(blip, playerBlipRoot) 
    setTimer(updateBlipColor, 1000, 0, blip) --Upadate in 5 seconds, in case the server sets the color. 
end 
addEventHandler("onClientPlayerSpawn", root, playerJoin) 

Link to comment
Porque usas el evento onClientPlayerJoin...Aun no esta en ningun team..Proba usar esto:
  
function playerJoin() 
    
    local r, g, b = getTeamColor(getPlayerTeam(source)) 
    local blip = createBlipAttachedTo(source, 0, 2, r, g, b, 255, 1) 
    setElementParent(blip, playerBlipRoot) 
    setTimer(updateBlipColor, 1000, 0, blip) --Upadate in 5 seconds, in case the server sets the color. 
end 
addEventHandler("onClientPlayerSpawn", root, playerJoin) 

Pues no funciona en unas ocaciones el blip sale rojo o no aparece :/

local playerBlipRoot = createElement("playerBlipRoot", "playerBlipRoot") 
  
--This function creates blips for all players when the resource starts. 
local function resourceStart() 
    for _, player in ipairs(getElementsByType("player")) do 
        if player ~= localPlayer then 
            
            local r, g, b = getTeamColor(getPlayerTeam(player)) 
            local blip = createBlipAttachedTo(player, 0, 2, r, g, b, 255, 1) 
            setElementParent(blip, playerBlipRoot) 
        end 
    end 
end 
addEventHandler("onClientResourceStart", root, resourceStart) 
  
  
  
  
  
  
function playerJoin() 
    
    local r, g, b = getTeamColor(getPlayerTeam(source)) 
    local blip = createBlipAttachedTo(source, 0, 2, r, g, b, 255, 1) 
    setElementParent(blip, playerBlipRoot) 
    setTimer(updateBlipColor, 1000, 0, blip) --Upadate in 5 seconds, in case the server sets the color. 
end 
addEventHandler("onClientPlayerSpawn", root, playerJoin) 
  
--This function destroys a players blip when they quit. 
local function playerQuit() 
    for _, blip in ipairs(getElementChildren(playerBlipRoot)) do 
        if getElementAttachedTo(blip) == source then 
            destroyElement(blip) 
        end 
    end 
end 
addEventHandler("onClientPlayerQuit", root, playerQuit) 
  
--This function updates a blip's color, ensuring the blip colors always match. 
function updateBlipColor(blip) 
     
    if player then 
        
         local r, g, b = getTeamColor(getPlayerTeam(source)) 
        setBlipColor(blip, r, g, b, 255) 
    end 
end 

Link to comment
  • MTA Team

Prueba esto:

local playerBlipRoot = createElement("playerBlipRoot", "playerBlipRoot") 
  
--This function creates blips for all players when the resource starts. 
local function resourceStart() 
    for _, jugador in ipairs(getElementsByType("player")) do 
        if jugador ~= localPlayer then 
            
            local r, g, b = getTeamColor(getPlayerTeam(jugador)) 
            local pin = createBlipAttachedTo(jugador, 0, 2, r, g, b, 255, 1) 
            setElementParent(pin, playerBlipRoot) 
        end 
    end 
end 
addEventHandler("onClientResourceStart", root, resourceStart) 
  
  
  
  
  
  
function playerJoin() 
    
    local r, g, b = getTeamColor(getPlayerTeam(source)) 
    local pin = createBlipAttachedTo(source, 0, 2, r, g, b, 255, 1) 
    setElementParent(pin, playerBlipRoot) 
    setTimer(updateBlipColor, 1000, 0, pin) --Upadate in 5 seconds, in case the server sets the color. 
end 
addEventHandler("onClientPlayerSpawn", root, playerJoin) 
  
--This function destroys a players blip when they quit. 
local function playerQuit() 
    for _, pin in ipairs(getElementChildren(playerBlipRoot)) do 
        if getElementAttachedTo(pin) == source then 
            destroyElement(pin) 
        end 
    end 
end 
addEventHandler("onClientPlayerQuit", root, playerQuit) 
  
--This function updates a blip's color, ensuring the blip colors always match. 
function updateBlipColor(pin) 
       for i, jugador in ipairs(getElementsByType("player")) do 
        
         local r, g, b = getTeamColor(getPlayerTeam(i)) 
        setBlipColor(pin, r, g, b, 255) 
    end 
end 

Link to comment
  • Recently Browsing   0 members

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