• 🏆 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!

Countdown timers??

Status
Not open for further replies.
Level 4
Joined
Jul 25, 2007
Messages
71
Hey everyone. I've got a map that displays a 20 second countdown timer. Later on, another countdown timer is needed. It uses a different variable for both the timer & timer window. But for some reason, no matter what I do, multiple timers display for a single player. Based on how many players are in the game. Six players = six of the same timer.

My code is flawless. I've spent days on this issue. The first timer is programmed the exact same way, and it works perfect. Can only one timer be used per game or something?
 
Level 3
Joined
Jun 9, 2010
Messages
59
Can only one timer be used per game or something?


I highly doubt this, would you mind posting your code (GUI or Jass w/e you made it as) so I or others can check it to see if there are any issues that would probly help in the aiding process alot so we can actually look for a mistake.
 
Level 11
Joined
Feb 11, 2010
Messages
199
Hey everyone. I've got a map that displays a 20 second countdown timer. Later on, another countdown timer is needed. It uses a different variable for both the timer & timer window. But for some reason, no matter what I do, multiple timers display for a single player. Based on how many players are in the game. Six players = six of the same timer.

My code is flawless. I've spent days on this issue.

I'm sorry, but if you are getting the result you describe here, your code is not flawless. Please show us your code (or a map attachment) so that we can correct your errors.

Can only one timer be used per game or something?
No. You can use as many timers as you want.
 
Here's how it should be:
  • Timer One
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start Timer1 as a One-shot timer that will expire in 20.00 seconds
      • Countdown Timer - Create a timer window for Timer1 with title Timer1!
      • Set TimerWindow[1] = (Last created timer window)
  • Timer Two
    • Events
      • Time - Timer1 expires
      • Time - Timer2 expires
    • Conditions
    • Actions
      • Custom script: local timer t = GetExpiredTimer()
      • Custom script: if t == udg_Timer1 then
      • Countdown Timer - Destroy TimerWindow[1]
      • Countdown Timer - Start Timer2 as a One-shot timer that will expire in 20.00 seconds
      • Countdown Timer - Create a timer window for Timer2 with title Timer2!
      • Set TimerWindow[2] = (Last created timer window)
      • Custom script: else
      • -------- Make the actions here for the second timer. --------
      • Countdown Timer - Destroy TimerWindow[2]
      • Custom script: endif
      • Custom script: set t = null
 
Level 4
Joined
Jul 25, 2007
Messages
71
Yes I suppose it was a tad bit foolish to exclaim my code was flawless. I was just convinced I could only use one timer per game.

I have uploaded my map for anyone willing to check it out. Timer 1 is displayed in the trigger "newOrLoad" at the very top. Timer 2 is displayed in the trigger "waitForRescueTime", and it is ran by an action at the very bottom of "newOrLoad". Timer 1 works perfectly. Timer 2 is programmed the same exact way, but doesn't work. Thank you gentlemen.
 

Attachments

  • Archonon Bay - RoM a new start. II.w3x
    322.9 KB · Views: 53
Level 28
Joined
Jan 26, 2007
Messages
4,789
1) Remove the actions "Do nothing", here is Septimus' awesome example of why you should remove it:
  1. Assume that you are not doing anything at this moment.
  2. I call you to come cause I have thing for you to do.
  3. I call you cause I want to tell you to do absolutely nothing at this moment.
That's exactly what the function does (or in more technical terms: drains your CPU usage by doing nothing at all).

There are about a dozen of these as well:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • EMPATHYISLAND_showRescueTimer[1] Equal to 0
    • Then - Actions
      • Do nothing
    • Else - Actions
      • Do nothing
Delete them, delete them all.
If you don't tell the game to do anything, it will also do nothing.
You're telling the game to do nothing, same result, longer way, worse method.

3) You can remove about 5/6th of all actions by combining them into a loop instead of using seperate If / Then / Elses for each player.

4)
  • And - All (Conditions) are true
    • Conditions
      • playerInt[1] Equal to 0
      • playerInt[2] Equal to 0
      • playerInt[3] Equal to 0
      • playerInt[4] Equal to 0
      • playerInt[5] Equal to 0
      • playerInt[6] Equal to 0
Remove the "And - all (Conditions) are true".
It always checks all conditions, unless you put "Or - ....").
(This function is made to use inside an "Or - condition are true").

5) Memory leaks are all over the place, you should learn how to remove them.
Every time you use a location, unit group, special effect or player group (apart from "All Players"), you create a leak.
Leaks cause lag -> they're bad.
They can be removed with the help of a little custom script, try checking the tutorial section for that.


Back to the real problem:

Every time someone types "#new", the trigger will run.
Since the "activate timer"-thing is outside the If/Then/Else, it will run every time someone types that command, meaning that if 2 people type "#new", there will be 2 timers.

The first timer works because it's put in the first If/Then/Else, it will only return true the first time someone types "#new", afterwards the timer never starts again.



Conclusion: your code is far from flawless, I suggest you take the tips I've mentioned here.
Without leak removal, loops or understanding of some functions (such as Do Nothing / And - all conditions are true), you won't get that far.

I hope you understood all of this =D
I wish you the best of luck and I hope it worked.

Edit: I was a hell lot slower (post before me wasn't there when I opened this thread), but still provided some extra information, so it could be useful I guess xD
 
Status
Not open for further replies.
Top