# Index of a sold unit from shop

Status
Not open for further replies.

#### pred1980

Level 13
Hi hivers,

i have a shop where you can buy units and i want to know the index of the slot in the shop.

Ex:

A Shop with 10 Units. You buy the 3 one. So the index would be 2. Is there a function or workaround to get the index of a sold unit???

Reg.

#### PurgeandFire

Level 44
There is no native for it. You'll have to use something like a hashtable and map the units to their appropriate indices. And if you ever add something to its stock, you have to do that as well.

... basically you have to keep track of it yourself.

#### venger07

Level 13
"A Shop with 10 Units. You buy the 3 one. So the index would be 2"

sorry :v I don't quite understand your example.. can you please explain it a bit more?

#### pred1980

Level 13
Do you know "arrays" ? An array starts with the index 0....
So if you pick something like a unit on the first position...it's position ONE for you but in the background the data is saved mb in an array and the first position is there the 0.

#### venger07

Level 13
I know arrays.. what I mean is that I don't understand the problem you want to solve..

#### pred1980

Level 13
I want to know the current index when you buy a unit from a shop.

#### Squiggy

Level 28
Make an array for the units being sold
Unit1 = array[0]
Unit2 = array[1]
according to the pattern you want and when a unit is sold from there, refer to the values in the array - maybe?

Unit is being sold,
for each integer from 0 to 6 do: stuff

something like that?

#### pred1980

Level 13
yes, i did a workaround like that. at the beginning i add all units to the shop and save the index... thats the way it is

#### Dr Super Good

Spell Reviewer
Level 63
Sadly WC3 does not allow you to look up command card positions of various orders. This is possible in SC2 thanks to catalog natives.

The only implementation possible in WC3 is if you map the command card positions of each unit for each shop into some kind of data system. For example a hashtable where the parent index is the shop and the child index is the unit type and store the command card position in form of an integer range 0 to 11.

Status
Not open for further replies.

Replies
2
Views
439
Replies
3
Views
488
Replies
3
Views
1K
Replies
3
Views
510
Replies
2
Views
609