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

[Trigger] Hashtable load not working on Timer Expiration

Status
Not open for further replies.
Level 2
Joined
May 17, 2018
Messages
16
Hello there,
first off i tried dumbing down the triggers to just the parts that i think that are related to the problem if you think it must be something else please let me know. What i am basically trying to do is use a loop to create a Timer for every player that is playing. In the loop body after the timer creation i will try to save a Value in a Hashtable(This is actually the important part since i just want to have a any way to save a value and to be able to load that specific value on timer expiration). Then i have a second Trigger that fires on Expiration of any of the previous created timers. Then the Value related to the expired timer, which was stored in the Hastable is supposed to be loaded.

When this happens not all Values are properly loaded. Apparently something is going wrong with either timers or the hashtable

Why do i need that many timers that start at the same time? Because eventually in the full version of the triggers that i am using players will trigger the 2nd, 3rd and n-th time those timers are being fired so they will at some point not be in sync anymore. Thanks for any help!

Trigger1:
upload_2018-5-21_0-6-52.png


Trigger2:
upload_2018-5-20_23-21-27.png


Random Number generation (I think this part is not the problem tho)

upload_2018-5-20_23-28-52.png
 
Last edited:
Here's a guide on posting triggers:
How To Post Your Trigger

These portions of your trigger might be the cause of your crashes:
  • Player(RandomPlayerNumber[(Integer A)])
  • Player(RandomPlayerNumber[(IntegerA)] - 1)
If you try to access Player() with an invalid index (e.g. anything less than 1, or anything greater than 24), the game will crash. Here are a few suggestions:
  • Make sure RandomPlayerNumber[] is set up for all player indices. Why is this a problem? Let's say you forgot to set RandomPlayerNumber[16]. If the loop tried to access RandomPlayerNumber[16] (i.e. Integer A is equal to 16), then it would resolve to 0 (the default value for when an array is not set). So Player(RandomPlayerNumber[16]) would resolve to Player(0), which will crash since that is an invalid index.
  • What are you trying to do with this line: "Player(RandomPlayerNumber[(Integer A)] - 1)"? I don't recommend doing that, because if RandomPlayerNumber[(Integer A)] is 1, then it will resolve to Player(0) (since you subtract 1), which will crash.
  • Make sure NumberOfPlayersPlaying is always less than or equal to 24. If it goes higher, e.g. 25, then RandomPlayerNumber[25] will likely not be set so it'll cause the problem I mentioned in the first bullet.

Good luck! If you are still getting issues, try posting your entire trigger.
 
Level 2
Joined
May 17, 2018
Messages
16
Thanks for your answer i will double check this but, i think i never resolve to a Player(x) anyways the numbers are actually just used to as indexes for arrays of a certain variable type. Does it crash for other cases where i have an "index out bounds" except with resolving players?
 
Last edited:
Even though you're using it as an index, you are still using "Player()" in your actual GUI code. So if you pass it an index out of bounds, it'll crash.

If you just want to fix the crash, then you could just change that one line to:
  • Hashtable - Save RandomPlayerNumber[(Integer A)] as (Key (Last started timer)) of (Key (Last started timer)) in Timers_Hashtable
Since doing "Player number of (Player(<number>))" is the same as just "<number>" by itself.
 
Level 2
Joined
May 17, 2018
Messages
16
I just updated the pics of the graphs so you have some more information. I also just applied your advice(thats not yet updated in the new attachements yet). I also made some other changes in the rest of the code to assure no more out of bounds stuff is happening.(basically disabling a lot of trigger and stuff for isolated testing just to be sure)

However, now i have the other issue is was talking about where it just does not load the right value and i do not know where it is going wrong. I could just upload the map if it helps making it easier analyze the problem but not sure if it is.

PS: Don't give up on me, You're really making my day by helping me out!
 
Last edited:
Level 2
Joined
May 17, 2018
Messages
16
I might have found the problem trying to confirm atm. It might be related to some swapping of the indexes.
Basically timer[1] one would "save" the Value=2 and timer[2] the Value=1 , so when timer[1] expires its loads the value =2 and then tries to create the timer["Value Saved in Timer[1] >>2],however since there is already a timer[2] in progress (even tho its just to expire), this is not possible and everything gets fucked up. Anyways hard to put into words... Edited: Maybe but still cant get it to work
 
Last edited:
Status
Not open for further replies.
Top