How to process a 2D array?
#1

I was making a message script where you have a function:
pawn Код:
MessageData(playerid, array[]);
What i want is to split the array, for example:
pawn Код:
new message[][15] =
{
     "hello",
     "hi"
}

MessageData(playerid, message);
But i can't, it gives me array dimensions do not match! Any help..
Reply
#2

Use this
Quote:

MessageData(playerid, array[][]);

As you notice you put two [] while declaring so you have to put two [] in function prototype too.
Reply
#3

Is there any way i can do it with 1D array? But should split!
Reply
#4

Quote:
Originally Posted by Excel™
Посмотреть сообщение
Is there any way i can do it with 1D array? But should split!
Whats the problem in using 2D array?
Reply
#5

Use it this way:
PHP код:
MessageData(playeridmessage[0]);
MessageData(playeridmessage[1]); 
Reply
#6

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
Whats the problem in using 2D array?
Its because i am doing multi purpose stuff on it. For example:

pawn Код:
MessageData(playerid, "Just one single string");
pawn Код:
new message[][15] =
{
     "hello",
     "hi"
}

MessageData(playerid, message);
Reply
#7

While passing multidimensional arrays to functions, only the last index can be left blank.

func(ar[2][]) //correct
func(ar[][]) //wrong
func(ar[5][5]) //correct
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)