• 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] Hashtable save and load problem

Status
Not open for further replies.
Level 3
Joined
Aug 31, 2009
Messages
31
I'm trying to create shop based bag system using hashtable.
Every time unit gets an item (exept when you get item from the shop) triger must save charges and add the item to shop unit in count of charges.
When you buy item from shop-bag triger must reduce saved count of charges until it become 0. After that item is removed from the sale.

So I create this - View attachment hashproblem.w3x (by the way, you can not buy from the store if you have no money. Use greedisgood)

For some reason it goes insane when I pick more then 4 items of the random type and trying to buyout them. (May be because of Key(string)/10000)
And give me some wierd count of item sold but variable responsible for this remains normal. (It can be because buying triger starts before item is sold and that explain why count of items in the shop can differ from the variable by 1 but sometimes it give me very strange numbers.)

Please tell me where is the problem because I cant see it...
 
You don't need to turn off the melee initialization trigger.

You don't have to create a hashtable for every player, just save the values you want to (Player number of (Triggering player)) when the unit acquires an item, not on the name of the item.

You leak unit groups. They are not needed anyway, enumerating them every time you pick an item. Just set a Unit variable with array and create the bag for each player that is currently playing, setting Bag[(IntegerA)] = (Last created unit).

I can't tell why do you divide the Key of item's name / 10000. It should be
  • Set BagCountTMP = (Load (Integer(count)) of (Player number of (Triggering player)) from BagHash
 
Level 3
Joined
Aug 31, 2009
Messages
31
You don't have to create a hashtable for every player, just save the values you want to (Player number of (Triggering player)) when the unit acquires an item, not on the name of the item.
]
I need to know 3 things:
-Player (because each player got its own bag)
-Item Name (because a lot of items can be placed in bag)
-Count of items (so that different players can hold different amount of charges in item of different type)

So I get an item (1xCoal) and you propose me to save it count to the Player number of (Triggering player)? Ok I get another item (3xDirt) and save 3 as count of Player number of (Triggering player) + previous. And what I get is that Player 1 (for examle) got value 4 savet in hashtable? Very usefull.
 
Status
Not open for further replies.
Top