//===========================================================================
// I made a snippet for you to use ^.^
//
// [1] Backup your map first!
//
// [2] Make a trigger in your map and convert it to custom text and clear its
// contents.
//
// [3] Copy paste everything in here and paste it inside the new trigger
//
// [4] Rename it as "Item Limiter"
//
// [5] And your ready to go!
//===========================================================================
function Display_Duration takes nothing returns real
return 12.00 // <==this is how long the message will display itself
endfunction
function Message takes nothing returns string
return "|cffff0000WARNING!: You can only have one weapon of the same type!" // <==this is the error message shown
//when someone violates the item limit
endfunction
function Maximum_Item_Limit takes nothing returns integer
return 1 // <== this is the maximum item limit
endfunction
function Item_Limiter takes nothing returns boolean
local integer nloops =0
local integer nloopsmax =5
local integer ncounter =0
local unit ItemOwner =GetManipulatingUnit()
local item ItemAcquired =GetManipulatedItem()
local item ItemInSlot
local integer ItemTypeId =GetItemTypeId(ItemAcquired)
loop
exitwhen nloops>nloopsmax
set ItemInSlot=UnitItemInSlot(ItemOwner,nloops)
if(ItemInSlot!=null and GetItemTypeId(ItemInSlot)==ItemTypeId)then
set ncounter=ncounter+1
endif
set nloops=nloops+1
endloop
if(ncounter>Maximum_Item_Limit())then
call UnitRemoveItem(ItemOwner,ItemAcquired)
DisplayTimedTextToPlayer(GetOwningPlayer(ItemOwner),0,0,Display_Duration(),Message())
endif
set ItemOwner=null
set ItemInSlot=null
return false
endfunction
//===========================================================================
function InitTrig_Item_Limiter takes nothing returns nothing
local trigger Item_Limiter_Trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(Item_Limiter_Trg,EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition(Item_Limiter_Trg,Condition(function Item_Limiter) )
endfunction