Help with password checking.
#1

First time I've built a user system (I did use a tutorial but it was a shit one). I can't get it to check if the entered text is the same as the password... sounds noobish but meh.

pawn Код:
OnPlayerLogin(playerid, password[])
{
    new
        hashPassword[129],
        uFile[35];

    format(uFile, 35, "%s.ini", PlayerName(playerid));

    INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);

    WP_Hash(hashPassword, 129, password);
    if(PlayerInfo[playerid][pBanned] == 1)
    {
        new banreason = PlayerInfo[playerid][pBanReason];
        new string[128];
        format(string, sizeof(string), "%s", banreason);
        SendClientMessage(playerid, COLOR_LIGHTRED, "This account has been banned:");
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        Kick(playerid);
        return 0;
    }
    if(WP_Hash(hashPassword, 129, password) == PlayerInfo[playerid][pPassword])
    {
        SendClientMessage(playerid, COLOR_ORANGE, "You've logged into Los Santos Gang Wars!");
        SetPVarInt(playerid, "Logged", 1);
    }
    else
    {
        SendClientMessage(playerid, COLOR_ORANGE, "Error: wrong password entered, you've been kicked.");
        Kick(playerid);
    }
    return 1;
}
I get no errors or anything, it compiles fine, but it keeps kicking me, even if the passwords right.
Reply
#2

Nothing wrong with this line...

Removed

EDIT: Saw your post below sorry dont know what WP hash is so im doing research as im looking for problems
Reply
#3

Quote:
Originally Posted by IceCube!
Посмотреть сообщение
if(WP_Hash(inputtext) == PlayerInfo[playerid][pPassword])

try this

Edit wait thats for udb_hash not sure if its the same let do do a bit of research...

Although if the abouve works let me know
Nah, doesn't work. I also get warnings with it:
Код:
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
Reply
#4

Ok i cant see anything wrong with the code aboe how are you saving the password? although ill keep looking through it


Plus this probs isnt the place to ask but is there any major differnce between WP_hash and udb_hash?
Reply
#5

This is how I'm saving the password:
pawn Код:
OnPlayerRegister(playerid, password[])
{
    new
        hashPassword[129],
        uFile[35];

    format(uFile, 35, "%s.ini", PlayerName(playerid));

    new
        INI:playerFile = INI_Open(uFile);

    WP_Hash(hashPassword, 129, password);

    INI_WriteString(playerFile, "Password", hashPassword);
    INI_WriteInt(playerFile, "Admin", 0);
    INI_WriteInt(playerFile, "VIP", 0);
    INI_WriteInt(playerFile, "Money", 500);
    INI_WriteInt(playerFile, "Score", 0);
    INI_WriteInt(playerFile, "Kills", 0);
    INI_WriteInt(playerFile, "Deaths", 0);
    INI_WriteInt(playerFile, "Online", 0);
    INI_WriteInt(playerFile, "Banned", 0);
    INI_WriteString(playerFile, "BanReason", PlayerInfo[playerid][pBanReason]);

    INI_Close(playerFile);

    SetPVarInt(playerid, "Registered", 1);
    SetPVarInt(playerid, "Logged", 1);
    return 1;
}
That's called after someone finishes with the register dialog.
Reply
#6

Right this might be a bit annoying for you but i dont have a clue what WP_Hash is so i cant really help but i may be able to help if you change your stock to udb_hash

If you are willing to do this replace the WP_Hash stock with

pawn Код:
stock udb_hash(buf[])
{
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
and replace

this
pawn Код:
if(WP_Hash(hashPassword, 129, password) == PlayerInfo[playerid][pPassword])
with this

pawn Код:
if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
and this

pawn Код:
WP_Hash(hashPassword, 129, password);
     INI_WriteString(playerFile, "Password", hashPassword);
with this

pawn Код:
INI_WriteInt(File,"Password",udb_hash(inputtext));
and so on sorry but i dont know the things for WP and i cant find anything about it

also ****** has his own tutorial?

or you can wait for somone else to reply... (who understands WP_Hash)

also i found a better tutorial for you if this helps

https://sampforum.blast.hk/showthread.php?tid=273088

EDIT: Youve replyed to this tutorial... im guessing this isnt the one you used or is it?
Reply
#7

Quote:
Originally Posted by IceCube!
Посмотреть сообщение
Right this might be a bit annoying for you but i dont have a clue what WP_Hash is so i cant really help but i may be able to help if you change your stock to udb_hash

If you are willing to do this replace the WP_Hash stock with

pawn Код:
stock udb_hash(buf[])
{
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
and replace

this
pawn Код:
if(WP_Hash(hashPassword, 129, password) == PlayerInfo[playerid][pPassword])
with this

pawn Код:
if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
and this

pawn Код:
WP_Hash(hashPassword, 129, password);
     INI_WriteString(playerFile, "Password", hashPassword);
with this

pawn Код:
INI_WriteInt(File,"Password",udb_hash(inputtext));
and so on sorry but i dont know the things for WP and i cant find anything about it

also ****** has his own tutorial?

or you can wait for somone else to reply... (who understands WP_Hash)

also i found a better tutorial for you if this helps

https://sampforum.blast.hk/showthread.php?tid=273088

EDIT: Youve replyed to this tutorial... im guessing this isnt the one you used or is it?
I never used that tutorial nope, I tried what you told me to do, then tried the tutorial, it still didn't work. I'll have to re-do my registration system, then I'll let you know, thanks
Reply
#8

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
I never used that tutorial nope, I tried what you told me to do, then tried the tutorial, it still didn't work. I'll have to re-do my registration system, then I'll let you know, thanks
Ok im etremely sorry i couldnt help you but i hope this tutorial goes better for you

Quote:
Originally Posted by 4ir-W4ys
Посмотреть сообщение
Just Get yourself Another Login Register System...
I'll Help you with diractions...
This is The Bestest Login Register System i ever seen:
Login, Register, Rank
How meny times have you been told to get a life on these forums now plus explain to me how that is helpful
Reply
#9

I don't like to user Filterscripts.

Okay so anyone who's willing to help me instead of telling me to do it the quick and easy way, here's what I've now got:

My dialogs:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(response)
            {
                new
                    strText[179];

                if(strlen(inputtext) >= 4 && strlen(inputtext) <= 35)
                {
                    new
                    uFile[35];
                    format(uFile, 35, "%s.ini", PlayerName(playerid));
                    new
                    INI:playerFile = INI_Open(uFile);
                    INI_WriteInt(playerFile, "Password",udb_hash(inputtext));
                    INI_WriteInt(playerFile, "Admin", 0);
                    INI_WriteInt(playerFile, "VIP", 0);
                    INI_WriteInt(playerFile, "Money", 500);
                    INI_WriteInt(playerFile, "Score", 0);
                    INI_WriteInt(playerFile, "Kills", 0);
                    INI_WriteInt(playerFile, "Deaths", 0);
                    INI_WriteInt(playerFile, "Online", 0);
                    INI_WriteInt(playerFile, "Banned", 0);
                    INI_WriteString(playerFile, "BanReason", PlayerInfo[playerid][pBanReason]);
                    INI_Close(playerFile);
                    SetPVarInt(playerid, "Registered", 1);
                    SetPVarInt(playerid, "Logged", 1);
                    format(strText, 125, "You have registered with name {FFFFFF}'%s' {FFFF00}and password {FFFFFF}'%s'{FFFF00}, you are automatic logged in!", GetName(playerid), inputtext);
                    SendClientMessage(playerid, COLOR_VAGOS, strText);
                }
                else
                {
                    new registermsg[128];
                    format(registermsg, sizeof(registermsg), "Welcome to Los Santos Gang Wars.\n\nAccount Name: %s\nThat account is not registered, type your password below to register!", PlayerName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register for - Los Santos Gang Wars, string", registermsg, "Register", "Exit");
                }
            }
            else Kick(playerid);
        }

        case DIALOG_LOGIN:
        {
            if(response)
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
                {
                    OnPlayerLogin(playerid);
                }
                else
                {
                    new loginmsg[128];
                    format(loginmsg, sizeof(loginmsg), "Welcome back to Los Santos Gang Wars!\n\nAccount Name: %s\nThat account is registered, type your password in to return to war.", PlayerName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login to - Los Santos Gang Wars", loginmsg, "Login", "Exit");
                }
            }
            else Kick(playerid);
        }
    }
    return 1;
}
All OnPlayerLogin does is:
pawn Код:
OnPlayerLogin(playerid)
{
    if(PlayerInfo[playerid][pBanned] == 1)
    {
        new banreason = PlayerInfo[playerid][pBanReason];
        new string[128];
        format(string, sizeof(string), "%s", banreason);
        SendClientMessage(playerid, COLOR_LIGHTRED, "This account has been banned:");
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        Kick(playerid);
        return 0;
    }
    SendClientMessage(playerid, COLOR_ORANGE, "Welcome back to Los Santos Gang Wars!");
    return 1;
}
my problem is now it keeps showing me the dialog showing my passwords wrong (when it's not).

I do have the udb_hash stock:
pawn Код:
stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
Oh and this is the bit in my OnPlayerConnect:
pawn Код:
if(!INI_Exists(strText))
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Los Santos Gang Wars", registermsg, "Register", "Exit");
    }
    else
    {
        new
        uFile[35];
        format(uFile, 35, "%s.ini", PlayerName(playerid));
        INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Los Santos Gang Wars", loginmsg, "Login", "Exit");
    }
Reply
#10

Umm before i look into that this is probs a silly question so ill edit this post later with the correct answer

But did you delete the WP_Hash user file first?

EDIT:

pawn Код:
new                    strText[179];
                if(strlen(inputtext) >= 4 && strlen(inputtext) <= 35)
why do you use this instead of just

[pawn]if(!strlen(inputtext))pawn]

?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)