GetPlayerFirstName(playerid)
#1

The title says it all.


How could I find a players first name on their name string?

Say I have:

Test_Name

How could I get it to just send on a text - Welcome back, Test.

Instead of Welcome back, Test_Name.

Thanks.
Reply
#2

do it with sscanf2 ^^
parse FirstName, search for the '_', the second name is a {quiet} parameter, so aSecondName is not required:
pawn Code:
sscanf(PlayerName,"s[24]'_'{s[24]}",FirstName);
i <3 the '_' search function, maybe the p<_> delimeter could do that too..
Reply
#3

Mate, thanks for that.

BUT

It's confusing looking! -.- :')

Could you possibly explain it to me a little more? :3 like, maybe put it in a stock? D:

Thanks! <3
Reply
#4

You can also use strdel to delete part of the player's name :


pawn Code:
stock GetPlayerFirstName(playerid)
{
    new NickName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, NickName, MAX_PLAYER_NAME);
    strdel(NickName, strfind(NickName, "_"), strlen(NickName));
    return NickName;
}


I hope that i have helped .
Reply
#5

That looks like it only deletes the '_' :O

Does it delete all after the _ and the _ too? :3
Reply
#6

Quote:
Originally Posted by iGetty
View Post
Does it delete all after the _ and the _ too? :3
Yes, it does .



I hope that i have helped .
Reply
#7

You have helped LOADS!

Thanks and both have been repped!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)