Jump to content

Team blips


Guest D-Eagle

Recommended Posts

In my DM gamemode, i want the radar to show only the player blips, who are on the same team as you are. I suppose, that this is done in a client-side script.

  
function cdm_clientResourceStart ( resourcename ) 
    if ( resourcename == getThisResource () ) then 
        updateBlips() 
    end 
end 
  
addEventHandler ( "onClientResourceStart", getRootElement(), cdm_clientResourceStart ) 
  
function dist2DFixed( element, x, y, z ) 
    local x1, y1, z1 = getElementPosition( element ) 
    local dist = (( x - x1 )^2) + (( y - y1 )^2) 
    return dist 
end 
  
function updateBlips() 
    local players = getElementsByType( "player" ) 
        local x, y, z = getElementPosition( getLocalPlayer() ) 
        for k,v in ipairs(players) do 
        if (getElementData ( v, "team" ) == getElementData ( getLocalPlayer(), "team" )) then  
            if ( dist2DFixed( v, x, y, z ) < 62500 ) then 
            createBlipAttachedTo ( v, 0, 2, 255, 255, 0, 255 ) 
            else 
            destroyBlipsAttachedTo ( v ) 
            end 
        end 
        end 
        setTimer( updateBlips, 2000, 0 ) 
end 

That is what i've tried, but the game gets stuck when i try to play it. Someone, help?

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