Show only first name
#4

I just made this function for you, though I haven't had a chance to properly test it.

pawn Код:
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;
}
This will only get the name before the first underscore.

Usage:
pawn Код:
new szName[MAX_PLAYER_NAME], szMessage[128];
GetPlayerName(playerid, szName, MAX_PLAYER_NAME);
format(szMessage, sizeof(szMessage), "Hi, %s. How are you?", getFirstName(szName));
Reply


Messages In This Thread
Show only first name - by Harry_Sandhu - 06.07.2011, 12:11
Re: Show only first name - by SwatOwner - 06.07.2011, 12:23
Re: Show only first name - by Harry_Sandhu - 06.07.2011, 12:39
Re: Show only first name - by Calgon - 06.07.2011, 12:59
Re: Show only first name - by CoaPsyFactor - 06.07.2011, 14:43
Re: Show only first name - by Calgon - 06.07.2011, 14:44
Re: Show only first name - by CoaPsyFactor - 06.07.2011, 14:46
AW: Show only first name - by Nero_3D - 06.07.2011, 14:56
Re: Show only first name - by CoaPsyFactor - 06.07.2011, 14:59

Forum Jump:


Users browsing this thread: 2 Guest(s)