What am I missing?
#1

There's something wrong with this code, but i'm just overseeing it. It's giving me an invalid password error, even if the password is correct; Here is the code:

pawn Код:
else if(dialogid == DIALOG_JOIN)
    {
        if(response)
        {
            new string2[256];
            format(string, sizeof(string), "Welcome to %s | V: %s!", SCRIPT_MODE, SCRIPT_VERSION);
            format(string2, sizeof(string2), "In order to play on our server, we require you create an account.\nYou may be asking yourself, why do I have to create an account? The answer would be: Security.\nWe strive to provide a completely secure SA:MP experience! Please enter a password below:");

            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_JOIN, DIALOG_STYLE_INPUT, string, string2, "Join", "Leave");

            new INI:File = INI_Open(FindUserPath(playerid));
            new plrIP[16];
            GetPlayerIp(playerid, plrIP, sizeof(plrIP));
           
            INI_SetTag(File,"DATA");
            INI_WriteInt(File,"Password", udb_hash(inputtext));
            INI_WriteString(File, "IP", plrIP);
            INI_WriteInt(File,"Money", 0);
            INI_WriteInt(File,"AuthLevel", 0);
            INI_WriteInt(File,"Kills", 0);
            INI_WriteInt(File,"Deaths", 0);
            INI_Close(File);
           
            SetSpawnInfo(playerid, 0, 119, 0, 0, 0, 0, 24, 99999, 31, 99999, 34, 99999);
            SpawnPlayer(playerid);
           
        }
        else
        {
            SendClientMessage(playerid, COLOR_SUCCESSFUL, "[System] You have been booted from the server. (Clicked \"Leave\" or closed the dialog!)");
            return Kick(playerid);
        }
    }
    else if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            if(udb_hash(inputtext) == UserInfo[playerid][Password])
            {
                INI_ParseFile(FindUserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                format(string, sizeof(string), "AuthLevel: %d", UserInfo[playerid][AuthLevel]);
                SendClientMessage(playerid, -1, string);
                return 1;
            }
            else
            {
                SendClientMessage(playerid, -1, "Invalid Password!");
                return 1;
            }
        }
        return 1;
    }
Reply
#2

pawn Код:
if(udb_hash(inputtext) == UserInfo[playerid][Password])
Should be:

pawn Код:
if(!strcmp(udb_hash(inputtext), UserInfo[playerid][Password], false))
Reply
#3

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
pawn Код:
if(udb_hash(inputtext) == UserInfo[playerid][Password])
Should be:

pawn Код:
if(!strcmp(udb_hash(inputtext), UserInfo[playerid][Password], false))
Quote:

error 035: argument type mismatch (argument 1)

Same line you posted above, the hash is an integer.
Reply
#4

Quote:
Originally Posted by Scarred
Посмотреть сообщение
Same line you posted above, the hash is an integer.
Okay, but you can't do the thing you currently have because "UserInfo[playerid][Password]" is a string, correct?
Reply
#5

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Okay, but you can't do the thing you currently have because "UserInfo[playerid][Password]" is a string, correct?
"Password" in the enum is actually an integer, sadly, I'm flawed when it comes to Y_INI, and I can't figure out how to create password as a string properly, and the tutorial I'm looking at is wrong, I'm assuming.

However, I have switched "Password" over to a string in the enum, and changed my code around a bit; Let me test it, and I will edit my post/reply to this thread if it works or not. Give me about a minute.


EDIT: Alright, after switching my "Password" to a string in every bit of code, I'm getting a different action now. It's logging me in now, even if the password is incorrect. The correct password is "hello", I type in "1" as the password, and it automatically logs me in, when it is obviously not the password.

The password-checking code is:

pawn Код:
if(!strcmp(inputtext, UserInfo[playerid][Password], false))
I took out the hashing of the passwords, but still, I don't see what's wrong.

EDIT2: I changed the password-checking code to the following -

pawn Код:
if(strcmp(inputtext, UserInfo[playerid][Password], true))
and now every single password reads as invalid. I'm honestly getting quite confused by this considering it SHOULD be working. (within my logic, atleast)
Reply
#6

Quote:
Originally Posted by Scarred
Посмотреть сообщение
"Password" in the enum is actually an integer, sadly, I'm flawed when it comes to Y_INI, and I can't figure out how to create password as a string properly, and the tutorial I'm looking at is wrong, I'm assuming.

However, I have switched "Password" over to a string in the enum, and changed my code around a bit; Let me test it, and I will edit my post/reply to this thread if it works or not. Give me about a minute.


EDIT: Alright, after switching my "Password" to a string in every bit of code, I'm getting a different action now. It's logging me in now, even if the password is incorrect. The correct password is "hello", I type in "1" as the password, and it automatically logs me in, when it is obviously not the password.

The password-checking code is:

pawn Код:
if(!strcmp(inputtext, UserInfo[playerid][Password], false))
I took out the hashing of the passwords, but still, I don't see what's wrong.

EDIT2: I changed the password-checking code to the following -

pawn Код:
if(strcmp(inputtext, UserInfo[playerid][Password], true))
and now every single password reads as invalid. I'm honestly getting quite confused by this considering it SHOULD be working. (within my logic, atleast)
Determine what "UserInfo[playerid][Password]" is, try doing this:

pawn Код:
print(UserInfo[playerid][Password]);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)