HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What?! Triggers run 2 times at once?

12-22-2007, 02:47 PM#1
BestZero
I'm making the map that can rematch when end and starting a new game again but sometime triggers will run 2 times at once (like create 2 units at a time). I think it must be something wrong about trigger but I don't know so I tried to destroy trigger everytime when it finishes but seem that's not a point....

Expand JASS:

and When I want to rematch just type -rematch and the trigger will run
Collapse JASS:
call StartSelectingMode()

I have tired about this......... What I did wrong ? For someone who helps me I will give you a rep and adding you in my map credit too.
12-23-2007, 12:47 AM#2
moyack
well, dynamic triggers sometimes sucks, so we should try to avoid them as much as possible.

I don't know.... I would do this system in other way like... one permanent trigger that detects the input and a global boolean which is set to true if the -rematch command is started.

Something like this:

Collapse JASS:
function SelectMode takes nothing returns nothing
    if udg_ActivateRematch then
        // here you play with the entered string and do your stuff.
    endif
endfunction

function StopMode takes nothing return nothing
    set udg_ActivateRematch = false
    call DestroyTimer(GetExpiredTimer())
endfunction

function Trig_Rematch_Actions takes nothing returns nothing
    set udg_ActivateRematch = true
    call TimerStart(CreateTimer(), 15., false, function StopMode)
endfunction

//===========================================================================
function InitTrig_Rematch takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent(t,Player(0),"-am",true)
    call TriggerRegisterPlayerChatEvent(t,Player(0),"-nm",true)
    call TriggerAddAction(t, function SelectMode)
    set gg_trg_Rematch = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Rematch, Player(0), "-rematch", true )
    call TriggerAddAction( gg_trg_Rematch, function Trig_Rematch_Actions )
    set t = null
endfunction
12-23-2007, 06:12 AM#3
BestZero
Thanks moyack, last night I was thinking about making triggers to permanent too, seem it's the better way.

even though I really want to know issue why sometime it runs 2 times at once.

thanks for helping me +rep.


EDIT : OK I got it because I quickly rematch before the timer detroyed so sometime triggers will call function 2 or 3 times at once.