Loop through 3D Array
#1

Here is what im working with for testing purposes:
Код:
new Items[][3][] =
{   //ItemID/////Category///Name/////
	{0000,0,"Blank"},
	{1650,0,"Gas Can"},
	{3409,0,"Marijuana"},
	{2216,0,"Snack"},
	{2033,0,"Matches"}
};

stock GetInventoryItemNames(itemid)
{
    new itemname[256];
	for(new idx=1; idx< sizeof(Items); idx++)
	{
	    if(itemid==Items[idx][0])
	    {
	        format(itemname, 256, Items[idx][2]);
	        break;
	    }
	}
return itemname;
}

CMD:getitemname(playerid, params[])
{
	new id, string[256];
	if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "This command does not exist.");
	if(sscanf(params,"i", id)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /GetItemName id");
	format(string, sizeof(string), "%d: %s", id, GetInventoryItemNames(id));
	SendClientMessage(playerid, COLOR_BLUE, string);
return 1;
}
When i compile I get:
Код:
array must be indexed (variable "Items")
at
Код:
if(itemid==Items[idx][0])
Reply
#2

Its only a 2d array
pawn Код:
new Items[][] =
{   //ItemID/////Category///Name/////
    {0000,0,"Blank"},
    {1650,0,"Gas Can"},
    {3409,0,"Marijuana"},
    {2216,0,"Snack"},
    {2033,0,"Matches"}
};
Reply
#3

lol, i got it working now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)