spAik Posted August 27, 2013 Share Posted August 27, 2013 Hi, I try to remove all empty teams when a player quits... Whats wrong? 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
Castillo Posted August 27, 2013 Share Posted August 27, 2013 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
spAik Posted August 28, 2013 Author Share Posted August 28, 2013 oh. thanks, your version works perfect Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now