spAik Posted August 27, 2013 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)
Castillo Posted August 27, 2013 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 )
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