SA-MP Forums Archive
Get the 'Firstname' from Firstname_lastname format - 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: Get the 'Firstname' from Firstname_lastname format (/showthread.php?tid=268293)



Get the 'Firstname' from Firstname_lastname format - Jack_Leslie - 12.07.2011

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?


Re: Get the 'Firstname' from Firstname_lastname format - Skylar Paul - 12.07.2011

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.


Re: Get the 'Firstname' from Firstname_lastname format - Jack_Leslie - 12.07.2011

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!