SA-MP Forums Archive
[Question]First player name letter. - 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: [Question]First player name letter. (/showthread.php?tid=389522)



[Question]First player name letter. - FuznesS - 02.11.2012

Hey, i want to know how i can to get the first letter/character of player name, for example the player name is: Sean_Banks, and i want to get his first letter S, and his first letter in his last name.
for Exmaple: Sean_Banks = SB, how did i do it and get the letters? i want it for vehicle plate system..


Re: [Question]First player name letter. - Nirzor - 02.11.2012

i think it will be hard but you can use variables to detect it and make it


Re: [Question]First player name letter. - ReneG - 02.11.2012

pawn Код:
stock retFirstLeters(name[MAX_PLAYER_NAME])
{
    new
        strpos = strfind(name, "_", true),
        string[4];
   
    format(string, sizeof(string), "%c%c", name[0], name[strpos+1]);
    return string;
}
example
pawn Код:
printf("%s",retFirstLeters("Sean_Banks"));
prints out
Quote:

SB

The name HAS to be in roleplay format for it to work though.


Re: [Question]First player name letter. - FuznesS - 02.11.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
pawn Код:
stock retFirstLeters(name[MAX_PLAYER_NAME])
{
    new
        strpos = strfind(name, "_", true),
        string[4];
   
    format(string, sizeof(string), "%c%c", name[0], name[strpos+1]);
    return string;
}
example
pawn Код:
printf("%s",retFirstLeters("Sean_Banks"));
prints out
The name HAS to be in roleplay format for it to work though.
I'll test it now, thank you very much!

EDIT: its work only for Sean Banks name, i want it for every player for Exmaple my name is not Joey Taylor its tell its my name is JT, and Sean Banks SB, and for every player like his name.


Re: [Question]First player name letter. - JaKe Elite - 02.11.2012

use the code

pawn Код:
retFirstLetters(playername[]);
You just copy the code that's why it doesn't work in other names.


Re: [Question]First player name letter. - FuznesS - 02.11.2012

Thank you all, its works great!!