29.12.2010, 13:09
Just wrote that as improved version of the above code now
- Each name must start with a capital and go on with lower case letters
- Names are separted with underscores
- No limit with names, means "Don_Fernando_Flores" as example is valid
- Each name must start with a capital and go on with lower case letters
- Names are separted with underscores
- No limit with names, means "Don_Fernando_Flores" as example is valid
pawn Код:
stock IsValidRPName(name[])
{ //Nero_3D © 12.2010
new idx = strfind(name, "_", false);
if((idx != -1) && ('A' <= name[0] <= 'Z') && ('A' <= name[idx + 1] <= 'Z')) {
new i = 1;
while(i != idx) {
switch(name[i]) {
case 'a'..'z': i++;
default: return 0;
}
}
for(i += 2; ; ) {
switch(name[i]) {
case 'a'..'z': i++;
case '_': return IsValidRPName(name[idx + 1]);
case EOS: return 1;
default: return 0;
}
}
}
return 0;
}