RP name check... help please
#1

Hey everyone... I'm looking for a valid name check public which checks if the playername contains a form like this:

Firstname_Lastname

Not FirstName_LaStname or something like that.... Right now I'm checking for the "_"... But I want to check for capitals too... How to do this?

pawn Код:
stock IsValidName(playerid)
{
    if (IsPlayerConnected(playerid))
    {
        new player[24];
        GetPlayerName(playerid,player,24);
        for(new n = 0; n < strlen(player); n++)
        {
            if (player[n] == '_') return 1;
            if (player[n] == ']' || player[n] == '[') return 0;
        }
    }
    return 0;
}
Reply
#2

pawn Код:
stock IsValidName(playerid)
{
    if (IsPlayerConnected(playerid))
    {
        new player[24];
        GetPlayerName(playerid,player,24);
        for(new n = 0; n < strlen(player); n++)
        {
            if (player[n] == '_' && player[n+1] >= 'A' && player[n+1] <= 'Z') return 1;
            if (player[n] == ']' || player[n] == '[') return 0;
        }
    }
    return 0;
}
Reply
#3

Does that check the capital of both Firstname and Lastname?
Reply
#4

Quote:
Originally Posted by introzen
Посмотреть сообщение
Does that check the capital of both Firstname and Lastname?
Only the first name, if you wan't do the last name then replace my edited code with this.

pawn Код:
new splitname[2][MAX_PLAYER_NAME];
split(player, splitname, '_');
if (player[n] == '_' && splitname[0+1] >= 'A' && splitname[0+1] <= 'Z' && splitname[1+1] >= 'A' && splitname[1+1]<= 'Z') return 1;
You obviously need the split function to use that. I'm not 100% if that will work or not.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)