Whats Wrong ?
#1

Hi guys I make a login register system It was working perfect When I set PInfo,pass as a int but now I change it to string
and its not getting right str and saving "Wrong pass"

pawn Код:
enum pInfo
{
 Password[255],
 pAdminLevel,
 pScore,
 pCash,
 pLPrice,
};

pawn Код:
if(dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext))return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
        PlayerInfo[playerid][Password] = dini_Get(file,"Password");
        if(udb_hash(inputtext) != PlayerInfo[playerid][Password])
        {
            SendClientMessage(playerid,RED,"Sorry Wrong Password!");
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
        }
        else
        {
            OnLogin(playerid, inputtext);
        }
    }

    return 1;
}
Reply
#2

Always use strcmp for string:
Код:
if(strcmp(udb_hash(inputtext),PlayerInfo[playerid][Password]),false))
Go to wiki to know more.
Reply
#3

Don't forget that it returns 0 if one string is empty though
Reply
#4

Something like this, try not to get into a habbit of using strlen for simple things like this !

pawn Код:
if(dialogid == 2)
    {
        new
            name[MAX_PLAYER_NAME], file[50], tmp[50];

        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);

        if(!response) return Kick(playerid);

        // Your previous example used strlen, which loops around every character in the string until it finds the '\0' escape character
        // To check if there's no input, simply check if the first character is not a valid character, thus it must be '\0'.
        // This is much quicker than checking all characters, when you only want to check if there is a character, if there is text, the first character will not be '\0'.

        if(!inputtext) return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");

        format(tmp, sizeof(tmp), "%s", dini_Get(file, "Password"));
        format(PlayerInfo[playerid][Password], 50, "%s", tmp);

        if(udb_hash(inputtext) != PlayerInfo[playerid][Password])
        {
            SendClientMessage(playerid,RED,"Sorry Wrong Password!");
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
            return 1;
        }
       
        OnLogin(playerid, inputtext);
        return 1;
    }
   
    // Other dialogs
    return 0;
}
Reply
#5

Quote:
Originally Posted by Joe_
Посмотреть сообщение
Something like this, try not to get into a habbit of using strlen for simple things like this !

pawn Код:
if(dialogid == 2)
    {
        new
            name[MAX_PLAYER_NAME], file[50], tmp[50];

        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);

        if(!response) return Kick(playerid);

        // Your previous example used strlen, which loops around every character in the string until it finds the '\0' escape character
        // To check if there's no input, simply check if the first character is not a valid character, thus it must be '\0'.
        // This is much quicker than checking all characters, when you only want to check if there is a character, if there is text, the first character will not be '\0'.

        if(!inputtext) return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");

        format(tmp, sizeof(tmp), "%s", dini_Get(file, "Password"));
        format(PlayerInfo[playerid][Password], 50, "%s", tmp);

        if(udb_hash(inputtext) != PlayerInfo[playerid][Password])
        {
            SendClientMessage(playerid,RED,"Sorry Wrong Password!");
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
            return 1;
        }
       
        OnLogin(playerid, inputtext);
        return 1;
    }
   
    // Other dialogs
    return 0;
}
Oh thanks I got idea about it.....
Reply
#6

Quote:
Originally Posted by Joe_
Посмотреть сообщение
Something like this, try not to get into a habbit of using strlen for simple things like this !

pawn Код:
if(dialogid == 2)
    {
        new
            name[MAX_PLAYER_NAME], file[50], tmp[50];

        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);

        if(!response) return Kick(playerid);

        // Your previous example used strlen, which loops around every character in the string until it finds the '\0' escape character
        // To check if there's no input, simply check if the first character is not a valid character, thus it must be '\0'.
        // This is much quicker than checking all characters, when you only want to check if there is a character, if there is text, the first character will not be '\0'.

        if(!inputtext) return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");

        format(tmp, sizeof(tmp), "%s", dini_Get(file, "Password"));
        format(PlayerInfo[playerid][Password], 50, "%s", tmp);

        if(udb_hash(inputtext) != PlayerInfo[playerid][Password])
        {
            SendClientMessage(playerid,RED,"Sorry Wrong Password!");
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
            return 1;
        }
       
        OnLogin(playerid, inputtext);
        return 1;
    }
   
    // Other dialogs
    return 0;
}
Not getting right pass "Sorry Wrong Password!".......
Reply
#7

I got it Working ....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)