[Help] - Multidimensional Arrays
#1

Can someone please show me an example on how to store some text(string) in multidimensional array.
I would really appreciate that.

Thank you.
Reply
#2

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

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

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

Ohh, okay.
I'll try to play around with that.
Thank you for your time.
Reply
#6

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


Forum Jump:


Users browsing this thread: 2 Guest(s)