Well, this is my second jass script I ever wrote. Sort of. Not really, since ¾ of it is yours.
Fun stuff. Liking it more than GUI already, damn why did I stick with GUI for 6 years
(and refused to learn hashtables + timers, all I know is arrays lmao).
JASS:
function item_is_in_pool takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I06B'
/*************************************************************************************
replace the above line with
return GetItemType(GetManipulatedItem()) != ITEM_TYPE_PURCHASABLE
if you want all items bounded except for items of purchasable class
or something like
return GetItemTypeId(GetManipulatedItem()) == 'xxxx' or GetItemTypeId(GetManipulatedItem()) == 'xxxx'
if you want to bound only 2 item types, etc
*************************************************************************************/
endfunction
function set_item_player takes nothing returns nothing
local unit u=GetTriggerUnit()
local item i=GetManipulatedItem()
local force f=GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit()))
if (GetItemUserData(i) == 0) then
call SetItemUserData(i, GetConvertedPlayerId(GetOwningPlayer(u)))
endif
if (GetItemUserData(i) != GetConvertedPlayerId(GetOwningPlayer(u))) then
call UnitRemoveItemSwapped( GetManipulatedItem(), GetTriggerUnit())
call DisplayTextToForce(f, "This item belongs to " + GetPlayerName(ConvertedPlayer(GetItemUserData(i))))
endif
set u=null
set i=null
set f=null
endfunction
function InitTrig_item_pickup takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t,Condition(function item_is_in_pool))
call TriggerAddAction(t,function set_item_player)
set t=null
endfunction
Trigger name: item pickup
What it does: items bound by player, gives message of who owner is if other player tries to pick.
EDIT: I did this by setting Item Custom Value to Player # of manipulator. Just thought you'd need to know in case you ever want to edit it.