Jump to content

Blips visible to Teams


Recommended Posts

Hi everyone. I have a problem.

I want create Blips but only visible to my team

I have this. Debug script dont show error

local playerBlipRoot = createElement("playerBlipRoot", "playerBlipRoot") 
  
local function resourceStart() 
          team = getPlayerTeam(localPlayer) 
          local tplayers = getPlayersInTeam ( team ) 
    for _, tplayers in ipairs(tplayers) do 
        if tplayers ~= localPlayer then 
            local r, g, b = getPlayerNametagColor(tplayers) 
            local blip = createBlipAttachedTo(tplayers, 0, 2, r, g, b, 255, 1, 70) 
            setElementParent(blip, playerBlipRoot) 
        end 
    end 
end 
addEventHandler("onClientResourceStart", root, resourceStart) 
  
local function playerJoin() 
    local r, g, b = getPlayerNametagColor(source) 
    local blip = createBlipAttachedTo(source, 0, 2, r, g, b, 255, 1,70) 
    setElementParent(blip, playerBlipRoot) 
    setTimer(updateBlipColor, 5000, 1, blip) --Upadate in 5 seconds, in case the server sets the color. 
end 
  
addEventHandler("onClientPlayerLogin", root, playerJoin) 
addEventHandler("onClientResourceStart", root, playerJoin) 
addEventHandler("onClientPlayerSpawn", root, playerJoin) 
  
local function playerQuit() 
    for _, blip in ipairs(getElementChildrene(playerBlipRoot)) do 
        if getElementAttachedTo(blip) == source then 
            destroyElement(blip) 
        end 
    end 
end 
addEventHandler("onClientPlayerQuit", root, playerQuit) 
  
function updateBlipColor(blip) 
    local player = getElementAttachedTo(blip) 
    if player then 
        local r, g, b = getPlayerNametagColor(player) 
        setBlipColor(blip, r, g, b, 255) 
    end 
end 

Thanks for your time

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