Warcraft III resources & community, 2003–2006 · archived

Hi, I need hardly Help with this JASS script

3 posts
#1

Hi, I need hardly Help with this JASS script

Hello i need help with this Jass script its a system "when a unit gets 3 items from type campaign each next gets dropped" pls i need badly help!
function Trig_DropOnGet3 takes nothing returns nothing
    local integer CountItemSlots = 1
    local integer CountReagsInventory
    local item ReagMani = GetManipulatedItem()
    local unit manipulator = GetManipulatingUnit()
    
    if ( GetItemType(ReagMani) == ITEM_TYPE_CAMPAIGN ) then
        loop
        exitwhen CountItemSlots == 6
        if ( CountReagsInventory == 3 ) then
            call UnitRemoveItem(manipulator, ReagMani)
            
        else
        endif
        if ( GetItemType(UnitItemInSlotBJ(manipulator, CountItemSlots)) == ITEM_TYPE_CAMPAIGN ) then
           set CountReagsInventory = CountReagsInventory + 1
        else
            
        endif
        set CountItemSlots = CountItemSlots + 1
    endloop
    else
        
    endif
endfunction

//===========================================================================
function InitTrig_Reag_System takes nothing returns nothing
    set gg_trg_Reag_System = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Reag_System, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_Reag_System, function Trig_DropOnGet3 )
endfunction
#2
try changing

local integer CountReagsInventory


to

local integer CountReagsInventory = 0


if you leave an integer/real at null and try to ADD a value to it ( ex set i = i + 1 when i == null ) will cause a line break

also try to get rid of those messy BJs if u can
#3

Thank you!

Yeah that was the problem big thanks! :D