• 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] why it returns (null)?

Status
Not open for further replies.
JASS:
call CreateUnit(Player(0),'hfoo',1,1,1)
set u[5] = GetLastCreatedUnit()
set s[5] = GetUnitName(u[5])
call Print(s[5])

why does this return null?
GetLastCreatedUnit() only works when using the BJ for creating a unit.

Basicly, change it to this, it should work:
JASS:
set u[5] = CreateUnit(Player(0),'hfoo',1,1,1)
set s[5] = GetUnitName(u[5])
call BJDebugMsg(s[5])
 
CreateUnit is not a BJ.
Here how GetLastCreatedUnit works :
JASS:
function CreateUnitAtLocSaveLast takes player id, integer unitid, location loc, real face returns unit

    if (unitid == 'ugol') then

        set bj_lastCreatedUnit = CreateBlightedGoldmine(id, GetLocationX(loc), GetLocationY(loc), face)

    else

        set bj_lastCreatedUnit = CreateUnitAtLoc(id, unitid, loc, face)

    endif



    return bj_lastCreatedUnit

endfunction



//===========================================================================

function GetLastCreatedUnit takes nothing returns unit

    return bj_lastCreatedUnit

endfunction

Source: Blizzard.J
 
Status
Not open for further replies.
Top