How to make this array to store strings?
#1

I have this array, how I need to remake it to store strings?
Код:
new PlayerTexts[MAX_PLAYERS][1000];
Because now I get:
Код:
error 006: must be assigned to an array
Array info like this:
Код:
PlayerTexts[playerid][0] = "Some text 1";
PlayerTexts[playerid][1] = "Some text 2";
PlayerTexts[playerid][2] = "Some text 3";
...
I use like this:
Код:
PlayerTexts[playerid][0]
PlayerTexts[playerid][1]
PlayerTexts[playerid][2]
...
Reply
#2

This depends entirely upon what you are trying to achieve.

If you want to store one string of length 1000 for each player:
Код:
new PlayerTexts[MAX_PLAYERS][1000];
...
PlayerTexts[playerid] = "Some text"
Or if you want to store 1000 strings of a given length for each player:
Код:
new PlayerTexts[MAX_PLAYERS][1000][1024];
...
PlayerTexts[playerid][0] = "The first string";
PlayerTexts[playerid][1] = "The second string";
Reply
#3

Quote:
Originally Posted by Simeon87
Посмотреть сообщение
Код:
new PlayerTexts[MAX_PLAYERS][1000][1024];
...
PlayerTexts[playerid][0] = "The first string";
PlayerTexts[playerid][1] = "The second string";
I thinking about this code, but after it I getting "don't send"
Reply
#4

If you are simply trying to send one of the strings to a player:
Код:
SendClientMessage(playerid, COLOR_RED, PlayerTexts[playerid][1]);
Reply
#5

My challenge is:
Код:
new PlayerTexts[MAX_PLAYERS][1000];
...
for(new i=0; i<mysql_num_rows(); i++)
{
      mysql_fetch_field_row(fetch, Choosen_Row);
      PlayerTexts[playerid][i] = fetch;
}
...
SendClientMessage(playerid, -1, PlayerTexts[playerid][0]);
..or..
ShowPlayerDialog(playerid, 101, DIALOG_STYLE_PASSWORD, PlayerTexts[playerid][0], PlayerTexts[playerid][1], PlayerTexts[playerid][2], "");
Reply
#6

Just change

new PlayerTexts[MAX_PLAYERS][1000];

to

new PlayerTexts[MAX_PLAYERS][1000][];
Reply
#7

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Just change

new PlayerTexts[MAX_PLAYERS][1000];

to

new PlayerTexts[MAX_PLAYERS][1000][];
On empty size I getting:
Код:
error 009: invalid array size (negative, zero or out of bounds)
error 046: unknown array size (variable "PlayerTexts")
warning 215: expression has no effect
On some size like I said pawno stop working.
Reply
#8

My bad, it should be...

new PlayerTexts[MAX_PLAYERS][1000][128];

It should never crash pawno, if it does there is an error in your code... Change 128 accordingly, but I recommend keeping it low, the 3D array is already huge (500*1000*12...
Reply
#9

Quote:
Originally Posted by Crayder
Посмотреть сообщение
My bad, it should be...

new PlayerTexts[MAX_PLAYERS][1000][128];

It should never crash pawno, if it does there is an error in your code... Change 128 accordingly, but I recommend keeping it low, the 3D array is already huge (500*1000*12...
No errors found before making array, but third size crashing pawno.
Reply
#10

Try using strcat?

pawn Код:
strcat(PlayerTexts[playerid][0], "Some Data Here");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)