• 🏆 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 is not MUI

Status
Not open for further replies.
Level 8
Joined
Nov 2, 2007
Messages
160
Hey guys,
I have read a Hashtable tutorial and everything is quite clear to me.
Now I wanted to use them to attach an integer value to towers when they get an upgrade in order to be able to use the amount of gold paid for possible sell actions.

My problem is that this only works for the last tower that got the upgrade. If I upgrade 2 towers only the second one has the right value.

I only gonna post the important lines for this issue.

Trigger storing the value:

  • Hashtable - Create a hashtable
  • Set Myhashtable = (Last created hashtable)
  • Hashtabelle - Save Myvalue[(Player number of (Owner of (Triggering unit)))] as 1 of (Key (Triggering unit)) in Myhashtable
Trigger loading it:

  • Events
    • Unit - A unit starts to cast a spell
  • Conditions
    • (Ability being cast) is equal to Sell
  • Actions
    • Set Temp_Integer = (Integer(((((Max. Leben of (Target unit of ability being cast)) / 10.00) + (Real((Load 1 of (Key (Target unit of ability being cast)) from Myhashtable)))) x Sellvalue)))
 
Level 4
Joined
Apr 16, 2009
Messages
85
Well as it seems now you are creating a new hashtable every time you save a value. You should make a init trigger (that runs only once) that creates a hashtable and stores it into a global variable and use that over and over again.

(what you are currently doing is like this: you want to keep track of something and use a book for that but instead of using the same book over and over again you use a new one for every entry - so there can only be one entry in it)
 
Status
Not open for further replies.
Top