"call CreateUnit" problem

Tinki3

Special Member
Reaction score
418
Code:
call CreateUnit(GetOwningPlayer(u), GetUnitTypeID(u), udg_Creep_Location[GetRandomInt(1, 9)])
When I try to enable a trigger with that line in it, it comes up with an error saying "expected a name".

Can anyone help me fix?
 
1

1337D00D

Guest
I find it better to use CreateNUnitsAtLoc(), because GetLastCreatedUnit() dosen't seem to work with CreateUnit(). (At least for me.)
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
set bj_lastCreatedUnit = CreateUnit( Player, Unit type, x, y, facing )


Just a question, are you guessing what those functions need or do???
 

SFilip

Gone but not forgotten
Reaction score
634
I find it better to use CreateNUnitsAtLoc(), because GetLastCreatedUnit() dosen't seem to work with CreateUnit(). (At least for me.)
Uh you don't need LastCreatedUnit if you're using CreateUnit. LastCreatedUnit is simply a global variable and it exists so that you could somehow refer to the unit in GUI.
In Jass this is much easier. local unit u = CreateUnit(...) will set the local u to the unit you just created.
 

Chocobo

White-Flower
Reaction score
409
There are 5 CreateUnit<blabla>(<blabla>) functions.

- CreateUnit(player,unitId,x,y,facing)
It doesn't set bj_lastCreatedUnit. So you will have to write something like :

Code:
local unit u = CreateUnit(Player(0),'A000',0.00,0.00,359.99)


- CreateUnitAtLoc(player,unitId,loc,facing)
Again, it isn't setting bj_lastCreatedUnit.

Code:
local unit u = CreateUnitAtLoc(Player(0),'A000',Location(0.00,0.00),359.99)


- CreateUnitAtLocByName(player,unit's name,location,real)
This function is almost never used by all the people who uses GUI, it isn't setting also bj_lastCreatedUnit. And it crashes if you put a wrong string for the unit name.

Code:
local unit u = CreateUnitAtLocByName(Player(0),"Tauren",Location(0.00,0.00),359.99)


- CreateUnitAtLocSaveLast(player,unitId,location,real)
It saves the unit in bj_lastCreatedUnit. Also, if the unit's Id == 'ugol', it uses a Blighted Gold Mine.

Code:
local unit u
call CreateUnitAtLocSaveLast(Player(0),'ugol',Location(0.00,0.00),359.99)
set u = bj_lastCreatedUnit

[B]//or simply[/B]

local unit u = CreateUnitAtLocSaveLast(Player(0),'ugol',Location(0.00,0.00),359.99)


- CreateUnitByName(player,unit's name,x,y,facing)
It works like CreateUnitAtLocByName, whereas it takes x and y as parameters instead of a location. It isn't setting the unit to bj_lastCreatedUnit and crashes with a wrong unit name.

Code:
local unit u = CreateUnitByName(Player(0),"Priest",0.00,0.00,359.99)


You can also creates unitpools, if you know how to use them :

Code:
local unitpool up = CreateUnitPool
local unit u = UnitPoolAddUnitType(up,'A000',25.00) [B]//25.00 = Weight of 100.00, up = unitpool, 'A000' = UnitId[/B]
call UnitPoolRemoveUnitType(up,'A000') [B]Removes the unitId 'A000' from the unitpool up[/B]
call DestroyUnitPool(up)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top