25.08.2014, 11:51
Function CheckPlayerName.
pawn Код:
stock CheckPlayerName(const name[])
{
if (strlen(name) < 6) return 0;
if (strfind(name, "_", true) == -1) return 0;
new underscorecount, expectinguppercase = 1;
for (new i = 0, j = strlen(name); i < j; i++)
{
if (expectinguppercase == 1)
{
if (name[i] < 'A' || name[i] > 'Z') return 0;
expectinguppercase = 0;
continue;
}
switch (name[i])
{
case '_':
{
if (underscorecount == 1) return 0;
else
{
underscorecount = 1;
expectinguppercase = 1;
}
continue;
}
case 'A' .. 'Z': continue;
case 'a' .. 'z': continue;
default: return 0;
}
}
return 1;
}
}