Question about multi-dimensional arrays -
Finn707 - 27.05.2015
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)
Re: Question about multi-dimensional arrays -
Konstantinos - 27.05.2015
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).
Re: Question about multi-dimensional arrays -
Finn707 - 27.05.2015
Could you possibly explain how you mean?
Re: Question about multi-dimensional arrays -
Charalambos26 - 27.05.2015
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
Re: Question about multi-dimensional arrays -
Konstantinos - 28.05.2015
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];