• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] jass is driving me insane(need some help)

Status
Not open for further replies.
Level 2
Joined
Oct 2, 2006
Messages
24
Hello again,

im still trying to make handles work in ROC and here's the next issue.
I copied the handle script into blizzard.j, thx to low-life for that suggestion.
The awesome thing is that WE actually accepts my scripts with handle functions in it
now, it doenst crash or give erros! wooohhaaaa!!!

But...the script doenst execute. It is meant to display a message to me when i kill a unit but that just doesnt happen. The script looks good to me, no syntax errors.

JASS:
function text takes nothing returns nothing
    local string A = "omg u killed"
    local timer t = CreateTimer()
    local unit killer = GetHandleUnit(t,"testing")
    local unit d = GetHandleUnit(t,"tester")
    local string B = GetUnitName(d)
    call DisplayTimedTextToPlayer(GetOwningPlayer(killer),0,0,500,"A+B")
    set killer = null
    set d = null
    set A = null
    set B = null
    call DestroyTimer(t)
endfunction

function Trig_handletesting_Actions takes nothing returns nothing
    local unit killer = GetKillingUnit()
    local unit dieer = GetTriggerUnit()
    local timer t = CreateTimer()
    call SetHandleHandle(t,"testing",killer)
    call SetHandleHandle(t,"tester",dieer)
    call TimerStart(t,10,false,function text)
    set killer = null
    set dieer = null
    call DestroyTimer(t)
    call FlushHandleLocals(t)
    
endfunction

//===========================================================================
function InitTrig_handletesting takes nothing returns nothing
    set gg_trg_handletesting = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_handletesting, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_handletesting, function Trig_handletesting_Actions )
endfunction


Does anyone have a clue why this is the case?

thanks,
frenksel
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Cause you destroy the timer right after you start running it?

The timer call doesnt pause the calling function, or everyone would just use it as a substitute for Wait.

Anyways, another few notes

-You didnt null the timer in either func
-You cant FlushHandleLocals after you DestroyTimer ( as far as i know )
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
JASS:
function text takes nothing returns nothing
    local timer t = GetExpiredTimer()
    call DisplayTimedTextToPlayer(GetOwningPlayer(GetHandleUnit(t,"testing")),0,0,500,"omg u killed "+GetUnitName(GetHandleUnit(t,"tester")))
    call FlushHandleLocals(t)
    call DestroyTimer(t)
    set t = null
endfunction
 
function Trig_handletesting_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    call SetHandleHandle(t,"testing",GetKillingUnit())
    call SetHandleHandle(t,"tester",GetTriggerUnit())
    call TimerStart(t,10,false,function text)
    set t = null
endfunction

function InitTrig_handletesting takes nothing returns nothing
    set gg_trg_handletesting = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_handletesting, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_handletesting, function Trig_handletesting_Actions )
endfunction

Ok this should work with 0 leaks.
As you can see I restructured the locals for effiency and repaired the script so that is should work.

The main problem was you were not handling your timer correctly so look at the corrections and learn.

Also I removed some of the locals so that they are more efficent and as far as I know do not leak.
I have not actualy tested this script but hopefully it should work.
 
Status
Not open for further replies.
Top