Register / Login system no loading stats
#1

Like the title says my register and login system is not loading STATS! please help!

Code:
public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
    ("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
    INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
    INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
    INI_Int("Money",pInfo[playerid][Money]); //As explained above
    INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
    INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
    INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
    return 1;
}
Code:
   if(dialogid == dlogin) //If dialog id is a login dialog
    {//then
        if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
        if(response) //if they clicked the first button "Register"
        {//then
            new hashpass[129]; //Will create a new variable to hash his/her password
            WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
            if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
            {//then
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
                SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
                GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
                SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
            }
            else //If they've entered an incorrect password
            {//then
                ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
                return 1;
            }
        }
    }
    return 1;
}
Please help guyz
Reply
#2

I am aware you used strcmp to check the password before you parsed the INI data.

You should parse the data first then compare passwords.
Reply
#3

Code:
public OnPlayerConnect(playerid)
{

    new name[MAX_PLAYER_NAME], string[23 + MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
    GetPlayerName(playerid,name,sizeof(name)); //Get player's name
    format(string, sizeof(string), "%s has joined the server", name);
    SendClientMessageToAll(0xFFFF00FF, string);
	if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
    {// then
        INI_ParseFile(Path(playerid),"loadaccount_user", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
    }
    else //If the connected user is not registered,
    {//then we will 'force' him to register :)
        ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
        return 1;
    }

    return 1;
}
!
Reply
#4

Add prints! Debug! Print out the both the result hashes, et cetera, and help yourself!
Reply
#5

superb advice
and i now know that
loadaccount is not being called
Code:
public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
    ("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
    INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
    INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
    INI_Int("Money",pInfo[playerid][Money]); //As explained above
    INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
    INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
    INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
    printf("lol"); //made it to printf
    return 1;
}
here is what i got from the log
Code:
[20:54:01] Incoming connection: 127.0.0.1:65060
[20:54:01] [join] superrobot48 has joined the server (0:127.0.0.1)
[20:54:09] [part] superrobot48 has left the server (0:1)
and it does not print lol, even when i logged in
SA-MP CHAT LOG
Code:
[20:56:55] {FFFFFF}SA-MP {B9C9BF}0.3z {FFFFFF}Started

[20:56:58] Connecting to 127.0.0.1:7777...

[20:56:58] Connected. Joining the game...

[20:56:59] superrobot48 has joined the server

[20:57:06] Connected to {B9C9BF}SA-MP 0.3 Server

[20:57:06] Welcome back! You have successfully logged in
and btw
Code:
#define true
Reply
#6

okay made it work by changing
Code:
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
to
Code:
INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
now am getting incorrect password
Reply
#7

Quote:
Originally Posted by superrobot48
View Post
okay made it work by changing
Code:
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
to
Code:
INI_ParseFile(Path(playerid),"loadaccount_user,.bExtra = true, .extra = playerid);//We will load his account's data from user's path
now am getting incorrect password
Code:
INI_ParseFile(Path(playerid),"loadaccount_user,.bExtra = true, .extra = playerid);//We will load his account's data from user's path
why you open a " " " and then you don't close it.. it is like you have a string text now..
Reply
#8

it was closed already i forgot it while postin here sorry
Reply
#9

fixed by changing
Code:
if(!strcmp(hashpass, pInfo[playerid][Pass], false) //If they have insert their correct password
to
Code:
if(strcmp(hashpass, pInfo[playerid][Pass], true)) //If they have insert their correct password
all thanks to Sweet <3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)