Player Initials
#1

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(playeridszNamesizeof(szName));
    return 
szName;

Reply
#2

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...
Reply
#3

Ty vm!! +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)