delete group of selected units command ?

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
itsonlyaname
Senior Member
Posts: 195
Joined: February 13th, 2008, 5:30 pm

delete group of selected units command ?

Post by itsonlyaname »

i've been experimenting a bit, and now i'm trying to make a command that deletes all selected units when typed.

Code: Select all

local group g=CreateGroup()
...
if SubString(s,0,4)=="-del"then
        loop
            exitwhen i>1
            call RemoveUnit(FirstOfGroup(g))
            set i=i+1
        endloop
endif
but, this only removes 1 unit from the group, even if i change "exitwhen i>1" to "exitwhen i>2" or higher.
i tried with the ForGroupBJ command too, but it didn't work either.
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: delete group of selected units command ?

Post by Aero »

Code: Select all

function Remove takes nothing returns nothing
call RemoveUnit(GetEnumUnit())
endfunction
Use this...

Code: Select all

call ForGroup(g,function Remove)