• 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.

[Solved] Unit Variable Not Getting Set, Value = 0

Status
Not open for further replies.
Level 11
Joined
Aug 6, 2009
Messages
697
  • Actions
    • Custom script: local boolean InGroup
    • Custom script: local integer UnitType2
    • Custom script: local integer i = 0
    • Custom script: local boolean done
    • Custom script: set done = false
    • Custom script: set UnitType2 = 0
    • Custom script: set InGroup = true
    • Custom script: loop
    • Custom script: set UnitType2 = GetUnitTypeId(udg_DR_Units[i])
    • Custom script: set InGroup = IsUnitInGroup(udg_DR_Units[i], udg_DR_InUse)
    • Custom script: if udg_DR_UnitType == UnitType2 and InGroup == false then
    • Custom script: set udg_DR_Number = i
    • Unit Group - Add DR_Units[DR_Number] to DR_InUse
    • Unit Group - Remove DR_Units[DR_Number] from DR_NotInUse
    • Unit - Unhide DR_Units[DR_Number]
    • Unit - Change ownership of DR_Units[DR_Number] to DR_Player and Change color
    • Custom script: call SetUnitXY(udg_DR_Point,udg_DR_Units[i])
    • Custom script: set done = true
    • Custom script: elseif i == udg_DR_MaxIndex then
    • Custom script: set udg_DR_MaxIndex = udg_DR_MaxIndex + 1
    • Custom script: set udg_DR_Number = udg_DR_MaxIndex
    • Custom script: call CreateUnitAtLoc(udg_DR_Player, udg_DR_UnitType, udg_DR_Point, udg_DR_Angle)
    • Custom script: set udg_DR_Units[udg_DR_Number] = GetLastCreatedUnit() <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<HERE
    • Unit Group - Add DR_Units[DR_Number] to DR_InUse
    • Custom script: set done = true
    • Custom script: endif
    • Game - Display to (All players) the text: (String(DR_Number))
    • Game - Display to (All players) the text: (String(DR_UnitType))
    • Game - Display to (All players) the text: (Name of DR_Units[DR_Number])
    • Custom script: set i = i + 1
    • Custom script: exitwhen done == true
    • Custom script: endloop
 
CreateUnitAtLoc returns the unit, it doesn't store it into bj_lastCreatedUnit
JASS:
native CreateUnitAtLoc takes player id, integer unitid, location whichLocation, real face returns unit
Since it returns the unit, you can:
  • Custom script: set udg_DR_Units[udg_DR_Number] = CreateUnitAtLoc(udg_DR_Player, udg_DR_UnitType, udg_DR_Point, udg_DR_Angle)
 
Status
Not open for further replies.
Top