• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Problem with IsUnitInGroup

Status
Not open for further replies.
Level 11
Joined
Sep 12, 2008
Messages
657
Hey.. im working on a system that picks every unit in a group, and is added by public function called add,

everything works fine, and all.. but when the same unit is added twice, it does same effect on same unit, just twice.

for example, making him move a bit to the right, he will do that twice instead of once.

i used the IsUnitInGroup(GroupName, Unit), and for some reason. it still does it twice.. any ideas?


JASS:
public function Add takes unit u, real x returns nothing
    
        call UnitAddAbility(u, 'Amrf')
        call UnitRemoveAbility(u, 'Amrf')
        call MC_Actions(u)
        
            if MC_UIGD == true then
                    
                call SetUnitFlyHeight(u, x + 50, 0)
                set MC_UIGD = false
                    
            elseif MC_UIGU == true then
                    
                call SetUnitFlyHeight(u, x - 50, 0)
                set MC_UIGU = false
                    
            elseif MC_UISS == true then
            
                call SetUnitFlyHeight(u, x, 0)
                set MC_UISS = false
                
            endif
            
                if IsUnitInGroup(u, Group) == false then
                    call GroupAddUnit(Group, u)
                endif
endfunction


thanks in advance.
 
JASS:
public function Add takes unit u, real x returns nothing
		if not IsUnitInGroup(u, Group) then
			call GroupAddUnit(Group, u)
		else
			return
		endif

    
        call UnitAddAbility(u, 'Amrf')
        call UnitRemoveAbility(u, 'Amrf')
        call MC_Actions(u)
        
		if MC_UIGD == true then
				
			call SetUnitFlyHeight(u, x + 50, 0)
			set MC_UIGD = false
				
		elseif MC_UIGU == true then
				
			call SetUnitFlyHeight(u, x - 50, 0)
			set MC_UIGU = false
				
		elseif MC_UISS == true then
		
			call SetUnitFlyHeight(u, x, 0)
			set MC_UISS = false
			
		endif
            
endfunction
Try this, it checks before making any action.
 
Level 11
Joined
Sep 12, 2008
Messages
657
Thats great.. but it never works after first try now.. AND Yes it does remove him from group, cuz i did DisplayTextToForce when inside group.. and it stops showing after 3-5 seconds...

edit: aha.. my bad, it works perfect, thanks alot =]
 
Status
Not open for further replies.
Top