. He used module memory which first is slower and second makes a lot of limits, so I wrote up you an example how to do this in only pawn code.
I also kept the same structure which normal arrays have, so you can use any similiar ways to call the variables:
In the example you only see fourth and fifth dimensions but you can use this up to 10 dimensions with the same formula.
Thing more to note is that you can came up with a bug which appears with increment and decrement operators. It comes when you use these operators as an expression with a cell of an array which is passed by defining with both pre and post modes. What the bug does is that the expression returns a wrong value and the variable isn't increased or decremented. You may somehow use the increment and decrement operators as statement without worries.
PHP Code:
/*
Plugin to test fourth and fifth array dimensions.
*/
#include <amxmodx>
#define PLUGIN "More array dimensions - Pawn"
#define VERSION "1.0"
#define AUTHOR "SnoW"
#define FIRST_DIMENSION 2
#define SECOND_DIMENSION 3
#define THIRD_DIMENSION 2
#define FOURTH_DIMENSION 3
#define FIFTH_DIMENSION 2
#define DIMENSIONS4 THIRD_DIMENSION * FOURTH_DIMENSION
#define DIMENSIONS5 DIMENSIONS4 * FIFTH_DIMENSION
#define array4[%1][%2][%3][%4] dArray4[ %1 ][ %2 ][ FOURTH_DIMENSION * %3 + %4 ]
#define array5[%1][%2][%3][%4][%5] dArray5[ %1 ][ %2 ][ ( FOURTH_DIMENSION * %3 + %4 ) * FIFTH_DIMENSION + %5 ]
public plugin_init( )
{
register_plugin( PLUGIN, VERSION, AUTHOR );
test;
}
test( )
{
//array4
new dArray4[ FIRST_DIMENSION ][ SECOND_DIMENSION ][ DIMENSIONS4 ] =
{
{
{ 0, 1, 2, 3, 4, 5 },
{ 6, 7, 8, 9, 10, 11 },
{ 12, 13, 14, 15, 16, 17 }
},
{
{ 18, 19, 20, 21, 22, 23 },
{ 24, 25, 26, 27, 28, 29 },
{ 30, 31, 32, 33, 34, 35 }
}
};
//array5
new dArray5[ FIRST_DIMENSION ][ SECOND_DIMENSION ][ DIMENSIONS5 ] =
{
{
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 },
{ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 },
{ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 }
},
{
{ 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47 },
{ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59 },
{ 60, 61, 62, 63, 63, 65, 66, 67, 68, 69, 70, 71 }
}
};
for( new d1; d1 < FIRST_DIMENSION; d1++ )
for( new d2; d2 < SECOND_DIMENSION; d2++ )
for( new d3; d3 < THIRD_DIMENSION; d3++ )
for( new d4; d4 < FOURTH_DIMENSION; d4++ )
{
server_print( "%i", array4[ d1 ][ d2 ][ d3 ][ d4 ] );
for( new d5; d5 < FIFTH_DIMENSION; d5++ )
{
server_print( "%i", array5[ d1 ][ d2 ][ d3 ][ d4 ][ d5 ] );
}
}
}