23.04.2013, 21:00
Hey, guys. I've been using a pre-written function for checking RP Names, problem is it seems to work fine up until you use an RP name such as
Firstname_
And it still lets it pass as it has an underscore. I've tried multiple ways to try count the characters AFTER the _ but I can't seem to figure it out without causing it to completely work in a different way. The function i'm using is this
I've tried counting the string but I have no idea how to go about checking for the underscore... other than trying
Any ideas how to check for an underscore? Then make sure after it there is a minimum of 3 characters?
Firstname_
And it still lets it pass as it has an underscore. I've tried multiple ways to try count the characters AFTER the _ but I can't seem to figure it out without causing it to completely work in a different way. The function i'm using is this
pawn Код:
stock NameValidator(name[])
{
new underline=0;
if(strfind(name,"[",true) != (-1)) return 0;
else if(strfind(name,"]",true) != (-1)) return 0;
else if(strfind(name,"$",true) != (-1)) return 0;
else if(strfind(name,"(",true) != (-1)) return 0;
else if(strfind(name,")",true) != (-1)) return 0;
else if(strfind(name,"=",true) != (-1)) return 0;
else if(strfind(name,"@",true) != (-1)) return 0;
else if(strfind(name,"1",true) != (-1)) return 0;
else if(strfind(name,"2",true) != (-1)) return 0;
else if(strfind(name,"3",true) != (-1)) return 0;
else if(strfind(name,"4",true) != (-1)) return 0;
else if(strfind(name,"5",true) != (-1)) return 0;
else if(strfind(name,"6",true) != (-1)) return 0;
else if(strfind(name,"7",true) != (-1)) return 0;
else if(strfind(name,"8",true) != (-1)) return 0;
else if(strfind(name,"9",true) != (-1)) return 0;
new maxname = strlen(name);
for(new i=0; i<maxname; i++)
{
if(name[i] == '_') underline ++;
}
if(underline != 1) return 0;
name[0] = toupper(name[0]);
for(new x=1; x<maxname; x++)
{
if(name[x] == '_') name[x+1] = toupper(name[x+1]);
else if(name[x] != '_' && name[x-1] != '_') name[x] = tolower(name[x]);
}
return 1;
}
pawn Код:
if(underline == 1)
{
//do something here which I just can't seem to crack
}