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

How can I deal with timer array ?

Status
Not open for further replies.
Go to variable editor, when you create a timer array, make sure its SIZE OPTION is bigger than 0. Actually, make sure its size equals to the number of timers you think you're gonna use.

This happens because GUI creates timers by default when you create the variable, but if you create a timer array, it will only create a number of them (instead of creating 8192 timers at map initialization).
 
If you need to use more than 256 timers at any point, you have bigger problems than lag at map init. If you have 8192 timers running at any reasonably small interval the game's probably gonna lag really bad.

Rethink your design, there's literally no map that benefits from more than 256 timers, and you can usually get away with using about 5-6 for the whole map.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
So I hear on a post that when dealing with timer arrays you first have to create the timer, then you can start it. My question is how can I create the timer array so I can start it later ?
Thanks
You call CreateTimer() to create a new timer object and store it to the index of your choosing. Remember to destroy the timer with DestroyTimer(udg_yourtimerhere[udg_yourindex]) before replacing it with a new timer. Periodic timers have to be stopped before destruction, and become single shot timers after a save/load cycle or being paused.
 
Level 11
Joined
Oct 9, 2015
Messages
721
Thanks guys for the detailed information! Apparently this did the trick as I have put a message in the second trigger and it is being displayed correctly when the timer expires, my array default size is 1 and the number I'm using is 77. However I wanted to ask if you can confirm this information.

  • Events
  • Conditions
  • Actions
    • Custom script: set udg_MyTimer[udg_TempInteger[1]]=CreateTimer()
    • Trigger - Add to Timer Expires <gen> the event (Time - MyTimer[TempInteger[1]] expires)
  • Countdown Timer - Start MyTimer[TempInteger[1]] as a One-shot timer that will expire in 1.00 seconds
  • Timer Expires
    • Events
    • Conditions
    • Actions - MY ACTIONS
 
Level 11
Joined
Oct 9, 2015
Messages
721
I'm usging this timers every time the unit casts a specific ability (which will be constant), each unit have a timer with an array equal to it's custom value (using unit indexer), currently I never destroy them, just start them again, maybe that's recycling already?
I'm also having trouble recieving information from (Expiring Timer) in hashtable, if you mind helping me with that too I would be very thankful!
  • Hashtable - Save TempInteger[1] as 0 of (Key (Last started timer)) in Timer_Hash
  • Set TempInteger[1] = (Load 0 of (Key (Expiring timer)) from Timer_Hash)
The second function is returning 0 when it should return 77 (the value of TempInteger[1])
 
Status
Not open for further replies.
Top