SA-MP Forums Archive
3D Array is giving errors - 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)
+--- Thread: 3D Array is giving errors (/showthread.php?tid=578860)



3D Array is giving errors - Muted - 22.06.2015

At the start of the array: error 029: invalid expression, assumed zero
At the end of the array: error 010: invalid function or declaration

Код:
new Data[3][3][10] = {  
        {"123456",120,3},
        {"123456789",100,2},
        {"12345",0,100}
};



Re: 3D Array is giving errors - Pottus - 22.06.2015

Of course it is that isn't the correct syntax this is how this array actually looks.

Код:
new Data[3][3][10] = {
	{
		{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
		{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
		{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
	},
	{
		{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
		{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
		{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
	},
	{
		{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
		{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
		{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
	}
};



Re: 3D Array is giving errors - Muted - 22.06.2015

Hmm, I found an example in this tutorial https://sampforum.blast.hk/showthread.php?tid=318212 and I thought it would work.

Код:
new Array_3D_B [] [] [] =
{
	{float:102.14571, 	"******", 		4100},
	{float:452.45245, 	"*******",  	4012},
	{float:124.78951, 	"Memebase",		4501}
};
But all I need is an array to store strings and some integers, I didn't know how to do it with a 2D.


Re: 3D Array is giving errors - Pottus - 22.06.2015

Use an enum instead.


Re: 3D Array is giving errors - Muted - 22.06.2015

Instead of a string or an array? I don't think I can do without an array because there's a lot more data than just 3 lines.


AW: 3D Array is giving errors - Mencent - 22.06.2015

Hello!

This is an example how you can do this with an enum.
PHP код:
enum dataEnum
{
    
id[20],
    
id2,
    
id3
};
new 
Data[3][dataEnum] =
{
    {
"123456",120,3},
    {
"123456789",100,2},
    {
"12345",0,100}
}; 
- Mencent