[Help] - Multidimensional Arrays - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] - Multidimensional Arrays (
/showthread.php?tid=228319)
[Help] - Multidimensional Arrays -
xRyder - 19.02.2011
Can someone please show me an example on how to store some text(string) in multidimensional array.
I would really appreciate that.
Thank you.
Re: [Help] - Multidimensional Arrays -
Ash. - 19.02.2011
Well, you would do something like this; I will use an example Calg00ne was talking about in another thread.
pawn Код:
new pName[MAX_PLAYERS][MAX_PLAYER_NAME];
//[MAX_PLAYERS] - the maximum amount of "data"
//[MAX_PLAYER_NAME] - the max length of the string (or player name, in this case)
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, pName[playerid], MAX_PLAYER_NAME); //This stores the players name in the multi-dimensional array.
//You an also store data in it using format, like so;
format(pName, MAX_PLAYER_NAME, "This is the text that will go in pName");
return 1;
}
Re: [Help] - Multidimensional Arrays -
xRyder - 19.02.2011
Okay, I understand that, but what about making some command like:
pawn Код:
CMD:test(playerid, params[])
{
SendClientMessage(playerid, COLOR, params);
// and now i need to store 'params' in multidimensional array so I can use it again
// Sure that doesn't have to be this way, but this is just a simple example
return 1;
}
Re: [Help] - Multidimensional Arrays -
Ash. - 19.02.2011
You can then do;
pawn Код:
CMD:text(playerid, params[])
{
SendClientMessage(playerid, COLOR, params);
//format(ArrayName[playerid], ArraySize, params);
//Or back to my example;
format(pName[playerid], MAX_PLAYER_NAME, params);
return 1;
}
Re: [Help] - Multidimensional Arrays -
xRyder - 19.02.2011
Ohh, okay.
I'll try to play around with that.
Thank you for your time.
Re: [Help] - Multidimensional Arrays -
Ash. - 19.02.2011
Any time

Let me know if you need any more help, either here or by visitor message