3D Array is giving errors
#1

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}
};
Reply
#2

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 }
	}
};
Reply
#3

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.
Reply
#4

Use an enum instead.
Reply
#5

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.
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)