Works the first time, not the second
#1

pawn Код:
case DIALOG_CREATE_PASSWORD:
        {
            if(!response || isnull(inputtext)) return ClearChat(playerid), SendClientMessage(playerid, COLOR_RED, "Notice: You have been kicked as you did not want to register.  You may rejoin at anytime!"), Kick(playerid);
            if(response)
            {
                if(strlen(inputtext) < 4 || strlen(inputtext) > 21) return SendClientMessage(playerid, COLOR_LIGHTRED, "Your password cannot have more than 20 letters/numbers or less than 4 letters/numbers"), ShowPlayerDialog(playerid, DIALOG_CREATE_PASSWORD, DIALOG_STYLE_PASSWORD, "Create a Password", "Pleae create a secure password.  Your password must be between 4-20 characters.", "Next", "Cancel");
                else
                {
                    strcat(TempPassword[playerid], inputtext, sizeof(TempPassword));
                    SendClientMessage(playerid, COLOR_WHITE, "Great, now please confirm your password!"), ShowPlayerDialog(playerid, DIALOG_CREATE_PASSWORD_CONFIRM, DIALOG_STYLE_PASSWORD, "Confirm your Password", "Please confirm that you know your password.  If you cannot enter it as before, you will need to recreate one", "Next", "Cancel");
                }
            }
        }
        case DIALOG_CREATE_PASSWORD_CONFIRM:
        {
            if(!response || isnull(inputtext)) return ClearChat(playerid), SendClientMessage(playerid, COLOR_RED, "Notice: You have been kicked as you did not want to register.  You may rejoin at anytime!"), Kick(playerid);
            if(response)
            {
                if(!strcmp(inputtext, TempPassword[playerid], false))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "Okay, great!  Now enter a valid email address.  We will only contact you if it is nessessary.");
                    new buffer[129];
                    WP_Hash(buffer, sizeof(buffer), inputtext);
                    pInfo[playerid][pPassword] = buffer;
                    ShowPlayerDialog(playerid, DIALOG_SET_EMAIL, DIALOG_STYLE_INPUT, "Email Address", "Please enter a valid email address so we can contact you in the future.  We may contact you about administrative actions or server news!", "Next", "Close");
                }
                else
                {
                    SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: The passwords did not match.  Please recreate your password!");
                    ShowPlayerDialog(playerid, DIALOG_CREATE_PASSWORD, DIALOG_STYLE_PASSWORD, "Create a Password", "Pleae create a secure password.  Your password must be between 4-20 characters.", "Next", "Cancel");
                }              
            }
        }
The above is my code, TempPassword[MAX_PLAYERS] is defined globally.

It works as designed if both passwords match the first time, but if you screw up it will always give you the else statement even if they match on the confirm password dialog.

Any ideas?
Reply
#2

I took out [playerid] from the TempPassword variable however it is still having hte issue.
Reply
#3

It's because you use strcat without clearing the string's contents. You will end up with random stuff that's glued together. Would've been very easy to spot, if you'd just learn how to debug.

Use an implentation of strcpy:
pawn Код:
stock strcpy(dest[], const source[], maxlength=sizeof dest)
    strcat((dest[0] = EOS, dest), source, maxlength);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)