SA-MP Forums Archive
INI doesn't hash password + doesnt load money - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: INI doesn't hash password + doesnt load money (/showthread.php?tid=597386)



INI doesn't hash password + doesnt load money - fuckingcruse - 30.12.2015

Hey guys i have tried this login/register system it doesn't hash password it allows me to type and password and gives access to account.. and it doesn't load money while login.. check it if you are free , thanks.

Код:
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new
					hashed_password[ 129 ];
				WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );


                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteString(File, "Password", hashed_password );
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Sex",0);
                INI_WriteInt(File,"Age",0);
                INI_WriteFloat(File,"Pos_x",1654.0);
    			INI_WriteFloat(File,"Pos_y",-2330.3);
    			INI_WriteFloat(File,"Pos_z",13.5);
   			 	INI_WriteInt(File,"Skin",0);
   			 	INI_WriteInt(File,"Team",0);
   			 	INI_WriteInt(File,"Accent",0);
                INI_WriteInt(File,"Member",0);
                INI_Close(File);

            }
        }
        case DIALOG_LOGIN:
        {
            //if ( !response ) return Kick ( playerid );  done :D
            if( response )
            {
                new
					hashed_password[ 129 ];
				

                if( !strcmp ( hashed_password, PlayerInfo[ playerid ][ pPassword ] ) )
                {
                    INI_ParseFile(UserPath ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
					SetSpawnInfo(playerid, PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
					GivePlayerMoney( playerid, PlayerInfo[ playerid ][ pCash ] );
					// so this is done (thanks i pissed and chosen to come and fix :D) man not fixed trust me JUST WATCH
				}
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{97F2FD}Account: Login","{FF2020}You have entered an incorrect password\n\n{FFFFFF}Please type your password to login","Login","Quit");
                }
                return 1;
            }
            else
            {
                Kick(playerid);
                //ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Please enter a password to proceed further.","Login","Quit");
			}
        }
    }



Re: INI doesn't hash password + doesnt load money - Swarn - 30.12.2015

Do you mean, when you are typing in the password in the text box, it shows it?


Re: INI doesn't hash password + doesnt load money - fuckingcruse - 30.12.2015

Nope.. Like my password is : ABCD ..

I registered it with it ( ABCD ) when i login again .. and type anything in the password box it grants me access..


Re: INI doesn't hash password + doesnt load money - IceBilizard - 30.12.2015

give a try to this code

PHP код:
//Put this somewhere in script
stock num_hash(buf[])
{
    new 
length strlen(buf),s1 1,s2 0,n;
    for(
0lengthn++)
    {
        
s1 = (s1 buf[n]) % 65521;
        
s2 = (s2 s1)     % 65521;
    }
    return (
s2 << 16) + s1;
}
//Then
INI_WriteString(File"Password",  num_hash(inputtext)); //inputtext for if you are using dialog for register 



Re: INI doesn't hash password + doesnt load money - fuckingcruse - 30.12.2015

I have tried implementing it , but a little bit confused as my codes is using hashed_password and it is used everywhere in login and register dialog. it would be a great favour if you may change it and add it in my codes and present me.. Thanks.


Re: INI doesn't hash password + doesnt load money - IceBilizard - 30.12.2015

PHP код:
stock num_hash(buf[])
{
    new 
length strlen(buf),s1 1,s2 0,n;
    for(
0lengthn++)
    {
        
s1 = (s1 buf[n]) % 65521;
        
s2 = (s2 s1)     % 65521;
    }
    return (
s2 << 16) + s1;
}
case 
DIALOG_REGISTER:
{
            if (!
response) return Kick(playerid);
            if(
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new 
INI:File INI_Open(UserPath(playerid));
                
INI_SetTag(File,"data");
                
INI_WriteString(File"Password"num_hash(inputtext));
                
INI_WriteInt(File,"Cash",0);
                
INI_WriteInt(File,"Admin",0);
                
INI_WriteInt(File,"Sex",0);
                
INI_WriteInt(File,"Age",0);
                
INI_WriteFloat(File,"Pos_x",1654.0);
                
INI_WriteFloat(File,"Pos_y",-2330.3);
                
INI_WriteFloat(File,"Pos_z",13.5);
                    
INI_WriteInt(File,"Skin",0);
                    
INI_WriteInt(File,"Team",0);
                    
INI_WriteInt(File,"Accent",0);
                
INI_WriteInt(File,"Member",0);
                
INI_Close(File);
            }
}
case 
DIALOG_LOGIN:
{
            
//if ( !response ) return Kick ( playerid );  done :D
            
if( response )
            {
                if(
num_hash(inputtext) == PlayerInfoplayerid ][ pPassword ] ) )
                {
                    
INI_ParseFile(UserPath playerid ), "load_user_%s", .bExtra true, .extra playerid);
                    
SetSpawnInfo(playeridPlayerInfo[playerid][pTeam], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
                    
GivePlayerMoneyplayeridPlayerInfoplayerid ][ pCash ] );
                    
// so this is done (thanks i pissed and chosen to come and fix :D) man not fixed trust me JUST WATCH
                
}
                else
                {
                    
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,"{97F2FD}Account: Login","{FF2020}You have entered an incorrect password\n\n{FFFFFF}Please type your password to login","Login","Quit");
                }
                return 
1;
            }
            else
            {
                
Kick(playerid);
                
//ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Please enter a password to proceed further.","Login","Quit");
            
}
        }




Re: INI doesn't hash password + doesnt load money - fuckingcruse - 30.12.2015

Errors.. unexpectional
Код:
C:\Users\Tarun\Desktop\Varun\My script\gamemodes\grandlarc.pwn(2598) : error 017: undefined symbol "num_hash"
C:\Users\Tarun\Desktop\Varun\My script\gamemodes\grandlarc.pwn(2600) : error 017: undefined symbol "buf"
C:\Users\Tarun\Desktop\Varun\My script\gamemodes\grandlarc.pwn(2603) : error 017: undefined symbol "buf"



Re: INI doesn't hash password + doesnt load money - IceBilizard - 30.12.2015

did u add in your script?
PHP код:
stock num_hash(buf[])
{
    new 
length strlen(buf),s1 1,s2 0,n;
    for(
0lengthn++)
    {
        
s1 = (s1 buf[n]) % 65521;
        
s2 = (s2 s1)     % 65521;
    }
    return (
s2 << 16) + s1;




Re: INI doesn't hash password + doesnt load money - fuckingcruse - 30.12.2015

Lmao ofc.. that line number is of that line.


Re: INI doesn't hash password + doesnt load money - IceBilizard - 30.12.2015

well i this code is fine for me where did you add it in dialog or outside of dialog?