Give item to hero in slot? or move item to slot?

woot

New Member
Reaction score
8
Is it possible to give an item to a hero in a specific slot number? (or move an item to a specific slot) ?

If so.... how?


Thanks :)



I coded something that should do the trick:
JASS:
function AddItemUnitSlot takes integer itemId, unit u, integer slot returns item
    local integer i = 0
    local item array dummies[6]
    local integer dummiesSize = 0
    local item itemAdded = null
    
    if(slot < 1 or slot > 6)then
        return null
    endif
    
    if(UnitItemInSlotBJ(u, slot)!=null)then
        return null
    endif
    
    set i = 1
    loop
    exitwhen i > slot
        if(i==slot)then
            set itemAdded = UnitAddItemByIdSwapped( itemId, u )
            exitwhen true
        else
            if(UnitItemInSlotBJ(u, i)==null)then
                //add DUMMY ITEM
                set dummies[dummiesSize]=UnitAddItemByIdSwapped( 'I00G', u )
                set dummiesSize = dummiesSize+1
            endif
        endif
    set i=i+1
    endloop
    
    //remove dummies
    set i = 0
    loop
    exitwhen i>= dummiesSize
        call RemoveItem(dummies<i>)
        set dummies<i>=null
    set i=i+1
    endloop
    
    return itemAdded
endfunction
</i></i>
 

Samael88

Evil always finds a way
Reaction score
181
I don't think there is a function for that:(

But you can solve it by developing a small system for it.
One that fills the none required slots with items then add the new one and remove the "fillings" again:)

You will need an item array of 6. Then check the items in slots.
Say it turns out like this:
slot1: item
slot2: none
slot3: item
slot4: Here is where you want yours.

If you just add yours it will en up in slot2, but instead do this:
slot1: item
slot2: fill this with something for a milisec.
slot3: item
slot4: Then your item will end up here!

Then you just need to remove the "fillings" when done:thup:
 

woot

New Member
Reaction score
8
lol

I'm removing items from hero's inventories and adding them back again as a different item (but the same item)

which works fine unless there is a blank space in the inventory above that item


thank's im gunna check out your dummy item thing


Dummy item thing programmed.. I haven't tested it.. but I think it will work :D

JASS:
function AddItemUnitSlot takes integer itemId, unit u, integer slot returns item
    local integer i = 0
    local item array dummies[6]
    local integer dummiesSize = 0
    local item itemAdded = null
    
    if(slot &lt; 1 or slot &gt; 6)then
        return null
    endif
    
    if(UnitItemInSlotBJ(u, slot)!=null)then
        return null
    endif
    
    set i = 1
    loop
    exitwhen i &gt; slot
        if(i==slot)then
            set itemAdded = UnitAddItemByIdSwapped( itemId, u )
            exitwhen true
        else
            if(UnitItemInSlotBJ(u, i)==null)then
                //add DUMMY ITEM
                set dummies[dummiesSize]=UnitAddItemByIdSwapped( &#039;I00G&#039;, u )
                set dummiesSize = dummiesSize+1
            endif
        endif
    set i=i+1
    endloop
    
    //remove dummies
    set i = 0
    loop
    exitwhen i&gt;= dummiesSize
        call RemoveItem(dummies<i>)
        set dummies<i>=null
    set i=i+1
    endloop
    
    return itemAdded
endfunction

</i></i>
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top