bank help +rep
#1

Guys help me i need help with this one
it wont write the password
or just do with integer of 0

bdw here is my code

pawn Код:
case D_BANKREGISTER:
        {
            if (!response) return SendClientMessage(playerid,C_ERROR,"[ Error ]:"CWHITE" You have cancelled it ");
            if(response)
            {
                if(!strlen(inputtext)) return SendClientMessage(playerid,C_ERROR,"[ Error ]:"CWHITE" Invalid pin number");
                if(!isnumeric(inputtext)) return SendClientMessage(playerid,C_ERROR,"[ Error ]:"CWHITE" Invalid pin number");
                if(strval(inputtext) < 6 || strval(inputtext) >6) return 1;
                {
                    new INI:Data = INI_Open(BPATH(playerid));
                    INI_SetTag(Data,"data");
                    INI_WriteInt(Data,"Password",strval(inputtext));
                    INI_WriteInt(Data,"Cash",0);
                    INI_Close(Data);
                }
            }
        }
       
        case D_BANKLOGIN:
        {
            if (!response) return SendClientMessage(playerid,C_ERROR,"[ Error ]:"CWHITE" You have cancelled it ");
            if(response)
            {
                if(strval(inputtext) == pbData[playerid][bPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    SendClientMessage(playerid,C_BOT,"Enricka:"CWHITE" You have succesfull loged in to your bank account");
                    ShowPlayerDialog(playerid,D_BANK,LIST,""CSERVER"RicaNiel - "CWHITE"Bank System","Balance\r\nDeposit\r\nWithdraw","Proceed","Cancel");
                }
                else
                {
                    SendClientMessage(playerid,C_ERROR,"[ Error ]:"CWHITE" Please enter your 6 pin digin again");
                }
            }
        }
    }
pawn Код:
stock BPATH(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),R_BANKPATH,playername);
    return string;
}
Код:
[data]
Password = 0
Balance = 0
Reply
#2

Mash it, mashing it is the better way so no one can see the real pass.

example when you type 871425 in the database it will be 418474
to mash it you need this:

pawn Код:
//credits to DracoBlue - taken from dudb
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;
}
then do this

pawn Код:
INI_WriteInt(Data, "Password", udb_hash(inputtext));
Reply
#3

Right. Like anyone cares about some virtual pin number, virtual bank account or virtual money. <_<

Anyway, problem is here:
pawn Код:
if(strval(inputtext) < 6 || strval(inputtext) >6) return 1;
Please learn the difference between strval (get the integer value of a string) and strlen (get the length of a string). Replace with:
pawn Код:
if(strlen(inputtext) != 6) return 1;
Reply
#4

yes even if i hash it it wont detect the password
and bdw.. i want the password would be numeric

not password with letters
all is numeric
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)