• 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.

[Trigger] Timer window doesn't show timer's time

Status
Not open for further replies.
So, i have that :

  • Timer - Start (Load 10 of (Key (Triggering unit)) in Hash) as a Un coup timer that will expire in (Respawn_Time + ((Real((Hero level of (Triggering unit)))) x Respawn_Increment)) seconds
  • Timer - Create a timer window for (Last started timer) with title Respawn time :
  • Timer - Show (Last created timer window) for (Triggering player)
The timer is created, the window too. But the problem is that the window doesn't show timer's remaining time.
 
(Last started timer) will return null,
JASS:
function GetLastCreatedTimerBJ takes nothing returns timer
    return bj_lastStartedTimer
endfunction
because when you saved timer you didn't set global variable.

Before this your code add this line:
set bj_lastStartedTimer = LoadTimerHandle(udg_Hash, GetHandleId(GetTriggerUnit()), 10)
And it should work, you can then use Last started timer to start timer as well in your first line.
 
I don't think it's the problem, cause when i tried the trigger with that :

  • Timer - Create a timer window for (Load 10 of (Key (Triggering unit)) in Hash) with title Respawn time :
also, your jass line gave me a compilation error.

Sry I write hash instead of udg_Hash, try it now: set bj_lastStartedTimer = LoadTimerHandle(udg_Hash, GetHandleId(GetTriggerUnit()), 10)

Make sure you are not creating a Timer Window at map initialization.
In that case window won't be created at first place.

Hmmm can you show whole trigger?

1 more things, timer must be created at some point, maybe you forget to create it, and Load function returned null.
 
You're solution don't work.

Star, if you look actions, you can see that it's not started at map init since i use triggering unit.

So, here is whole trigger :

  • Death
    • Evénements
      • Unité - A unit Meurt
    • Conditions
      • ((Dying unit) is Un héros) Egal à TRUE
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • ((Killing unit) belongs to an enemy of (Triggering player)) Egal à TRUE
        • Alors - Actions
          • Set TempInt = (Random integer number between 1 and 4)
          • Partie - Display to (All players) the text: ((Name of (Owner of (Killing unit))) + (KillsStrings[TempInt] + ((Name of (Triggering player)) + (KillsStrings2[TempInt] + ((String((KillGold_Basic + ((Hero level of (Triggering unit)) x KillGold_Increment)))) + !)))))
          • Joueur - Add (180 + ((Hero level of (Triggering unit)) x KillGold_Increment)) to (Owner of (Killing unit)) Or actuel
          • Joueur - Add -50 to (Triggering player) Or actuel
        • Sinon - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • (Triggering player) Egal à (Owner of (Killing unit))
            • Alors - Actions
              • Set TempInt = (Random integer number between 1 and 3)
              • Partie - Display to (All players) the text: ((Name of (Triggering player)) + SuicideStrings[TempInt])
            • Sinon - Actions
              • Set TempInt = (Random integer number between 1 and 1)
              • Partie - Display to (All players) the text: ((Name of (Owner of (Killing unit))) + (DenyStrings[TempInt] + ((Name of (Triggering player)) + !)))
      • Groupe unité - Add (Triggering unit) to Rez_Group
      • Compte à rebours - Start (Load 10 of (Key (Triggering unit)) in Hash) as a Un coup timer that will expire in (Respawn_Time + ((Real((Hero level of (Triggering unit)))) x Respawn_Increment)) seconds
      • Custom script: set bj_lastStartedTimer = LoadTimerHandle(udg_Hash, GetHandleId(GetTriggerUnit()), 10)
      • Compte à rebours - Create a timer window for (Last started timer) with title Respawn time :
      • Compte à rebours - Montrer (Last created timer window) for (Triggering player)
      • Table de hachage - Save Handle Of(Last created timer window) as 11 of (Key (Triggering unit)) in Hash
      • Table de hachage - Save (Respawn_Time + ((Real((Hero level of (Triggering unit)))) x Respawn_Increment)) as 12 of (Key (Triggering unit)) in Hash
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • (Respawn <gen> is on) Egal à FALSE
        • Alors - Actions
          • Déclencheur - Turn on Respawn <gen>
        • Sinon - Actions
 
  • Compte à rebours - Start (Load 10 of (Key (Triggering unit)) in Hash) as a Un coup timer that will expire in (Respawn_Time + ((Real((Hero level of (Triggering unit)))) x Respawn_Increment)) seconds
  • Custom script: set bj_lastStartedTimer = LoadTimerHandle(udg_Hash, GetHandleId(GetTriggerUnit()), 10)
  • Compte à rebours - Create a timer window for (Last started timer) with title Respawn time :
  • Compte à rebours - Montrer (Last created timer window) for (Triggering player)
  • Table de hachage - Save Handle Of(Last created timer window) as 11 of (Key (Triggering unit)) in Hash
Here are all actions related to the timer.

I didn't saved the timer, i've just created and started it.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Well, i'm not sure i can read correctly GUI actually, but it seems you attemp to use a timer stored in an hashtable.
Code:
Compte à rebours - Start (Load 10 of (Key (Triggering unit)) in Hash)
So if a created timer is not stored there in the first place, it should use a null timer, so it would explain why it doesn't work.
 
Here you go small library that will do job with timers dialogs for you :)
You can still do regular things with timers all you need to do is to use custom script and player id (jass player 0 (red) == gui player 1 (red)).
Also you can create GUI timer variable and just use something like this in custom script:
set udg_YOUR_TIMER_VARIABLE = RT[0] <<<< Timer created for red player.
and then use udg_YOUR_TIMER_VARIABLE in gui triggers easily :)

JASS:
library RespawnTimer
    globals
                timer array       RT
                timerdialog array RTD
        
        private boolean array     B
        private hashtable         HASH = InitHashtable()
    endglobals
    
    private function FlushExpiredTimer takes nothing returns nothing
        local integer id = GetHandleId(GetExpiredTimer())
        call DestroyTimer(      LoadTimerHandle(      HASH, id, 0))
        call DestroyTimerDialog(LoadTimerDialogHandle(HASH, id, 1))
        set B[LoadInteger(                            HASH, id, 2)] = false
        call TriggerExecute(LoadTriggerHandle(        HASH, id, 3))
        /**/call BJDebugMsg("Debug: Timer Dialog Destroyed for player: " + GetPlayerName(Player(LoadInteger(HASH, id, 2))))
        call FlushChildHashtable(HASH, id)
    endfunction
    
    function CreateRespawnTimer takes player owner, string title, real timeout, boolean show, trigger trig returns nothing
        local integer id = GetPlayerId(owner)
        if not B[id] then
            set B[id] = true
            set RT[id]  = CreateTimer()
            set RTD[id] = CreateTimerDialog(RT[id])
            call SaveTimerHandle(        HASH, GetHandleId(RT[id]), 0, RT[id] )
            call SaveTimerDialogHandle(  HASH, GetHandleId(RT[id]), 1, RTD[id])
            call SaveInteger(            HASH, GetHandleId(RT[id]), 2, id     )
            call SaveTriggerHandle(      HASH, GetHandleId(RT[id]), 3, trig   )
            call TimerStart(RT[id], timeout, false, function FlushExpiredTimer)
            call TimerDialogSetTitle(RTD[id], title)
            if show then
                call TimerDialogDisplay(RTD[id], true)
            endif
            /**/call BJDebugMsg("Debug: Timer Dialog is created for: " + GetPlayerName(owner))
        else
            /**/call BJDebugMsg("Debug: Timer Dialog is already created for: " + GetPlayerName(owner))
        endif
    endfunction
endlibrary
+
  • Test
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: call CreateRespawnTimer(Player(0), "Example" , 5.00 , true, gg_trg_Test_2 )
      • Custom script: call CreateRespawnTimer(Player(1), "Example" , 7.00 , true, gg_trg_Test_3 )
+
  • Test 2
    • Events
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
+
  • Test 3
    • Events
    • Conditions
    • Actions
      • Unit - Create 1 Priest for Player 2 (Blue) at (Center of (Playable map area)) facing Default building facing degrees
 

Attachments

  • ax.w3x
    17 KB · Views: 44
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
We are not in your mind, if you don't post your attempts, we can't guess what's wrong.
So far, it seems that you are not using any timer, that's not because you use an hashtable that magically it creates a timer for you.
Create a timer, and then store it in the hashtable if you want.

You can link a timer and a timer window, but it's not because you create a timer window that creates automatically a timer as well, you have to do it yourself.
 
  • Death
    • Evénements
      • Unité - A unit Meurt
    • Conditions
      • ((Dying unit) is Un héros) Egal à TRUE
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • ((Killing unit) belongs to an enemy of (Triggering player)) Egal à TRUE
        • Alors - Actions
          • Set TempInt = (Random integer number between 1 and 4)
          • Partie - Display to (All players) the text: ((Name of (Owner of (Killing unit))) + (KillsStrings[TempInt] + ((Name of (Triggering player)) + (KillsStrings2[TempInt] + ((String((KillGold_Basic + ((Hero level of (Triggering unit)) x KillGold_Increment)))) + !)))))
          • Joueur - Add (180 + ((Hero level of (Triggering unit)) x KillGold_Increment)) to (Owner of (Killing unit)) Or actuel
          • Joueur - Add -50 to (Triggering player) Or actuel
        • Sinon - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • (Triggering player) Egal à (Owner of (Killing unit))
            • Alors - Actions
              • Set TempInt = (Random integer number between 1 and 3)
              • Partie - Display to (All players) the text: ((Name of (Triggering player)) + SuicideStrings[TempInt])
            • Sinon - Actions
              • Set TempInt = (Random integer number between 1 and 1)
              • Partie - Display to (All players) the text: ((Name of (Owner of (Killing unit))) + (DenyStrings[TempInt] + ((Name of (Triggering player)) + !)))
      • Groupe unité - Add (Triggering unit) to Rez_Group
      • Compte à rebours - Start (Load 10 of (Key (Triggering unit)) in Hash) as a Un coup timer that will expire in (Respawn_Time + ((Real((Hero level of (Triggering unit)))) x Respawn_Increment)) seconds
      • Custom script: set bj_lastStartedTimer = LoadTimerHandle(udg_Hash, GetHandleId(GetTriggerUnit()), 10)
      • Compte à rebours - Create a timer window for (Last started timer) with title Respawn time :
      • Compte à rebours - Montrer (Last created timer window) for (Triggering player)
      • Table de hachage - Save Handle Of(Last created timer window) as 11 of (Key (Triggering unit)) in Hash
      • Table de hachage - Save (Respawn_Time + ((Real((Hero level of (Triggering unit)))) x Respawn_Increment)) as 12 of (Key (Triggering unit)) in Hash
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • (Respawn <gen> is on) Egal à FALSE
        • Alors - Actions
          • Déclencheur - Turn on Respawn <gen>
        • Sinon - Actions
Here it is.
 
Status
Not open for further replies.
Top