HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Iterating through a group in JASS?

01-11-2006, 01:00 AM#1
PCPharaoh
Can anyone give me a nice snippit of code for iterating through a player group, so that I can use locals and everything, and don't have to use ForForceBJ?
01-11-2006, 01:06 AM#2
Vexorian
Collapse JASS:
 local integer u=1
 local integer i=0


    loop
         exitwhen(i>15)
         if (IsPlayerInForce(Player(i), Theforce  )) then
              //do something to Player(i)
         endif
         set i=i+1
    endloop


01-11-2006, 01:10 AM#3
Nantuko Husk
you could use something like this

Collapse JASS:
    local integer index = 0
    local player p
    local force f //your player group

    loop
    exitwhen index > 15
        set p = Player ( index )
        if IsPlayerInForce ( p , f ) then
                //do your stuff here
        else
               // else actions
        endif 
        set index = index + 1
    endloop   


EDIT :

hahaha lol

btw vex , why is needed that u integer
01-11-2006, 01:11 AM#4
PCPharaoh
Thanks Vex. You made me feel dumb for not thinking of something so simple. Anyway, is there a point to the u variable? I don't see it referenced anywhere.

EDIT: haha. Basically the exact same code. :D Thanks to you too, Nantuko.
01-11-2006, 01:12 AM#5
Vexorian
The u integer is there so he knows that he could use it
01-11-2006, 01:14 AM#6
PCPharaoh
What?? You lost me vex.
01-11-2006, 01:16 AM#7
Nantuko Husk
~_~ yes , yes I know :p

btw I was writing that code at JSP so I didnt see vex posting it.
01-11-2006, 01:30 AM#8
Vexorian
Nantuko: Your sig is crap, AbilityId2String() never worked at all
01-11-2006, 01:33 AM#9
Nantuko Husk
I write Random Jass Crap. what's the problem.

btw I write that we got a replacement AbilityId2String() ,with GetObjectName ( blah ) we can get the internal name of a spell , buff , or any object editor stuff. Thing that AbilityId2String() never did. :p