Save all nick's players
#1

Hi everybody,
I'm trying to save all nicks of players in game...
I'm using this code, but doesn't work
Код:
format(originalnick[playerid],sizeof(originalnick[playerid]),"%s",name);
OR
GetPlayerName(playerid,originalnick[playerid],sizeof(originalnick[playerid]));
ERRORS:
(263) : error 001: expected token: "]", but found "-identifier-"
(263) : warning 215: expression has no effect
(263) : error 001: expected token: ";", but found "]"
(263) : error 029: invalid expression, assumed zero
(263) : fatal error 107: too many error messages on one line

how can i fix it?
thanks for your helping. Bye
Reply
#2

You can't use sizeof like this
pawn Код:
sizeof(originalnick[playerid])
even if you're using 2d arrays. Just add the max number of cells minus 1 instead of sizeof
Reply
#3

excuse...how can i do it?

EDIT: I need only that all nicks will be restored at restart of gmode
Reply
#4

Maybe you should remove the [playerid], like this:

pawn Код:
GetPlayerName(playerid,originalnick,sizeof(originalnick));
Reply
#5

Quote:
Originally Posted by dice7
You can't use sizeof like this
pawn Код:
sizeof(originalnick[playerid])
even if you're using 2d arrays. Just add the max number of cells minus 1 instead of sizeof
Of course he can, and it's possible with any amount of dimensions.

pawn Код:
sizeof(originalnick[])
Quote:
Originally Posted by cοοp
Maybe you should remove the [playerid], like this:

pawn Код:
GetPlayerName(playerid,originalnick,sizeof(originalnick));
That will get the first dimension size, aka MAX_PLAYERS.

pawn Код:
new array[10][20][30];
printf("%d", sizeof array);   // 10
printf("%d", sizeof array[]);  // 20
printf("%d", sizeof array[][]); // 30
Reply
#6

I need to do this when you restart the gmode
Код:
for(i=0;i<MAX_PLAYERS;i++)
{
SetPlayerName(i, originalnick[i]);
}
Reply
#7

DONE!
declaration:
Код:
new originalnick[MAX_PLAYERS][256];
get nick (OnPlayerConnect):
Код:
GetPlayerName(playerid,name,sizeof(name));
GetPlayerName(playerid,originalnick[playerid],sizeof(name));
OnPlayerDisconnect:
Код:
for(new i=0;i<MAX_PLAYERS;i++)
	{
	SetPlayerName(i, originalnick[i]);
	}
Thanks for your help!
Bye
Reply
#8

Is there a problem with
pawn Код:
GetPlayerName(playerid, originalnick[playerid], MAX_PLAYER_NAME);
?
Reply
#9

another solution...yes
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)