06.07.2011, 12:11
Is there any script so it shows the Players First name only and not the Lastname?
If yes then can you tell me how it can be?
If yes then can you tell me how it can be?
stock getFirstName(szPlayerName[]) {
new
_tmpSzPlayerName[MAX_PLAYER_NAME],
iCh = strfind(szPlayerName, "_", true);
if(iCh != -1) {
strcat(_tmpSzPlayerName, szPlayerName, MAX_PLAYER_NAME);
strdel(_tmpSzPlayerName, iCh, strlen(szPlayerName));
} else {
format(_tmpSzPlayerName, sizeof(_tmpSzPlayerName), "Nameless");
}
return _tmpSzPlayerName;
}
new szName[MAX_PLAYER_NAME], szMessage[128];
GetPlayerName(playerid, szName, MAX_PLAYER_NAME);
format(szMessage, sizeof(szMessage), "Hi, %s. How are you?", getFirstName(szName));
stock GetFirstName(playerid){
new PlayerName[128], Split[3][128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
split(PlayerName, Split, '_');
return Split[0];
}
stock split(const strsrc[], strdest[][], delimiter)
{
GetPlayerName(
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc))
{
if(strsrc[i] == delimiter || i == strlen(strsrc))
{
len = strmid(strdest[aNum], strsrc, li, i, 128);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
stock getFirstName(name[]) {
new
dest[MAX_PLAYER_NAME];
dest[1] = strfind(name, "_", false);
if(dest[1] != -1) {
strcat(dest, name, dest[1]);
} else {
strcat(dest, name, sizeof dest);
}
return dest;
}