19.07.2011, 20:22
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.
It can also be found on pastebin: http://pastebin.com/fDXPduZU

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