• 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] Function problem

Status
Not open for further replies.
Level 3
Joined
Nov 7, 2006
Messages
36
Could someone just tell me whats wrong with this line of code (WE don't like it)

JASS:
call GroupEnumUnitsOfType(towns, h000, null)

WE says something about an expected name. And btw towns is a unit group, h000 is a unit id and null is a boolean expression.
 
Level 3
Joined
Nov 7, 2006
Messages
36
Yay! worked :p +rep

{EDIT}
even though i got the line right the whole trigger don't work. Its meant to give all players the same amount of towns.

JASS:
function Trig_Give_Towns_Actions takes nothing returns nothing
    local group towns = CreateGroup()
    local integer number_of_towns = CountUnitsInGroup(towns)
    local unit town
    local integer player_number = 0
    call GroupEnumUnitsOfType(towns, GetObjectName('h000'), null)
    loop
        set town = FirstOfGroup(towns)
        exitwhen town == null
        call SetUnitOwner(town, Player(player_number), true)
        call GroupRemoveUnit(towns, town)
        if player_number == 11 then
            set player_number = 0
        else
            set player_number = 1 + player_number
        endif 
    endloop
    call DestroyGroup(towns)
endfunction

//===========================================================================
function InitTrig_Give_Towns takes nothing returns nothing
    set gg_trg_Give_Towns = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Give_Towns, 1.00 )
    call TriggerAddAction( gg_trg_Give_Towns, function Trig_Give_Towns_Actions )
endfunction
Anyone wanna help?
 
Last edited by a moderator:
JASS:
    local group towns = CreateGroup()
    local integer number_of_towns = CountUnitsInGroup(towns)
Don't get it; you create the group and afterwards you count the units in it?
Anyway, why don't you just create a unit for each player, instead of doing this? Apart from that,
JASS:
call SetUnitOwner(town, Player(player_number), true)
-> Player(player_number + 1)
 
Level 3
Joined
Nov 7, 2006
Messages
36
Anyway, why don't you just create a unit for each player, instead of doing this?
Well tbh the trigger is not yet completely done. Well yea i know its not even working, but anyway. When its completed it will split upp all the towns between all players, which means that if you are less players you will start with more towns.
Edit: YES! Finaly i got it, used:
JASS:
set towns = GetUnitsOfTypeIdAll('h000')
instead of
JASS:
call GroupEnumUnitsOfType(towns, GetObjectName('h000'), null)
 
Last edited:
Status
Not open for further replies.
Top