Player Initials - 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)
+--- Thread: Player Initials (
/showthread.php?tid=598704)
Player Initials -
Squirrel - 16.01.2016
Alright so Ive got a lil bit of a problem. I want to display only players Initials. Ie my name would be Squirrel_LastName, I want to add like
"S. LastName says: %s"
Code
PHP код:
new string[128];
format(string,sizeof(string),"%s says: %s",GetName(playerid),text);
GetName basically just gets the full name. How do I make it somehow get only initials of FirstName but display full last name?
PHP код:
stock GetName(playerid);
{
new szName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szName, sizeof(szName));
return szName;
}
Re: Player Initials -
Crayder - 16.01.2016
pawn Код:
stock GetName(playerid, bool:initialize = false);
{
new szName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szName, sizeof(szName));
if(!initialize)
return szName;
else {
format(szName, sizeof szName, "%c. %s", szName[0], szName[strfind(szName, "_") + 1]);
return szName;
}
}
To use the initialized name just use GetName like this: GetName(playerid, true);
To use the regular name, don't change anything, just use the function as normal: GetName(playerid);
Ex.
pawn Код:
new string[128];
//Will print: "C. Crayder says: text"
format(string,sizeof(string) ,"%s says: %s", GetName(playerid, true), text);
//Both will print: "Crayder Crayder says: text"
format(string,sizeof(string) ,"%s says: %s", GetName(playerid), text);
format(string,sizeof(string) ,"%s says: %s", GetName(playerid, false), text);
Note: This is untested by the way, but it should work...
Re: Player Initials -
Squirrel - 16.01.2016
Ty vm!! +rep