[HELP] LoadUnitHandle error

Iky

New Member
Reaction score
2
i'm having problem with LoadUnitHandle, why it does not work?

JASS:
function CallBack takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = LoadUnitHandle(udg_kbhs, GetHandleId(t), 0)
call KillUnit(u)
call BJDebugMsg("!")
endfunction

function SHActions takes nothing returns nothing
    local unit c
    local timer tm
    if ( GetSpellAbilityId() == 'Iky0' ) then
        set c = GetTriggerUnit()
        set tm = CreateTimer()
        call SaveUnitHandle(udg_kbhs, GetHandleId(tm), 0 , c)
        call TimerStart(tm,5,false,function CallBack)
    endif
endfunction

function InitTrig_SH takes nothing returns nothing
    local trigger b = CreateTrigger ()
    call TriggerRegisterAnyUnitEventBJ( b, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( b, function SHActions )
    set b = null
endfunction
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
JASS:
function CallBack takes nothing returns nothing
    local timer t = GetExpiredTimer() //same as below, no use for setting a timer variable to the expired timer if you reference it once
    call KillUnit(LoadUnitHandle(udg_kbhs, GetHandleId(t), 0)) //if you only reference a unit once, just replace the variable you are using with the actual actions to get that unit, same with SHActions
    call BJDebugMsg("!")
endfunction

function SHActions takes nothing returns boolean //need to return boolean for "condition" functions, see trigger creation below
    local timer tm
    if ( GetSpellAbilityId() == 'Iky0' ) then
        set tm = CreateTimer()
        call SaveUnitHandle(udg_kbhs, 'SHTimer', 0 , GetTriggerUnit()) //dont use a timer handle as the parent, because you either need to set it to a global or leak a timer handle
        call TimerStart(tm,5,false,function CallBack)
        set tm = null //null timer handles or they leak
    endif
    return false //need to return boolean for "condition" functions, see trigger creation below
endfunction

function InitTrig_SH takes nothing returns nothing
    local trigger b = CreateTrigger ()
    call TriggerRegisterAnyUnitEventBJ( b, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( b, Filter(function SHActions)) //use TriggerAddCondition instead, notice the Filter(function SHActions), for some reason traditional actions seem to leak
    set b = null
endfunction


-->

JASS:
function SHActions takes nothing returns boolean
    if ( GetSpellAbilityId() == 'Iky0' ) then
        call TriggerSleepAction(5)
        call KillUnit(GetTriggerUnit())
        call BJDebugMsg("!")
    endif
    return false
endfunction

function InitTrig_SH takes nothing returns nothing
    local trigger b = CreateTrigger ()
    call TriggerRegisterAnyUnitEventBJ( b, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( b, Filter(function SHActions))
    set b = null
endfunction
 

Iky

New Member
Reaction score
2
JASS:

function CallBack takes nothing returns nothing
    local timer t = GetExpiredTimer() 
    call KillUnit(LoadUnitHandle(udg_kbhs, GetHandleId(t), 0)) 
    call BJDebugMsg("!")
endfunction

function SHActions takes nothing returns nothing
    local timer tm
    if ( GetSpellAbilityId() == 'Iky0' ) then
        set tm = CreateTimer()
        call SaveUnitHandle(udg_kbhs, 'SHTimer', 0 , GetTriggerUnit()) //the rawcode of timer does not work, syntase error
        call TimerStart(tm,5,false,function CallBack)
        set tm = null 
    endif
endfunction

function InitTrig_SH takes nothing returns nothing
    local trigger b = CreateTrigger ()
    call TriggerRegisterAnyUnitEventBJ( b, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( b, Filter(function SHActions)) 
    set b = null
endfunction
 

Iky

New Member
Reaction score
2
i'm learnning about hashtables in jass, so i'm just experimenting,
i know what you did ^^
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top