SA-MP Forums Archive
RP name check... help please - 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: RP name check... help please (/showthread.php?tid=157463)



RP name check... help please - introzen - 06.07.2010

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;
}



Re: RP name check... help please - Carlton - 06.07.2010

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;
}



Re: RP name check... help please - introzen - 06.07.2010

Does that check the capital of both Firstname and Lastname?


Re: RP name check... help please - Carlton - 06.07.2010

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.