How to process a 2D array? - 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: How to process a 2D array? (
/showthread.php?tid=570084)
How to process a 2D array? -
Excel™ - 05.04.2015
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..
Re: How to process a 2D array? -
BroZeus - 05.04.2015
Use this
Quote:
MessageData(playerid, array[][]);
|
As you notice you put two [] while declaring so you have to put two [] in function prototype too.
Re: How to process a 2D array? -
Excel™ - 05.04.2015
Is there any way i can do it with 1D array? But should split!
Re: How to process a 2D array? -
BroZeus - 05.04.2015
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?
Re: How to process a 2D array? -
ATGOggy - 05.04.2015
Use it this way:
PHP код:
MessageData(playerid, message[0]);
MessageData(playerid, message[1]);
Re: How to process a 2D array? -
Excel™ - 05.04.2015
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);
Re: How to process a 2D array? -
Yashas - 05.04.2015
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