HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with Unit Object and Unit Ownership

12-06-2009, 06:14 PM#1
NewRelic
Alright, my problem is when I call "SetUnitOwner", it wants me to pass a unit object, but I have a long list of locations, so I am looping them. But when attempting to pass a joined string of the unit, it tells me I "cannot convert string to unit". I have looked everywhere for a function that I can call to convert the object ID to a unit object with no luck. If I pass the actual string, no quotes of course. It treats it like a unit object just fine, but the location number needs to be dynamic based on my array list.

Collapse JASS:
call SetUnitOwner(gg_unit_hbar_0001, Player(0), true ) // WORKS 

Collapse JASS:
call SetUnitOwner("gg_unit_hbar_"+Locations[c], Player(0), true ) // DOES NOT WORK

I have already tried using a group instead of an array and tried using a unit array, both say undeclared variable "gg_unit_hbar_xxxx", where xxxx = object ID

Collapse JASS:
 

        local string array Locations

        set Locations[0] = "0056"
    set Locations[1] = "0145"
    set Locations[2] = "0151"
    set Locations[3] = "0148"
    set Locations[4] = "0154"
    set Locations[5] = "0157"

        set c = 0
        loop
            exitwhen c >= 4
                        
            // Assign Ownership

            //call SetUnitOwner(gg_unit_hbar_0001, Player(0), true )
            call SetUnitOwner("gg_unit_hbar_"+Locations[c], Player(0), true )
     
            set c = c + 1
        endloop