15.06.2016, 19:35
Since content data are mixed up you need to count every time an item from that shop appears and if it equals the listitem, then give the weapon etc.
Unfortunately, you'll have to loop again and check which shop it is. A per-player variable would be useful I guess if there are many shops.
EDIT: Added money check, forgot it.
PHP Code:
if (!response) return true;
new count_listitem = -1, z;
for (new i = 0; i < MAX_SHOPS; i++)
{
if (IsPlayerInRangeOfPoint(playerid, 5.0, ShopInfo[i][ShopX], ShopInfo[i][ShopY], ShopInfo[i][ShopZ]))
{
for (new x = 0; x < MAX_CONTENT_DATA; x++)
{
z = ShopInfo[i][ShopID];
if (ShopData[z][x][ContentID] == ShopInfo[i][ShopID])
{
if (++count_listitem == listitem)
{
if (GetPlayerMoney(playerid) < ShopData[z][listitem][ContentPrice]) return SCM(playerid, COLOR_RED, "You dont have enough money. You need %i to buy this", ShopData[i][listitem][ContentPrice]);
GivePlayerWeapon(playerid, ShopData[z][listitem][ContentWeapon], ShopData[z][listitem][ContentAmmo]);
SCM(playerid, COLOR_RED, "You have purchased weapon ID: %i for %i$", ShopData[z][listitem][ContentWeapon], ShopData[z][listitem][ContentPrice]);
GivePlayerMoney(playerid, ShopData[z][listitem][ContentPrice]);
break;
}
}
}
}
}
EDIT: Added money check, forgot it.

