SA-MP Forums Archive
[HELP] Player name - 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: [HELP] Player name (/showthread.php?tid=192032)



[HELP] Player name - Pooh7 - 21.11.2010

hi

if player has a name in format Firstname_Lastname, how to extract only "Firstname" into another string? (without "_Lastname")

I want to make something like this: "Welcome back, Firstname", or "Welcome back, Firstname Lastname" (without "_").
how to do this? (if length of "Firstname" and "Lastname" and all player name is unknown)


Re: [HELP] Player name - Hiddos - 21.11.2010

Use strmid:

pawn Код:
new pName[MAX_PLAYER_NAME], firstname[MAX_PLAYER_NAME], pos = -1;
GetPlayerName(playerid, pName, sizeof pName);
for(new c; c < MAX_PLAYER_NAME; c++)
{
  if(pName[c] == '_')
  {
    pos = c;
    break;
  }
}
strmid(firstname, pName, 0, pos);
Untested and roughly coded, I don't know if this works.


Re: [HELP] Player name - Pooh7 - 21.11.2010

It works, thank you