SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/05/2020, 11:18 PM   #1
TheOliver
Big Clucker
 
Join Date: Apr 2020
Posts: 94
Reputation: 0
Default logging error wrong password

I have an error when trying to log in, and that is that when entering the password it tells me, incorrect password is the correct password.

here is my code for you to see (if you see something in Spanish ignore it).

Quote:
/*Credits to Dracoblue*/
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;
}
Quote:
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""#hBlanco"Registering...",""hBlanco"You have entered an invalid password.\n"hBlanco"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Muertes",0);
INI_WriteInt(File,"KD",0);
INI_WriteInt(File,"Escore",0);
INI_Close(File);

ShowPlayerDialog(playerid, DIALOGO_GENERO, DIALOG_STYLE_MSGBOX, "Genero", "Selecciona tu genero.", "Hombre", "Mujer");
}
}

case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""hBlanco"Login",""hRojo"You have entered an incorrect password.\n"hBlanco"Type your password below to login.","Login","Quit");
}
return 1;
}
}
Thank you
TheOliver is offline   Reply With Quote
Old 17/05/2020, 11:32 PM   #2
xRadical3
Gangsta
 
Join Date: May 2017
Location: Iran
Posts: 691
Reputation: 63
Default Re: logging error wrong password

Try to use another password hash functions.
xRadical3 is offline   Reply With Quote
Old 17/05/2020, 11:39 PM   #3
TheOliver
Big Clucker
 
Join Date: Apr 2020
Posts: 94
Reputation: 0
Default Re: logging error wrong password

Quote:
Originally Posted by Vizi10 View Post
Try to use another password hash functions.
as which? I don't know much about the hash and stuff, actually I'm starting with the pawno thing
TheOliver is offline   Reply With Quote
Old 18/05/2020, 01:29 AM   #4
ChandraLouis
Banned
 
Join Date: Mar 2013
Location: Indonesia
Posts: 438
Reputation: 37
Default Re: logging error wrong password

Try num_hash, works great for me.
ChandraLouis is offline   Reply With Quote
Old 18/05/2020, 01:32 AM   #5
Ghazal
Gangsta
 
Ghazal's Avatar
 
Join Date: Oct 2013
Location: Egypt
Posts: 523
Reputation: 167
Default Re: logging error wrong password

I'd recommend you to get over this and build a MySQL registration system better, INI is way too outdated anyway.
This tutorial will explain how to build one with MySQL R41-2 and a SHA256 password hashing system.
Ghazal is offline   Reply With Quote
Old 19/05/2020, 01:27 AM   #6
TheOliver
Big Clucker
 
Join Date: Apr 2020
Posts: 94
Reputation: 0
Default Re: logging error wrong password

Quote:
Originally Posted by Ghazal View Post
I'd recommend you to get over this and build a MySQL registration system better, INI is way too outdated anyway.
This tutorial will explain how to build one with MySQL R41-2 and a SHA256 password hashing system.
ok, if I have seen that they use it a lot lately, but the problem is that I don't know anything about that, if you could pass me a tutorial for beginners in MySQL that explains well, I would appreciate it a lot
TheOliver is offline   Reply With Quote
Old 19/05/2020, 02:21 AM   #7
ChandraLouis
Banned
 
Join Date: Mar 2013
Location: Indonesia
Posts: 438
Reputation: 37
Default Re: logging error wrong password

Quote:
ok, if I have seen that they use it a lot lately, but the problem is that I don't know anything about that, if you could pass me a tutorial for beginners in MySQL that explains well, I would appreciate it a lot
Take a look at this.
https://forum.sa-mp.com/showthread.php?t=627520
ChandraLouis is offline   Reply With Quote
Old 19/05/2020, 03:58 AM   #8
GameOvr
Huge Clucker
 
GameOvr's Avatar
 
Join Date: Jun 2018
Posts: 296
Reputation: 9
Default Re: logging error wrong password

The problem is you are not loading password from the file into variables before showing the login dialog.. there fore variable doesn't contain the correct pass when player tries to login.
Add this first
Code:
NI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
Whenever you are using this
Code:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""hBlanco"Login",""hRojo"You have entered an incorrect password.\n"hBlanco"Type your password below to login.","Login","Quit");
You have to fix this at OnPlayerConnect too...
__________________
GameOvr is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrong Password Error +reputation CarRamper Scripting Help 9 16/08/2016 01:46 PM
Wrong password when logging in but still logs me Jigsaw123 Scripting Help 2 19/06/2014 03:35 PM
Logging in with the wrong password - forces the account to reset. James Bob Scripting Help 8 04/12/2013 07:17 AM
Mysql not logging password Blademaster680 Scripting Help 2 05/08/2013 06:50 AM
[BUGGED] Password Logging GAMER_PS2 Scripting Help 9 17/10/2011 09:48 AM


All times are GMT. The time now is 09:40 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.