MySQL Register and Login problem
#1

Hi..
I changed my script to mysql but it doesn't work how it should...

OnPlayerCommandText:
pawn Код:
format(dat, sizeof(dat), "SELECT * FROM `User` WHERE `Name`='%s'", name);
    mysql_query(dat);
    mysql_store_result();
    if(!mysql_num_rows())
    {
        ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Registration", "Welcome to [HSA]Sgt's SA Heaven!\r\n\
        As your name is not registered in our Database yet, you\r\nhave to register before you can start playing.\r\n\
        Please enter the password you want to use below.\r\nIf you'd like to take another name click \"Quit\""
, "Continue", "Quit");
    }else{
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "Welcome Back to [HSA]Sgt's SA Heaven!\r\n\
        Your username is already registered in the HSA DataBase,\r\ntherefore please enter your password below\r\n\
        to start playering.\r\nIf this is not your account use\"Quit\" and take another name."
, "Login", "Quit");
    }
    mysql_free_result();
... if I enter, it always shows the login dialog -.-...

Login Dialog (part of):
pawn Код:
new dat[500], string[256], date[50], day, month, year, ip[40], tmp[50];
            GetPlayerName(playerid, name, sizeof(name));
            format(dat, sizeof(dat), "SELECT * From `User` WHERE `Name`='%s' AND `Password`='md5('%s')", name, inputtext);
            mysql_query(dat);
            mysql_store_result();
            if(mysql_num_rows())
            {
                mysql_get_field("Level", tmp);
                PlayerData[playerid][Level] = strval(tmp);
                mysql_get_field("Score", tmp);
                SetPlayerScore(playerid, strval(tmp));
                mysql_get_field("Money", tmp);
                SetPlayerMoney(playerid, strval(tmp));
                GetPlayerIp(playerid, ip, sizeof(ip));
                getdate(year, month, day);
                format(date, sizeof(date), "%d/%d/%d", day, year, month);
                format(dat, sizeof(dat), "UPDATE `User` SET `LoginDate`='%s', `LoginIP`='%s' (WHERE `Name=`='%s')", date, ip, name);
                mysql_query(dat);
I can always login, doesn't care whether the pass was wrong or not... and when i login it doesn't save the Level, etc. in the variables...

(gstyle's plugin)

EDIT:
I changed OnPlayerConnect to
pawn Код:
if(mysql_num_rows() >= 1){
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "Welcome Back to [HSA]Sgt's SA Heaven!\r\n\
        Your username is already registered in the HSA DataBase,\r\ntherefore please enter your password below\r\n\
        to start playering.\r\nIf this is not your account use\"Quit\" and take another name."
, "Login", "Quit");
    }else
    {
        ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Registration", "Welcome to [HSA]Sgt's SA Heaven!\r\n\
        As your name is not registered in our Database yet, you\r\nhave to register before you can start playing.\r\n\
        Please enter the password you want to use below.\r\nIf you'd like to take another name click \"Quit\""
, "Continue", "Quit");
    }
however now it always askes me to register -.-
Reply


Messages In This Thread
MySQL Register and Login problem - by Sascha - 16.01.2011, 13:50
Re: MySQL Register and Login problem - by Anthonyx3' - 16.01.2011, 14:46
Re: MySQL Register and Login problem - by hanzen - 16.01.2011, 15:11
Re: MySQL Register and Login problem - by Sascha - 16.01.2011, 15:20
Re: MySQL Register and Login problem - by hanzen - 16.01.2011, 15:39
Re: MySQL Register and Login problem - by Anthonyx3' - 16.01.2011, 16:40
Re: MySQL Register and Login problem - by Typhome - 16.01.2011, 16:48
Re: MySQL Register and Login problem - by Sascha - 16.01.2011, 17:28

Forum Jump:


Users browsing this thread: 1 Guest(s)