Flare
Stops copies me!
- Reaction score
- 662
JASS:
public function NewUnit takes player p, integer id, real x, real y returns unit
local integer i = 0
local boolean b = false
if UN != 0 then
loop
exitwhen i > UN or b
if id == GetUnitTypeId(U<i>) then
call ShowUnit(U<i>, true)
call SetUnitX(U<i>, x)
call SetUnitY(U<i>, y)
call SetUnitOwner(U<i>, p, true)
call BJDebugMsg (GetUnitName (U<i>))
set U[UN] = U<i>
set b = true
else
set i = i + 1
endif
endloop
if b != true then
call CreateUnit(p, id, x, y, 0)
endif
endif
if UN == 0 then
set U[0] = CreateUnit(p, id, x, y, 0)
else
set UN = UN - 1
endif
call SetHandleData(U[UN], 0)
call BJDebugMsg (GetUnitName (U[UN]))
return U[UN]
endfunction</i></i></i></i></i></i></i>
With your demonstration, it displayed Footman 3 times (even though the Id parameter only used 'hfoo' twice)