Get the 'Firstname' from Firstname_lastname format
#1

How would you get the Firstname from a Firstname_Lastname format? So get every text in the name before the first "_". Then if there is no "_" then you just get the whole name. is it possible?
Reply
#2

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
How would you get the Firstname from a Firstname_Lastname format? So get every text in the name before the first "_". Then if there is no "_" then you just get the whole name. is it possible?
pawn Код:
stock GetPlayerFirstName(playerid)
{
    new
        namestring[2][MAX_PLAYER_NAME],
        name[MAX_PLAYER_NAME];

    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    split(name, namestring, '_');
    return namestring[0];
}

stock GetPlayerLastName(playerid)
{
    new
        namestring[2][MAX_PLAYER_NAME],
        name[MAX_PLAYER_NAME];

    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    split(name, namestring, '_');
    return namestring[1];
}
Not sure who created it, but it sure as hell wasn't me. Oh, and i'll include the last name version of it aswell.
Reply
#3

Quote:
Originally Posted by Skylar Paul
Посмотреть сообщение
pawn Код:
stock GetPlayerFirstName(playerid)
{
    new
        namestring[2][MAX_PLAYER_NAME],
        name[MAX_PLAYER_NAME];

    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    split(name, namestring, '_');
    return namestring[0];
}

stock GetPlayerLastName(playerid)
{
    new
        namestring[2][MAX_PLAYER_NAME],
        name[MAX_PLAYER_NAME];

    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    split(name, namestring, '_');
    return namestring[1];
}
Not sure who created it, but it sure as hell wasn't me. Oh, and i'll include the last name version of it aswell.
Thankyou heaps!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)