More Dimensions in arrays - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: More Dimensions in arrays (
/showthread.php?tid=108501)
More Dimensions in arrays -
jyrno42 - 14.11.2009
Currently I'm doing it this way:
Код:
#define FIRST_DIMENSION 3
#define SECOND_DIMENSION 16
#define THIRD_DIMENSION 24
// GetFirstDim(firstDim, secondDim, secondDimSize);
#define GetFirstDim(%0,%1,%2) ((%1 < %2)?((%0*%2)+%1):((%0*%2)+%2-1))
enum bPathInf
{
sampleInt,
Float: sampleFloat
};
new SampleArray[FIRST_DIMENSION*SECOND_DIMENSION][THIRD_DIMENSION][bPathInf];
// Somewhere in my code I get a value like that:
SampleArray[GetFirstDim(0, 1, SECOND_DIMENSION)][0][sampleInt] = 0;
So I have a question, is my way any good, or would using two separate arrays to store 4 dimensions be a better solution. Or is there an even better one available?