unexplained bug again...
#1

Hello, I have this function:

pawn Код:
stock STOCK_InvalidMainName(str[])
{
    for(new c = 0; c < sizeof(ARY_INVALID_CHARACTERS); c++)
    {
        if(strfind(str, ARY_INVALID_MAIN_CHARACTERS[c], true) != -1)
        {
            return true;
        }
    }
    for(new n = 0; n < sizeof(ARY_INVALID_NAME_PARTS); n++)
    {
        if(strfind(str, ARY_INVALID_NAME_PARTS[n], true) != -1)
        {
            return true;
        }
    }
    return false;
}
Which is used in this:
pawn Код:
case DEF_DIALOG_REGISTER: // MAIN ACCOUNT NAME
        {
            if(!response) return FUNCTION_RegisterDialog(playerid,0);
            if(!STOCK_InvalidMainName(inputtext))
            {
                // IT DOESN'T REACH THIS POINT. IF THE STOCK IS FALSE ELSE IT RETURNS THE CORRECT ERROR>
                if(strlen(inputtext) <= 16 && strlen(inputtext) >= 4)
                {

                        Escape(inputtext);
                       
                        //STOCK_PlayerDebug(playerid,"[DEBUG] %s",p[VAR_CHAR_ESCAPED]);
                        format(p[VAR_CHAR_STRING],STR_MEDIUM,"SELECT * FROM `plr_account` WHERE `MAIN_NAME` = '%s'",p[VAR_CHAR_ESCAPED]);
                        mysql_function_query(VAR_SQL_CONNECTION, p[VAR_CHAR_STRING], true, "FUNCTION_NameExist", "id", playerid,0);

                } else return FUNCTION_RegisterDialog(playerid,0), FUNCTION_PlayerError(playerid,6);
            } else return FUNCTION_RegisterDialog(playerid,0), FUNCTION_PlayerError(playerid,5);
        }
If the stock returns false, there where no invalid characters found, but it jjust doesn't ahead with the rest of it .
if(!STOCK_InvalidMainName(inputtext))
{
It doesn't come here when it is false.?

Somebody know how to fix this mistery because I get stressed again lol.

PS: some time ago it work perfect, and suddenly it fails...
Reply
#2

I'd rather check for valid characters instead of invalid characters, for the valid characters only include a-z, A-Z and maybe the underscore.
Reply
#3

Yea not a bad idea, but I found the bug, the sizeof() of the first loop belongs to another array lol, so I think it keept looping...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)