Trouble with array
#1

Код:
new playermail[256][MAX_PLAYERS];
Код:
stock SendPlayerMail(playerid, text[])
{
	if(IsPlayerConnected(playerid))
	{
	    playermail[playerid] = text; //error 047: array sizes do not match, or destination array is too small
	}
}
after used that:
Код:
SendPlayerMail(playerid, "asdf123");
Reply
#2

1) You have your array dimensions in the wrong order. Swap them (MAX_PLAYERS <-> 256).
2) Use strcpy to copy strings.
Reply
#3

first, changed but still.
second, how exactly?
Reply
#4

who is know?
Reply
#5

Just include string into the gamemode and as Vince put on another post for copying strings:
pawn Код:
stock strcpy(dest[], const source[], maxlength=sizeof dest)
Reply
#6

just like this? still error.
Код:
stock SendPlayerMail(playerid, text[])
{
	if(IsPlayerConnected(playerid))
	{
	    playermail[playerid] = text;
	    strcpy(playermail[playerid], text, 256);
	}
}

stock strcpy(dest[], const source[], maxlength=sizeof dest)
{
    strcat((dest[0] = EOS, dest), source, maxlength);
}
Reply
#7

for huge arrays with text use strpack and unpack

pawn Код:
new playermail[MAX_PLAYERS][128 char];

stock SendPlayerMail(playerid, text[])
{
    if(IsPlayerConnected(playerid))
        strpack(playermail[playerid],text,sizeof(playermail[]));
}
and after if you want to 'decode'

pawn Код:
new Mail[128];
strunpack(Mail,playermail[playeris]);

SendClientMessage(playerid,-1,Mail); // Mail is now your playermail[playerid]
Reply
#8

work, thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)