• 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] Help me to remove items

Status
Not open for further replies.
Level 5
Joined
Jan 4, 2009
Messages
118
JASS:
function Test takes nothing reruns nothing

local unit u = GetManipulatingUnit()
local integer i
local integer quantity

loop
     if(quantity < 3)then
          RemoveItem(GetIndexItemOfTypeFromInventory(u, 'rat6')
          set quantity = quantity + 1
     endif
     set i = i + 1
     exitwhen i = bj_MAX_INVENTORY
endloop
endfunction

I try to coding jass to remove item equal 3 time on that above code ...
but It's not work ???

Tell me plz.
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
There are some syntax errors and mistakes with the code.

  • JASS:
    local integer i
    Needs to be initialized to 0.
  • JASS:
    RemoveItem(GetIndexItemOfTypeFromInventory(u, 'rat6')
    Needs the call before it.
  • JASS:
    exitwhen i = bj_MAX_INVENTORY
    It needs to be compared with ==
You should also post what the function GetIndexItemOfTypeFromInventory looks like since that could change how you should code this.
 
this will work...
JASS:
function Test takes nothing reruns nothing
   local unit u = GetTriggerUnit()
    local integer i = 0
    local integer quantity = 0
    local item it
    loop
        set it = UnitItemInSlot(u, i) 
        if (quantity < 3) and GetItemTypeId(it)=='rat6' then
            call RemoveItem(it)
            set quantity = quantity + 1
        endif
        set i = i + 1
        exitwhen i== bj_MAX_INVENTORY
   endloop
endfunction
 
Level 5
Joined
Jan 4, 2009
Messages
118
try this...

JASS:
function Test takes nothing reruns nothing
   local unit u = GetTriggerUnit()
    local integer i = 0
    local integer quantity = 0
    local item it
    loop
        set it = UnitItemInSlot(u, i) 
        if (quantity < 3) and GetItemTypeId(it)=='rat6' then
            call RemoveItem(it)
            set quantity = quantity + 1
        endif
        set i = i + 1
        exitwhen i== bj_MAX_INVENTORY
   endloop
endfunction

Sorry I think something wrong. If it's equal above code. It's remove item one each for one time, but I wanna remove three item in one time.

Ex. Orchid Malevolenece

Thanks for help
 
Status
Not open for further replies.
Top