SA-MP Forums Archive
Name help.. - 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: Name help.. (/showthread.php?tid=130610)



Name help.. - SiJ - 27.02.2010

Hey,
I'm using this to split player RP name to Firstname and Lastname:
pawn Код:
new TextName[MAX_PLAYERS][24];

GetPlayerName(playerid,pName[playerid],24);
sscanf(pName[playerid],"p_ss",TextName[playerid]);
tName[playerid] = Create3DTextLabel(TextName[playerid],COLOR_WHITE,0.0,0.0,0.0,50,-1,1);
But how should I use TextName[playerid] to show the first name only?
Let's say I connect with name Wayne_Wan I tried TextName[playerid][0] - it shows Wayne, but TextName[playerid][1] shows ayne.. how should I use it to show Wan?




Re: Name help.. - ¤Adas¤ - 27.02.2010

pawn Код:
public OnPlayerConnect(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
new var = strfind(Name, "_", true);
new NewName[MAX_PLAYER_NAME];
strmid(NewName, Name, 0, var, sizeof(NewName));
return true;
}
Something like this?


Re: Name help.. - smeti - 27.02.2010

Quote:
Originally Posted by SiJ
Hey,
I'm using this to split player RP name to Firstname and Lastname:
pawn Код:
new TextName[MAX_PLAYERS][24];

GetPlayerName(playerid,pName[playerid],24);
sscanf(pName[playerid],"p_ss",TextName[playerid]);
tName[playerid] = Create3DTextLabel(TextName[playerid],COLOR_WHITE,0.0,0.0,0.0,50,-1,1);
pawn Код:
new
        TextName[2][MAX_PLAYER_NAME],
        pName[MAX_PLAYER_NAME];// = "FirstName_LastName";
       
    GetPlayerName(playerid, pName, sizeof pName);
//            Firstname   Lastname
    sscanf(pName, "p_ss", TextName[0], TextName[1]);
//           LastName
    Create3DTextLabel(TextName[1],COLOR_WHITE,0.0,0.0,0.0,50,0);