Question about multi-dimensional arrays
#1

I've got a basic player item system, and the items are stored like this:

Items[playerid][itemid][various item details spread along these indexes]

but what I want is something like:

Items[playerid][itemid][type]
Items[playerid][itemid][name]
Items[playerid][itemid][...another detail]

So like, the details each have their own array with in array, a sort of 4D array.

Is this possible or is there a better way to do it than I am at the moment?

(I can't store them in a player enum because I'm designing it so items can be dropped and just left on the floor)
Reply
#2

I wouldn't use an enum and would be able to use 3D array (assuming you want an array in the enum with playerid and itemid too).
Reply
#3

Could you possibly explain how you mean?
Reply
#4

You need to separate the arrays with the qualifyers you want to exchange:

example:

Код HTML:
CountVar[zoneid] --; && 	if(IsPlayerHelping[i]{ zoneid } == true)
so

you need to requifer it, so that the Arrays go Dimensional.


Код HTML:
Publib Arrays(playerid, zoneid, arrayid)
{
	if(CountVar[zoneid] > 0)
	{
		CountVar[zoneid] --;
		SetPlayerProgressBarValue(playerid, ZBar, 25 - CountVar[zoneid]);
		UpdatePlayerProgressBar(playerid, ZBar);
		foreach (new i : Player)
		{
			if(IsPlayerHelping[i]{ zoneid } == true)
			{
			    SlashInternationalValue(i, ZBar, 25 - CountVar[zoneid]);
				UpdatePlayerProgressBar(i, ZBar);
	            CountVar[zoneid] --;
			}
		}
	}
	else if(CountVar[zoneid] == 0)
	{
		 GangZoneStopFlashForAll(Zone[zoneid]);
	switch(pLang[playerid])		KillTimer(ZUpdateTimer[zoneid]);
		CountVar[zoneid] = 25;
	}
	else if(CountVar[zoneid] < 0)
	{
		ZONECaptured(playerid, zoneid);
		HidePlayerProgressBar(playerid, ZBar);
		KillTimer(ZUpdateTimer[zoneid]);
		CountVar[zoneid] = 25;
	}
    return 1;
}
I hope I fixed your problem
Reply
#5

Quote:
Originally Posted by Finn707
Посмотреть сообщение
So like, the details each have their own array with in array, a sort of 4D array.
If you exclude the enum's index, you got a 3D array.

Quote:
Originally Posted by Finn707
Посмотреть сообщение
Could you possibly explain how you mean?
An example:
pawn Код:
new Items_Array[MAX_PLAYERS][MAX_ITEMS][MAX_SOMETHING_HERE];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)