scope NoItemDuplicates initializer init import SimError function countItems takes unit u, item i returns integer integer typ = GetItemTypeId(i) integer index = 0 integer count = 0 loop exitwhen index > 5 if GetItemTypeId(UnitItemInSlot(u, index)) == typ then count++ end index++ end return count end function act takes nothing returns boolean unit t = GetTriggerUnit() item i = GetManipulatedItem() if countItems(t, i) > 1 then UnitDropItemPoint(t, i, t.getX(), t.getY()) simError(t.getOwner(), "You can't carry two of the same item.") end return false end function init takes nothing returns nothing trigger trig = CreateTrigger() trig..registerAnyUnitEvent(EVENT_PLAYER_UNIT_PICKUP_ITEM)..addCondition(Condition(function act)) end endscope