item whichitem help

jig7c

Stop reading me...-statement
Reaction score
123
im using a condition which is

private function Conditions takes nothing returns boolean
return UnitHasItem (GetKillingUnit(), item whichItem )
endfunction

what goes in the which item part..

the name of the item is Golden Ring
and the item id is I01L, but it doesn't accept integer.. what goes there
 

tooltiperror

Super Moderator
Reaction score
231
You're trying to put in [LJASS]'I01L'[/LJASS], which is an integer that identifies a type of item.

You should be putting in an actual item.

JASS:
globals
    item GlobalItem=CreateItem('I01L',...)
endglobals

private function foo_conditions takes nothing returns nothing
     return UnitHasItem(GetKillingUnit(),GlobalItem)
endfunction


To see if a unit has any item of the type [LJASS]'I01L'[/LJASS] then you could loop through the items it has with [LJASS]UnitItemInSlot[/LJASS].

EDIT: Maybe...

JASS:
// untested
 function UnitHasItemById takes unit whichUnit, integer Id returns boolean
 	 local integer index=0
 	 loop
		 if (GetItemTypeId(UnitItemInSlot(whichUnit,index))==Id) then
			 return true
		 endif
		 set index=index+1
		 exitwhen index == UnitInventorySize(whichUnit)
	 endloop
	 return false
 endfunction
 
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