Jump to content

HUD


Anubhav

Recommended Posts

  
    function destroyAllBlips(player) 
        local attached = getAttachedElements ( player ) 
        if ( attached ) then 
            for k,element in ipairs(attached) do 
                if getElementType ( element ) == "blip" then 
                    destroyElement ( element ) 
                end 
            end 
        end 
    end 
    function createBlips() 
    destroyAllBlips(root) 
    local players = getElementsByType ( "player" ) 
    for k,v in ipairs(players) do 
    local r,g,b,a = getTeamColor(getPlayerTeam(v)) 
    createBlipAttachedTo(v,0,2,r,g,b,a,0,99999.0) 
    end 
    end 
    setTimer(createBlips,500,0) 
    function destroyer( thePlayer ) 
    destroyAllBlips( thePlayer ) 
end 
addEventHandler("onPlayerQuit",root,destroyer) 
  
  

Link to comment

try this:

blips = { } 
function createBlips() 
local players = getElementsByType ( "player" ) 
for k,v in ipairs(players) do 
if isElement (blips[v]) then 
destroyElement (blips[v]) 
blips[v] = nil 
end 
local r,g,b,a = getTeamColor(getPlayerTeam(v)) 
blips[v] = createBlipAttachedTo(v,0,2,r,g,b,a,0,99999.0, root) 
end 
end 
setTimer(createBlips,500,0) 
  
function destroyer() 
if isElement (blips[source]) then 
destroyElement (blips[source]) 
blips[source] = nil 
end 
end 
addEventHandler("onPlayerQuit",root,destroyer) 
Link to comment

WTF, why are you spamming the createBlips function? That's one way to bring the servers performance down.

  
    function destroyAllBlips(player) 
        local attached = getAttachedElements ( player ) 
        if ( attached ) then 
            for k,element in ipairs(attached) do 
                if getElementType ( element ) == "blip" then 
                    destroyElement ( element ) 
                end 
            end 
        end 
    end 
    function createBlips() 
    destroyAllBlips(root) 
    local players = getElementsByType ( "player" ) 
    for k,v in ipairs(players) do 
    local r,g,b,a = getTeamColor(getPlayerTeam(v)) 
    createBlipAttachedTo(v,0,2,r,g,b,a,0,99999.0) 
    end 
    end 
    setTimer(createBlips,500,0) 
    function destroyer( thePlayer ) 
    destroyAllBlips( thePlayer ) 
end 
addEventHandler("onPlayerQuit",root,destroyer) 
  
  

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