| 06-29-2004, 09:10 PM | #1 |
Code:
function Hero_swapInv takes unit hero returns nothing
local unit temp=CreateUnit(Player(15),'Hpal',0,0,0)
local unit hero1=Hero_getHero1(hero)
local integer i=0
local integer id=blankID()
call ShowUnit(temp, false)
loop
exitwhen 6-UnitInventoryCount(hero)==0
call UnitAddItemById(hero,id)
endloop
loop
exitwhen 6-UnitInventoryCount(hero1)==0
call UnitAddItemById(hero1,id)
endloop
loop
exitwhen i>5
call UnitAddItem(temp,UnitItemInSlot(hero1,i))
call UnitAddItem(hero1,UnitItemInSlot(hero,i))
call UnitAddItem(hero,UnitItemInSlot(temp,i))
set i=i+1
endloop
set i=0
loop
exitwhen i>5
call RemoveItem(GetItemOfTypeFromUnitBJ(hero,id))
call RemoveItem(GetItemOfTypeFromUnitBJ(hero1,id))
set i=i+1
endloop
call ShowUnit(temp,true)
call RemoveUnit(temp)
endfunctionTHis function works fine for swapping items when hero1s inventory is blank, but it doesn't when hero1s inventory has some stuff in it. THen it ONLY gives hero back the item in slot 1 of hero1. What did I do wrong here? |
