zZShinryuZz
Youtube Master Race
- 7/9/05
- 70
- 0
Mình hỏi trigger này có lỗi hay nên sửa gì không vậy ? Với lại vì sao mình destroy trigger thì nó không chạy ?
Mã:
function Add_charge_cond takes nothing returns boolean
return GetItemType(GetManipulatedItem()) == ITEM_TYPE_CHARGED
endfunction
function check_Item_in_loop takes item x, item y returns boolean
return ( x != y ) and ( GetItemTypeId(x) == GetItemTypeId(y) )
endfunction
function Trig_Add_charge_Actions takes nothing returns nothing
local unit owner = GetManipulatingUnit()
local item x = GetManipulatedItem()
local item y
local integer i = 0
local integer b
local boolean h = false
loop
exitwhen (i > 5) or (h == true)
set y = UnitItemInSlot(owner,i)
if ( check_Item_in_loop(x,y) ) then
if (GetItemCharges(y) != 99 ) then
set b = ( GetItemCharges(x) + GetItemCharges(y) )
if ( b <= 99 ) then
call SetItemCharges( y, b )
call RemoveItem(x)
else
call UnitRemoveItem( owner, x )
call SetItemCharges( x, b-99 )
call SetItemCharges( y, 99 )
endif
else
call UnitRemoveItem( owner, x )
endif
set h = true
endif
set i = i + 1
endloop
set x = null
set y = null
set owner = null
endfunction
//===========================================================================
function InitTrig_Add_charge takes nothing returns nothing
local trigger t
set t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( t, Condition( function Add_charge_cond ) )
call TriggerAddAction( t, function Trig_Add_charge_Actions )
// call DestroyTrigger(t)
// set t = null
endfunction
.
Jass bó tay 
.
(đang đau đầu với vụ này
)

)