edit: i wish i could spell
i have this trigger that i got from hiveworkshop and its for an item limit system, but my problem is that it doesnt refund money if you buy the item. i wanna know if someone could help me with it, tell me how i could refund the hero if they buy it, but cant use it.
i have this trigger that i got from hiveworkshop and its for an item limit system, but my problem is that it doesnt refund money if you buy the item. i wanna know if someone could help me with it, tell me how i could refund the hero if they buy it, but cant use it.
JASS:
function Add_Group_Limits takes integer num returns nothing
local item It = GetManipulatedItem()
local unit u = GetTriggerUnit()
local integer ut = GetUnitTypeId(u)
local integer it = GetItemTypeId(It)
local string grp = GetStoredString(GameCache(),"ItemStoreGroup"+I2S(it),"AddGroupGet"+I2S(num))
local integer i = 0
local integer limit = 0
local integer ulimit = GetStoredInteger(GameCache(),"UnitID"+I2S(ut),"GroupName"+grp)
if It == null then
set u = null
return
endif
if ulimit == 0 then
call UnitRemoveItem(u,It)
if grp == null then
call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, "|cFF00FFFFYou can039;t have items of this type")
else
call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, "|cFF00FFFFYou can039;t have items of type "+grp)
endif
set It = null
set u = null
return
endif
loop
exitwhen i > 5
if GetStoredBoolean(GameCache(),"ItemStoreGroup"+I2S(GetItemTypeId(UnitItemInSlot(u,i))),"GroupName"+grp) == true and UnitItemInSlot(u,i) != It then
set limit = limit + 1
endif
set i = i + 1
endloop
if limit >= ulimit then
call UnitRemoveItem(u,It)
if ulimit == 1 then
call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, "|cFF00FFFFYou can039;t have more than "+I2S(ulimit)+" item of type "+grp)
else
call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, "|cFF00FFFFYou can039;t have more than "+I2S(ulimit)+" items of type "+grp)
endif
else
if GetStoredString(GameCache(),"ItemStoreGroup"+I2S(it),"AddGroupGet"+I2S(num+1)) != null then
call Add_Group_Limits(num+1)
endif
endif
set It = null
set u = null
endfunction
function Check_Group_Limits takes nothing returns nothing
local item It = GetManipulatedItem()
local unit u = GetTriggerUnit()
local integer ut = GetUnitTypeId(u)
local integer it = GetItemTypeId(It)
local string grp = GetStoredString(GameCache(),"ItemStoreGroup"+I2S(it),"GroupGet")
local integer i = 0
local integer limit = 0
local integer ulimit = GetStoredInteger(GameCache(),"UnitID"+I2S(ut),"GroupName"+grp)
if It == null then
set u = null
return
endif
if ulimit == 0 and (grp != null) then
call UnitRemoveItem(u,It)
//if grp == null then
//call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, "|cFF00FFFFYou can't have items of this type")
//else
// call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, "|cFF00FFFFYou can't have items of type "+grp)
// endif
set It = null
set u = null
return
endif
loop
exitwhen i > 5
if GetStoredBoolean(GameCache(),"ItemStoreGroup"+I2S(GetItemTypeId(UnitItemInSlot(u,i))),"GroupName"+grp) == true and UnitItemInSlot(u,i) != It then
set limit = limit + 1
endif
set i = i + 1
endloop
if limit >= ulimit and (grp != null) then
call UnitRemoveItem(u,It)
if ulimit == 1 then
call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, "|cFF00FFFFYou can039;t have more than "+I2S(ulimit)+" item of type "+grp)
else
call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, "|cFF00FFFFYou can039;t have more than "+I2S(ulimit)+" items of type "+grp)
endif
else
if GetStoredString(GameCache(),"ItemStoreGroup"+I2S(it),"AddGroupGet"+I2S(1)) != null then
call Add_Group_Limits(1)
endif
endif
set It = null
set u = null
endfunction
function Check_Dummy takes nothing returns boolean
return (GetUnitTypeId(GetTriggerUnit()) != 039;h000039;)
endfunction
//===========================================================================
function InitTrig_ItemCheckGroupLimits takes nothing returns nothing
set gg_trg_ItemCheckGroupLimits = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_ItemCheckGroupLimits,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition( gg_trg_ItemCheckGroupLimits, Condition(function Check_Dummy))
call TriggerAddAction( gg_trg_ItemCheckGroupLimits, function Check_Group_Limits )
endfunction