Save all nick's players -
Murd0cK - 06.07.2009
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
Re: Save all nick's players -
dice7 - 06.07.2009
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
Re: Save all nick's players -
Murd0cK - 06.07.2009
excuse...how can i do it?
EDIT: I need only that all nicks will be restored at restart of gmode
Re: Save all nick's players -
refshal - 06.07.2009
Maybe you should remove the [playerid], like this:
pawn Код:
GetPlayerName(playerid,originalnick,sizeof(originalnick));
Re: Save all nick's players -
yom - 06.07.2009
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.
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
Re: Save all nick's players -
Murd0cK - 06.07.2009
I need to do this when you restart the gmode
Код:
for(i=0;i<MAX_PLAYERS;i++)
{
SetPlayerName(i, originalnick[i]);
}
Re: Save all nick's players -
Murd0cK - 06.07.2009
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
Re: Save all nick's players -
yom - 06.07.2009
Is there a problem with
pawn Код:
GetPlayerName(playerid, originalnick[playerid], MAX_PLAYER_NAME);
?
Re: Save all nick's players -
Murd0cK - 06.07.2009
another solution...yes