[Include] IsARolePlayName
#1

Yo, just putting it here so people can find it since it's so hard to find otherwise


It makes sure a string contains a upper-case first character, one underscore and a upper-case letter after that. It also checks for illegal characters and only allows A-Z and a-z.
pawn Код:
stock IsARolePlayName(name[])
{
    new
                szLastCell,
        bool:   bUnderScore;
       
    for(new i; i < strlen(name); i++)
    {
        if(name[i] == '_')
        {
            if(bUnderScore == true)
            {
                return 0;
            }
           
            bUnderScore = true;
        }
       
        else if(!szLastCell || szLastCell == '_') // Check if capitalized where it should be
        {
            if(name[i] < 'A' || name[i] > 'Z')
            {
                return 0;
            }
        }
       
        else
        {
            if(name[i] < 'a' || name[i] > 'z')
                return 0;
        }
       
        szLastCell = name[i];
    }
   
    if(bUnderScore == false)
        return 0;
       
    return 1;
}
It can also be found on pastebin: http://pastebin.com/fDXPduZU
Reply


Messages In This Thread
IsARolePlayName - by Lenny the Cup - 19.07.2011, 20:22
Re: IsARolePlayName - by kiss - 19.07.2011, 20:24
Re: IsARolePlayName - by SpiderWalk - 19.07.2011, 20:29
Re: IsARolePlayName - by MoroDan - 19.07.2011, 20:32
Re: IsARolePlayName - by SchurmanCQC - 19.07.2011, 20:33
Re: IsARolePlayName - by Lenny the Cup - 19.07.2011, 21:29
Re: IsARolePlayName - by [HiC]TheKiller - 20.07.2011, 02:14
Re: IsARolePlayName - by wups - 20.07.2011, 08:36
Re: IsARolePlayName - by Vipero - 20.07.2011, 08:38
Re : IsARolePlayName - by mehdi-jumper - 30.11.2011, 20:51

Forum Jump:


Users browsing this thread: 1 Guest(s)