valeman2
V
valeman2
How limit the items that you buy?
I want limit 1 but i dont know to i forgot anyone can help?
I want limit 1 but i dont know to i forgot anyone can help?

Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.

//===========================================================================
// 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
What code, and what options?S@Kobas can you edit the code se he can have options?
Alain.Mark, use DisplayTimedTextToPlayer() for fake error messages; the BJDebugMsg() displays messages for an unlimited amount of time.
==>I edited it already so he can configure the time.Yeah those one minute time periods take forever.
==> I mean the snippet i made so he can choose between DisplayTimedTextToPlayer() or use Floating texts.What code, and what options?
