• 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] spawning units from building

Status
Not open for further replies.
i have this so far but for some reason it doesnt add the unit to the group

JASS:
function Trig_Battlegrounds_setting_Groups_Actions takes nothing returns nothing
    local unit u
    set u = GetTrainedUnit()
    call GroupAddUnit( Battlegrounds_Group_Player[0], u )
    
endfunction

//===========================================================================
function InitTrig_Battlegrounds_setting_Groups takes nothing returns nothing
    set gg_trg_Battlegrounds_setting_Groups = CreateTrigger(  )
    call TriggerRegisterUnitEvent( gg_trg_Battlegrounds_setting_Groups, gg_unit_u00J_0085, EVENT_UNIT_TRAIN_FINISH )
    call TriggerAddAction( gg_trg_Battlegrounds_setting_Groups, function Trig_Battlegrounds_setting_Groups_Actions )
endfunction

and its for like when barracks creates a unit
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
If your Unit Group is an array type, it would return as null, you need to actually call a function to create that Unit Group first, before do something to it (Add/Remove).

For example;
set udg_UnitGroup[0] = CreateGroup()

Then only, you can access that Unit Group.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
In the post #4, I don't see any CreateGroup() function there ?
As I said before, if it is a Unit Group variable with ARRAY enabled, you must create it first by using the function CreateGroup() before accessing it.

You can't simply have globals to a Unit Group ARRAY, if it is non-array, well you can leave it as it is.

But we're talking about ARRAY Unit Group, that is why that function is needed.
 
lol i found out the problem i accidently set the units being trained in the unit editor to units sold instead of units trained lol oops thx for ur help tho and ik #4 isnt the trigger tht the group is created in it is created in another group thts wat i meant ive dealt w group arrays i have a few in my map it was the first thing i looked at it was just under the object editor tht it was the problem lol and in post #5 i said it was created in the trigger tht declares it as a group lol i did not say tht the trigger i posted on here was the trigger tht declared or created it
 
Status
Not open for further replies.
Top