• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] TriggerRegisterTimerEvent() not working

Status
Not open for further replies.
Level 2
Joined
Jul 1, 2012
Messages
25
I got a trigger that isn't firing )= and i just can't find out why. There are 3 triggers about a dialog with 2 choices. The last one won't fire when it's timed to (10 sec after map start) but it will fire if the second trigger executes it. Ill show the neccesary information below.

JASS:
globals
integer Number_Of_Players = 8
dialog Hero_Mode = DialogCreate()
button AR = DialogAddButton(Hero_Mode, "|cffffcc00A|rll Random", 65)
button SD = DialogAddButton(Hero_Mode, "|cffffcc00S|r|cffffffffingle Draft|r", 83)
integer Hero_Mode_Clicks = 0
integer Hero_Mode_Choice = 0
endglobals

Thoose are the globals used.

JASS:
function Trig_Hero_Mode_Dialog_Actions takes nothing returns nothing
local integer i = 0
    call DialogSetMessage(Hero_Mode, "|cffff2222Select Hero Mode|r")
    loop
        call DialogDisplay(Player(i), Hero_Mode, true)
        exitwhen i == 7
        set i = i + 1
    endloop
    call BJDebugMsg("debug")
call DestroyTrigger(GetTriggeringTrigger())
endfunction

//===========================================================================
function InitTrig_Hero_Mode_Dialog takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterTimerEvent(t, 0.0, false)
    call TriggerAddAction(t, function Trig_Hero_Mode_Dialog_Actions )
    set t = null
endfunction

That's the first trigger which creates and shows the dialog.

JASS:
function Trig_Hero_Mode_Dialog_Response_Actions takes nothing returns nothing
    set Hero_Mode_Clicks = Hero_Mode_Clicks + 1
    call DialogDisplay(GetTriggerPlayer(), Hero_Mode, false)
    if GetClickedButton() == AR then
        set Hero_Mode_Choice = Hero_Mode_Choice + 1
    else 
        set Hero_Mode_Choice = Hero_Mode_Choice - 1
    endif
    if Hero_Mode_Clicks == Number_Of_Players then
        call DestroyTrigger(GetTriggeringTrigger())
        call TriggerExecute(gg_trg_Hero_Mode_Dialog_Destroy)
    endif
endfunction

//===========================================================================
function InitTrig_Hero_Mode_Dialog_Response takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterDialogEvent(t, Hero_Mode)
    call TriggerAddAction( t, function Trig_Hero_Mode_Dialog_Response_Actions )
endfunction

Thats the second trigger which will execute the 3rd trigger if all players have voted.

JASS:
function Trig_Hero_Mode_Dialog_Destroy_Actions takes nothing returns nothing
local integer i = 0
   call BJDebugMsg("WTF")
    if Hero_Mode_Choice == 0 then
        set Hero_Mode_Choice = GetRandomInt(-1, 0)
    endif
    if Hero_Mode_Choice >= 0 then
        loop
            call DialogDisplay(Player(i), Hero_Mode, false)
            call DisplayTimedTextToPlayer(Player(i), 0, 0, 15, "|cff055bccAll Random chosen|r")
            exitwhen i == 7
            set i = i + 1
        endloop
    else
        loop
            call DialogDisplay(Player(i), Hero_Mode, false)
            call DisplayTimedTextToPlayer(Player(i), 0, 0, 15, "|cff22cc22Single Draft Chosen|r")
            exitwhen i == 7
            set i = i + 1
        endloop
    endif
    call DialogDestroy(Hero_Mode)
    call DestroyTrigger(GetTriggeringTrigger())
    call BJDebugMsg("WTFggggggggg")
endfunction

//===========================================================================
function InitTrig_Hero_Mode_Dialog_Destroy takes nothing returns nothing
    set gg_trg_Hero_Mode_Dialog_Destroy = CreateTrigger()
    call TriggerRegisterTimerEvent(gg_trg_Hero_Mode_Dialog_Destroy, 10.0, false)
    call TriggerAddAction( gg_trg_Hero_Mode_Dialog_Destroy, function Trig_Hero_Mode_Dialog_Destroy_Actions )
endfunction

And thats the 3rd trigger which will not fire on it's own event but only when executed by the second trigger. I have no idea what to do :/.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
A dialog pauses the game when testing in single player. Thus why the event doesn't fire.
In multiplayer however, this trigger should work.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
I knew that, but forgot this behavior.
So finally maybe we have a way to know if a game is "online" or not which is not screwed in replay ?

Lol I didn't even think of that 0.o
This might really be a good way of checking for online gameplay :p

Also: does it pause the game when a dialog is displayed to a different player in single player?
If so we could simply show a dialog to something like Player(13) to check if it's single player or not.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Well this seems to work so far (can even be done in simple GUI):

  • Start Game
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start CheckOnline as a One-shot timer that will expire in 0.13 seconds
      • Dialog - Change the title of checkOnline to You can only play t...
      • Dialog - Show checkOnline for Player 1 (Red)
      • Dialog - Show checkOnline for Player 2 (Blue)
      • Dialog - Show checkOnline for Player 3 (Teal)
      • Dialog - Show checkOnline for Player 4 (Purple)
      • Dialog - Show checkOnline for Player 5 (Yellow)
      • Dialog - Show checkOnline for Player 6 (Orange)
      • Dialog - Show checkOnline for Player 7 (Green)
      • Dialog - Show checkOnline for Player 8 (Pink)
      • Dialog - Show checkOnline for Player 9 (Gray)
      • Dialog - Show checkOnline for Player 10 (Light Blue)
      • Dialog - Show checkOnline for Player 11 (Dark Green)
      • Dialog - Show checkOnline for Player 12 (Brown)
  • Check for multiplayer
    • Events
      • Time - CheckOnline expires
    • Conditions
    • Actions
      • Dialog - Hide checkOnline for Player 1 (Red)
      • Dialog - Hide checkOnline for Player 2 (Blue)
      • Dialog - Hide checkOnline for Player 3 (Teal)
      • Dialog - Hide checkOnline for Player 4 (Purple)
      • Dialog - Hide checkOnline for Player 5 (Yellow)
      • Dialog - Hide checkOnline for Player 6 (Orange)
      • Dialog - Hide checkOnline for Player 7 (Green)
      • Dialog - Hide checkOnline for Player 8 (Pink)
      • Dialog - Hide checkOnline for Player 9 (Gray)
      • Dialog - Hide checkOnline for Player 10 (Light Blue)
      • Dialog - Hide checkOnline for Player 11 (Dark Green)
      • Dialog - Hide checkOnline for Player 12 (Brown)
This will block players from being abled to play single player.
(doesn't seem to work if you set the timer to something like 0.1 for some reason, gonna test for the right margins right now)
I haven't really found a way of keeping gameplay intact sadly enough.

EDIT: the smallest margin to make this work is 0.13 seconds for the timer... (in GUI that is)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Also for keeping able the player to play on single player mode, just use a TSA, it should not be halt during pause.

I'm sorry for being really ignorant, but what is a TSA?

EDIT: TriggerSleepAction() n.v.m.

Adding a dialog button can also work.

something like:

You do realise you are playing single player right?

Ok


Should I really put this in as a resource, it seems really simple to do :/
 
Last edited:
Level 23
Joined
Apr 16, 2012
Messages
4,041
well, according to nestharus, ReloadGameCachesFromDisk takes nothing returns boolean returns true only in single player so this is maybe the fastest way how to get if map is single player

Also I like how the person asked why it doesnt work and you two(partly me too from now on :D) are talking about detecting online/offline playing
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Well, the point is to provide a way to know by trigger if the game is played in solo or multiplayer mode (cheats are enable or not).

Regardless how simple or hard it is to make, it is not obvious, so yes if it works it's worth a submission.
However it needs improvement in the current state, and also you need to check if the result is screwed in a replay or not, because actually we have an instant and simplier way, just by using ReloadGameCachesFromDisk, but the result is screwed up with replays.

Also it should be a vJass submission.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I don't remember exactly but it's a false positive detection on a multiplayer replay, something like that.

I mean the result is incorrect in some situation.

Not to mention that i'm asking myself what is the real effect of this native function.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Well, the point is to provide a way to know by trigger if the game is played in solo or multiplayer mode (cheats are enable or not).

Regardless how simple or hard it is to make, it is not obvious, so yes if it works it's worth a submission.
However it needs improvement in the current state, and also you need to check if the result is screwed in a replay or not, because actually we have an instant and simplier way, just by using ReloadGameCachesFromDisk, but the result is screwed up with replays.

Also it should be a vJass submission.

The thing is, I really want to do this submission but I simply don't have the time right now to do so :/

I have lots on my mind to worry about and I can't put any more on my plate right now.

So if anyone wants to eat of my plate, I would be honoured.
 
Last edited:
Status
Not open for further replies.
Top