Jump to content

Remove all empty teams


spAik

Recommended Posts

Hi,

I try to remove all empty teams when a player quits...

Whats wrong? :P

function initiate() 
  teams = {} 
    for k,v in pairs(getElementsByType("team")) do 
            local team = v.team 
            if isElement(team) and getElementType(team) == "team" then 
                if countPlayersInTeam(team) == 0 then 
                    destroyElement(team) 
                end 
            end 
        end 
end 
  
addEventHandler("onPlayerQuit",getRootElement(),initiate) 

Link to comment
function initiate ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team ) then 
        if ( countPlayersInTeam ( team ) == 1 ) then 
            destroyElement ( team ) 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", getRootElement(), initiate ) 

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