Code:
// ...
new Names[6][] ={
"",
"Silent Footsteps",
"150 health",
"Sunglasses (No flash)",
"Steahlt-Suit",
"150 Armor"
}
// ...
public HnsBuyMenu(id)
{
// ...
for ( i = 1; i < 9; i++)
{
format(nr, 2,"%i", i)
format(Form, 49, "%s: ($%i)", Names[i], get_pcvar_num(pcvars[i]))
menu_additem(menu, Form, nr, 0);
}
// ...
}
Notice how the loop goes through 9, when you only have 6.
You could do:
Code:
public HnsBuyMenu(id)
{
// ...
for ( i = 1; i < sizeof(Names); i++)
{
format(nr, 2,"%i", i)
format(Form, 49, "%s: ($%i)", Names[i], get_pcvar_num(pcvars[i]))
menu_additem(menu, Form, nr, 0);
}
// ...
}
That way, you won't have to worry about changing the number every time you add an item, and the loop will still be fixed.
But, please notice that you are also looping through the pcvars array, so make sure you check the size of that one if the Names and the pcvars have different sizes.
Code:
public HnsBuyMenu(id)
{
// ...
// get the smallest size so we dont do out of bounds
new total = min(sizeof(Names), sizeof(pcvars));
for ( i = 1; i < total; i++)
{
format(nr, 2,"%i", i)
format(Form, 49, "%s: ($%i)", Names[i], get_pcvar_num(pcvars[i]))
menu_additem(menu, Form, nr, 0);
}
// ...
}
__________________