01.08.2010, 01:20
(
Последний раз редактировалось Kyosaur; 01.08.2010 в 11:05.
)
Quote:
Код:
stock NameFromFullRPname(playerid) { new ImeEx[MAX_PLAYER_NAME]; new destinacija[64]; destinacija[0] = 0; GetPlayerName(playerid, ImeEx, sizeof(ImeEx)); if(strfind(ImeEx,"_") != -1) for(new x =0; x < strlen(ImeEx); x++) if(ImeEx[x] == '_') strmid(destinacija, ImeEx, 0, x,sizeof(destinacija)); return destinacija; } Use like this : Код:
new Name[64]; Name = NameFromFullRPname(playerid); printf("Your first name is %s", Name); ![]() |
Here's how i'd personally do it:
pawn Код:
stock GetRolePlayName(playerid, first[24], last[24] = "N/A")
{
new trpn[MAX_PLAYER_NAME];
if(GetPlayerName(playerid,trpn,sizeof(trpn)))
{
new strd = strfind(trpn, "_", false);
if(strd != -1)
{
strmid(first,trpn,0,strd,sizeof(first));
strmid(last,trpn,strd+1,sizeof(trpn),sizeof(last));
return 1;
}
return 0;
}
return 0;
}
It has a connected check, no loops, and an optional last name parameter.
usage:
Код:
new FirstName[MAX_PLAYER_NAME, LastName[Max_PLAYER_NAME]; GetRolePlayName(playerid,FirstName,LastName); //dont need the LastName (optional) printf("First name = %s, and last name = %s", FirstName, LastName);