Password.
#1

The password problem has been fixed, the fix has been posted.
Reply
#2

How does this even compile without errors!?
pawn Code:
if(!strcmp(udb_hash(inputtext),PlayerInfo[playerid][pPass]))
                {
//code
                }
Use strcmp to compare 2 strings. I think this was the problem here.

Complete code:
pawn Code:
case DIALOG_LOGIN:
        {
            if (!response) return Kick (playerid);
            if(response)
            {
                if(!strcmp(udb_hash(inputtext),PlayerInfo[playerid][pPass]))
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pWanted]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"Invalid Password!\n"COL_WHITE"Type Your Password Below To Login","Login","Leave");
                }
                return 1;
            }
        }
    }
    return 1;
}
EDIT: thanks for the info Konstantinos, learned something new I guess
Reply
#3

Quote:
Originally Posted by Jstylezzz
View Post
How does this even compile without errors!?
udb_hash returns an integer so he compares it correctly. The problem most likely is on the loading part of the password so you can debug it to be sure:
pawn Code:
printf("udb_hash->inputtext: %i & pPass: %i", udb_hash(inputtext), PlayerInfo[playerid][pPass]);
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
Try again and post what it prints in the console/server log.
Reply
#4

This is what I get.
Quote:

[22:00:47] udb_hash->inputtext: 73204161 & pPass: 0

Reply
#5

That means that your password is not loading correctly.
Reply
#6

Umm, do you know how to fix it? I have no idea.
Reply
#7

You're loading the dude's data after he has logged in. You should do it once he connects to the server and after you verify that his account is actually registered.

Code:
public OnPlayerConnect( playerid )
{
	if(fexist(UserPath(playerid))) // If the account exists.
	{
	    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

	    //Show login dialog.
	}
	else
	{
		//Show register dialog.
	}
}
Now you can continue on with what you were doing. I'd also recommend you to use a better hashing method like Whirlpool.
Reply
#8

I have that in OnPlayerConnect.
pawn Code:
if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login","Login","Leave");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Register",""COL_WHITE"Type your password below to register","Register","Leave");
    }
Reply
#9

Okay, could you please show me your "LoadUser_data" public?
Reply
#10

pawn Code:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    // And the rest...
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)