///////////////////////sell item///////////////////////
function sell_point takes nothing returns nothing
set sell_point = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( sell_point, EVENT_PLAYER_UNIT_SELL_ITEM ) //任意單位出售物品
call TriggerAddAction(sell_point, function sell_point2)
endfunction
function sell_point2 takes nothing returns nothing
if ((GetItemTypeId(GetSoldItem()) == 'I000')) then //物品A被出售
set point = false //全域變量point變成false
else
endif
endfunction
///////////////////////buy item///////////////////////
function buy_point takes nothing returns nothing
set buy_point = CreateTrigger()
call TriggerRegisterUnitEvent( buy_point, gg_unit_h000_0000, EVENT_UNIT_SELL ) //自定義商店0000出售單位
call TriggerAddAction(buy_point, function buy_point2)
endfunction
function buy_point2 takes nothing returns nothing
if ((IsUnitType(GetBuyingUnit(), UNIT_TYPE_HERO) == true)) then //購買者是英雄
if ((point == false)) then //全域變量是false 即是沒人買過物品
call UnitAddItemByIdSwapped( 'I000', GetBuyingUnit() ) //建立物品A給購買者
set point = true //全域變量設為true
else
call UnitAddItemByIdSwapped( 'I001', GetBuyingUnit() ) //建立物品B給購買者
endif
else
endif
endfunction
因為再看一次你的意思是物品A只能有一個 其餘買的都是物品B
所以布林值不設為陣列
[ 本帖最後由 Frayja 於 2014-5-19 12:54 編輯 ]