A bug ..
#1

Hey guys, the bug is when the player registers it saves the password okay? but when he comes to log-in, it doesn't read his password .. he can type any password and just log-in and even without logging in his stats can be loaded, so

here are my /login and /register commands (I converted them from Dialogs to commands)

pawn Код:
CMD:login(playerid, params[])
{
    //if(PlayerInfo[playerid][pPass] == playerpassword
    //new tmp;
    //new INI:File = INI_Open(UserPath(playerid));
   
    //tmp = INI_Int(File,"Password",PlayerInfo[playerid][pPass]);
    if(sscanf(params,"s[128]",playerpassword)) return SendClientMessage(playerid, COLOR_ORANGE,"[REGISTRATION]/login <password>");
    if(strcmp(PlayerInfo[playerid][pPass],playerpassword,true))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
        SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED,""#COL_RED"You've entered a wrong password, try again!");
    }
    return 1;
}

CMD:register(playerid, params[])
{
    if(sscanf(params,"s[128]",playerpassword)) return SendClientMessage(playerid, COLOR_ORANGE,"[REGISTRATION]/register <password>");
   
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,".:-{ Player's Data }-:.");
    INI_WriteString(File,"Password", playerpassword);
    INI_WriteInt(File,"Cash",0);
    INI_WriteInt(File,"Admin",-1);
    INI_WriteInt(File,"Kills",0);
    INI_WriteInt(File,"Deaths",0);
    INI_WriteInt(File,"Zombie",0);
    INI_WriteInt(File,"Score",1);
    INI_WriteInt(File,"Team",-1);
    INI_Close(File);

    PlayerInfo[playerid][pTeam] = -1;
    PlayerInfo[playerid][pAdmin] = -1;
   
    SavePlayerStats(playerid);
    SendClientMessage(playerid, COLOR_ORANGE, "Congratulations! You have registered yourself and we're happy to have you here!");
    SendClientMessage(playerid, COLOR_RED,""#COL_GREEN"Type /starter for your starter pack.");
    return 1;
}
Reply
#2

Im sure
pawn Код:
if(strcmp(PlayerInfo[playerid][pPass],playerpassword,true))
Should be
pawn Код:
if(!strcmp(PlayerInfo[playerid][pPass],playerpassword,true))
Код:
Returns	-1 if string1 comes before string2
1 if string1 comes after string2
0 if the strings are the same (for the matched length).
Код:
Important Note: This function also returns 0 if either string is empty.
Reply
#3

So all I have to add now is the "!" ..?

Edit:

Nothing .. the problem is still the same.
Reply
#4

Quote:
Originally Posted by Guitar
Посмотреть сообщение
So all I have to add now is the "!" ..?
That should work.

EDIT:try
pawn Код:
if(strcmp(playerpassword,PlayerInfo[playerid][pPass],true))
Reply
#5

Nope nothing :S
Reply
#6

pawn Код:
if(strcmp(PlayerInfo[playerid][pPass],playerpassword) == 0) // make sure the array "PlayerInfo[playerid][pPass]" contains the password which is located at player file's.
about the command register, it will restart the stats of player that uses it, even being already registered, you should add another statement to prevent this.
Reply
#7

The password is there, and yup I will be making something like status ..
Now the log-in cmd is like this:

pawn Код:
CMD:login(playerid, params[])
{
    if(PlayerInfo[playerid][pReg] == 1)
    {
        if(sscanf(params,"s[128]",playerpassword)) return SendClientMessage(playerid, COLOR_ORANGE,"[REGISTRATION]/login <password>");
        if(strcmp(PlayerInfo[playerid][pPass],playerpassword) == 0)
        {
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
            GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED,""#COL_RED"You've entered a wrong password, try again!");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_ORANGE,"[REGISTRATION]/register <password>");
    }
    return 1;
}
and my register

pawn Код:
CMD:register(playerid, params[])
{
    if(PlayerInfo[playerid][pReg] == 0)
    {
        if(sscanf(params,"s[128]",playerpassword)) return SendClientMessage(playerid, COLOR_ORANGE,"[REGISTRATION]/register <password>");
   
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,".:-{ Player's Data }-:.");
        INI_WriteString(File,"Password", playerpassword);
        INI_WriteInt(File,"Cash",0);
        INI_WriteInt(File,"Admin",-1);
        INI_WriteInt(File,"Kills",0);
        INI_WriteInt(File,"Deaths",0);
        INI_WriteInt(File,"Zombie",0);
        INI_WriteInt(File,"Score",1);
        INI_WriteInt(File,"Team",-1);
        INI_WriteInt(File,"Registered",1);
        INI_Close(File);

        PlayerInfo[playerid][pTeam] = -1;
        PlayerInfo[playerid][pAdmin] = -1;
        PlayerInfo[playerid][pReg] = 1;

        SavePlayerStats(playerid);
        SendClientMessage(playerid, COLOR_ORANGE, "Congratulations! You have registered yourself and we're happy to have you here!");
        SendClientMessage(playerid, COLOR_RED,""#COL_GREEN"Type /starter for your starter pack.");
    }
    else if(PlayerInfo[playerid][pReg] == 1)
    {
        SendClientMessage(playerid, COLOR_GREEN,"You're already a member here, you can't use this command again.");
    }
    return 1;
}
I haven't tested them yet, I'm going now.

EDIT EDIT EDIT: something wrong now with the pLogged

pawn Код:
CMD:login(playerid, params[])
{
    if(PlayerInfo[playerid][pLogged] == 1)
    {
        if(PlayerInfo[playerid][pReg] == 1)
        {
            if(sscanf(params,"s[128]",playerpassword)) return SendClientMessage(playerid, COLOR_ORANGE,"[REGISTRATION]/login <password>");
            if(strcmp(PlayerInfo[playerid][pPass],playerpassword) == 0)
            {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                PlayerInfo[playerid][pLogged] = 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED,""#COL_RED"You've entered a wrong password, try again!");
            }
        }
        else if(PlayerInfo[playerid][pReg] == 0)
        {
            SendClientMessage(playerid, COLOR_ORANGE, "Please type /register to register your account.");
        }
    }
    else if(PlayerInfo[playerid][pLogged] == 0)
    {
        SendClientMessage(playerid, COLOR_ORANGE,"Please log into your account first, /login");
    }
    return 1;
}
    //if(PlayerInfo[playerid][pPass] == playerpassword
    //new tmp;
    //new INI:File = INI_Open(UserPath(playerid));

    //tmp = INI_Int(File,"Password",PlayerInfo[playerid][pPass]);

CMD:register(playerid, params[])
{
    if(PlayerInfo[playerid][pReg] == 0)
    {
        if(sscanf(params,"s[128]",playerpassword)) return SendClientMessage(playerid, COLOR_ORANGE,"[REGISTRATION]/register <password>");
   
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,".:-{ Player's Data }-:.");
        INI_WriteString(File,"Password", playerpassword);
        INI_WriteInt(File,"Cash",0);
        INI_WriteInt(File,"Admin",-1);
        INI_WriteInt(File,"Kills",0);
        INI_WriteInt(File,"Deaths",0);
        INI_WriteInt(File,"Zombie",0);
        INI_WriteInt(File,"Score",1);
        INI_WriteInt(File,"Team",-1);
        INI_WriteInt(File,"Registered",1);
        INI_WriteInt(File,"Logged",1);
        INI_Close(File);
       
        PlayerInfo[playerid][pLogged] = 1;
        PlayerInfo[playerid][pTeam] = -1;
        PlayerInfo[playerid][pAdmin] = -1;
        PlayerInfo[playerid][pReg] = 1;

        SavePlayerStats(playerid);
        SendClientMessage(playerid, COLOR_ORANGE, "Congratulations! You have registered yourself and we're happy to have you here!");
        SendClientMessage(playerid, COLOR_RED,""#COL_GREEN"Type /starter for your starter pack.");
    }
    else if(PlayerInfo[playerid][pReg] == 1)
    {
        SendClientMessage(playerid, COLOR_GREEN,"You're already a member here, you can't use this command again.");
    }
    return 1;
}
What is it?
Reply
#8

The PlayerInfo[playerid][pLogged] == 1 should be 0 right? so if they havent logged in, they have to login, allso the PlayerInfo[playerid][pLogged] == 0, should be 1?
Reply
#9

My mind is closed now man, because no matter what I do, the original problem will still be existing, which is you can type any password to log in .
Reply
#10

i don't know exactly how to make it but i guess you need to open the Password File (File,"Password", playerpassword) and check if the password written by the player is the same inside it. check some tutorials
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)