wrong pass
#1

Hello, i just finished my registration system with the help of some members around here, but got a problem.

Everything works except for the login, it says everytime "Wrong password" even if i put the CORRECT password:

pawn Код:
CMD:login(playerid, params[])
{
            new filestring[128];
            new name[24];
            GetPlayerName(playerid, name, 24);
            format(filestring, sizeof(filestring), "/Users/%s.ini", name);
            if(!fexist(filestring)) return SCM(playerid, COLOR_YELLOW, "You are not registered. Please /register.");
            new lpass[64];
            if(PlayerInfo[playerid][pLogged] == 1) return SCM(playerid, COLOR_YELLOW, "You are already logged in.");
            if(sscanf(params, "s[64]", lpass)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/login [password]");
            if(udb_hash(lpass) == PlayerInfo[playerid][pPass])
            {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    SetPlayerCash(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pKills]);
                    SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pRank]);
                    PlayerInfo[playerid][pLogged] += 1;
                    SCM(playerid,0x0080C0FF,"System: Account data loaded! Welcome back!");
            }
            else
            {
            SCM(playerid,0x0080C0FF,"System: Wrong password!");
            }
            return 1;
}
Reply
#2

INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

This load's the data.

You load it after comparing the passwords..

Put it OnPlayerConnect.

Also, use strcmp for comparing passwords.
Reply
#3

Like tyler set make it look like:

pawn Код:
CMD:login(playerid, params[])
{
            new filestring[128];
            new name[24];
            GetPlayerName(playerid, name, 24);
            format(filestring, sizeof(filestring), "/Users/%s.ini", name);
            if(!fexist(filestring)) return SCM(playerid, COLOR_YELLOW, "You are not registered. Please /register.");
            new lpass[64];
            if(PlayerInfo[playerid][pLogged] == 1) return SCM(playerid, COLOR_YELLOW, "You are already logged in.");
            if(sscanf(params, "s[64]", lpass)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/login [password]");
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
            if(udb_hash(lpass) == PlayerInfo[playerid][pPass])
            {
                    SetPlayerCash(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pKills]);
                    SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pRank]);
                    PlayerInfo[playerid][pLogged] += 1;
                    SCM(playerid,0x0080C0FF,"System: Account data loaded! Welcome back!");
            }
            else
            {
            SCM(playerid,0x0080C0FF,"System: Wrong password!");
            }
            return 1;
}
an i think it'll work
Reply
#4

Again udb...

Also
pawn Код:
if(!strcmp(udb_hash(Pass)), PlayerInfo[playerid][pPass])
{
    //do login
}
Reply
#5

Quote:
Originally Posted by Mr_DjolE
Посмотреть сообщение
Again udb...

Also
pawn Код:
if(!strcmp(udb_hash(Pass)), PlayerInfo[playerid][pPass])
{
    //do login
}
Argument mismatch.

Quote:
Originally Posted by HireMe
Посмотреть сообщение
Like tyler set make it look like:

pawn Код:
CMD:login(playerid, params[])
{
            new filestring[128];
            new name[24];
            GetPlayerName(playerid, name, 24);
            format(filestring, sizeof(filestring), "/Users/%s.ini", name);
            if(!fexist(filestring)) return SCM(playerid, COLOR_YELLOW, "You are not registered. Please /register.");
            new lpass[64];
            if(PlayerInfo[playerid][pLogged] == 1) return SCM(playerid, COLOR_YELLOW, "You are already logged in.");
            if(sscanf(params, "s[64]", lpass)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/login [password]");
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
            if(udb_hash(lpass) == PlayerInfo[playerid][pPass])
            {
                    SetPlayerCash(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pKills]);
                    SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pRank]);
                    PlayerInfo[playerid][pLogged] += 1;
                    SCM(playerid,0x0080C0FF,"System: Account data loaded! Welcome back!");
            }
            else
            {
            SCM(playerid,0x0080C0FF,"System: Wrong password!");
            }
            return 1;
}
an i think it'll work
Sometimes it works and sometimes not. I get "unknown command" at /register and /login sometimes.

I think
pawn Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
is bugged, i tried to add on OnPlayerConnect but both register and login cmds wasn't working.
Reply
#6

Try chaning _%s to _user
Reply
#7

Quote:
Originally Posted by tyler12
Посмотреть сообщение
Try chaning _%s to _user
Same. "Wrong password!" - I was thinking to make a stock instead of Loaduser. What do you think?
Reply
#8

HERE, HERE, and HERE

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Sometimes it works and sometimes not. I get "unknown command" at /register and /login sometimes.

I think
pawn Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
is bugged, i tried to add on OnPlayerConnect but both register and login cmds wasn't working.
DON'T SHOOT THE CODE! It does what YOU tell it to do, NOTHING IS BUGGED.
Reply
#9

Quote:
Originally Posted by Gh05t_
Посмотреть сообщение
HERE, HERE, and HERE



DON'T SHOOT THE CODE! It does what YOU tell it to do, NOTHING IS BUGGED.
You dont need to teach me how to open ******!

That code is bugged, FOR ME!

I tested now with fexist and fopen AND IT'S WORKING, SO DONT TELL "NOTHING IS BUGGED" WHEN YOU HAVEN'T TESTED IT.
Reply
#10

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
You dont need to teach me how to open ******!
Not only must you be taught how to open ******, you must be taught how to use INTERNET. You come here almost every day with the SAME issue and constantly whine and bitch, when you yourself have made no effort, no attempt WHAT-SO-EVER to even DEBUG YOUR CODE.

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
That code is bugged, FOR ME!
The code is NOT bugged for you good sir! You just don't know what you're doing! Does a baby walk without learning to crawl first?


Quote:
Originally Posted by Logitech90
I tested now with fexist and fopen AND IT'S WORKING, SO DONT TELL "NOTHING IS BUGGED" WHEN YOU HAVEN'T TESTED IT.
Of course fexist work, taking an example from the wiki is MUCH more easy than trying to understand the code itself! Say, since fexist and fopen works use THAT instead of y_ini (it's seemingly low level functions that provide "WAAY simpler abstractions from input and output"hint:*sarcasm*)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)