Differences - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Differences (
/showthread.php?tid=191116)
Differences -
zack3021 - 18.11.2010
I have been using,
pawn Код:
GetPlayerName(playerid,name,sizeof(name)); and
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
But what is the differences between them?
What effect does the sizeof() have on it?
Re: Differences -
Cameltoe - 18.11.2010
Quote:
Originally Posted by zack3021
I have been using,
pawn Код:
GetPlayerName(playerid,name,sizeof(name)); and GetPlayerName(playerid,name,MAX_PLAYER_NAME);
But what is the differences between them?
|
Try printing them.
pawn Код:
printf("%d",MAX_PLAYER_NAME);
printf("%d",sizeof(name));
Though i would recommend using an stock that returns the player name.. like this:
pawn Код:
stock GetPlayerNameEx(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}
Re: Differences -
zack3021 - 18.11.2010
Oh ok but what effect does the sizeof() have on it?
Re: Differences -
Grim_ - 18.11.2010
None really, however it would be faster to just use the MAX_PLAYER_NAME definition since functions take longer to execute then simply reading numbers. For example,
pawn Код:
new pName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, pName, sizeof( pName ) );
// This is basically telling the compiler:
GetPlayerName( playerid, pName, sizeof( 24 ) );
Basically, making it run an extra function to do the same thing. So you are better off writing your code like so:
pawn Код:
PlayerName( playerid )
{
new pName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, pName, MAX_PLAYER_NAME );
return pName;
}