SA-MP Forums Archive
[HELP] MYSQL Login System - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] MYSQL Login System (/showthread.php?tid=244487)



[HELP] MYSQL Login System - Camacorn - 27.03.2011

Ok, my server has completed its MySql system thanks to someone whos name i wont state because i dont think he would want me to.

The only issue is, when you relog, and try to Login, it says "* Wrong Password" every single time, even if the password is right. It does this for every player.

We use GstyleZzZ MySql Plugin R5 - https://sampforum.blast.hk/showthread.php?tid=56564

Here is the code:
(( Please ignore that it is non-indented on the forum, i dont know why. ))
Код:
    if(dialogid == 1400) // login dialog
    {
       if(response)
       {
            if(!strlen(inputtext))
            {
                //ShowPlayerDialog(playerid, 1400, DIALOG_STYLE_INPUT , "Login", "Insert your password below to log in!", "OK", "Cancel");
                SendClientMessage(playerid, c_red, "* You have to login to be able to play!");
				new str2[152];
				format(str2, sizeof(str2), "Welcome to Battlefield 1943:\n\n{FF0000}%s,\n\n{FFFFFF}That name is registered. Please enter your password below.", plnamed);
				ShowPlayerDialog(playerid, 1400, DIALOG_STYLE_INPUT, "Login",str2,"Login", "Cancel");
            }
            
            new str2[152], query[100];
            new string[128], pname[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pname, sizeof(pname));
			
			format(query, sizeof(query), "SELECT * FROM `users` WHERE name='%s'", pname);
  			mysql_store_result();
  			mysql_fetch_row_format(query, "|");
  			sscanf(query, "e<p<|>{s[32]}i{s[32]}i{i}iiiii>", PlayerInfo[playerid]);

			new pas = udb_hash(inputtext);
            new upas = PlayerInfo[playerid][hashpw];
            if(pas != upas)
			{
              SendClientMessage(playerid, c_red, "* Wrong Password.");
              format(str2, sizeof(str2), "Welcome to Battlefield 1943:\n\n{FF0000}%s,\n\n{FFFFFF}That name is registered. Please enter your password below.", plnamed);
			  ShowPlayerDialog(playerid, 1400, DIALOG_STYLE_INPUT, "Login",str2,"Login", "Cancel");
	  		}
            else
            {
              logged[playerid] = 1;/*
              PlayerInfo[playerid][Admin] = dini_Int(file, "Admin");
              SetPlayerScore(playerid, dini_Int(file, "score"));
              PlayerInfo[playerid][deaths] = dini_Int(file, "deaths");
              PlayerInfo[playerid][EasterEgg] = dini_Int(file, "EasterEgg");
              PlayerInfo[playerid][Warns] = dini_Int(file, "Warns");*/
              SendClientMessage(playerid, c_green, "* You have logged in!");
              format(string,sizeof(string),"* %s has logged in!", pname);
              SendClientMessageToAll(c_green, string);
              SendClientMessage(playerid, c_blue, "* If you don't spawn automatically, click on the 'Spawn' button!");
              UpdateTag(playerid);
              LoginPlayer(playerid);
            }
        }
        else
        {
            new str2[152];
        	format(str2, sizeof(str2), "Welcome to Battlefield 1943:\n\n{FF0000}%s,\n\n{FFFFFF}That name is registered. Please enter your password below.", plnamed);
			ShowPlayerDialog(playerid, 1400, DIALOG_STYLE_INPUT, "Login",str2,"Login", "Cancel");
			SendClientMessage(playerid, c_red, "* You have to login to be able to play!");
        }
    }
And if it helps, heres the player info:

Код:
// Playerinfo
enum pInfo
{
        //Basic
        namevar[32],
        hashpw,
        Admin,
        deaths,
        EasterEgg,
        Warns,
        Premium,
        PremiumChat,
        team,
        class,
        spawn,
        smember,
        sleader,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Thank you, if you can fix this


Re: [HELP] MYSQL Login System - [ProX]BlueFire - 27.03.2011

try my script =D
CLICK ON ME!!!!
(pass: 123)


Re: [HELP] MYSQL Login System - Camacorn - 27.03.2011

Sorry but no, im using MySql, if i wanted something basic, id have made it.


Re: [HELP] MYSQL Login System - [ProX]BlueFire - 27.03.2011

-.-
y all dont use the normal things....
y all have to be unqiue?
anyway its the same things...


Re: [HELP] MYSQL Login System - [NoV]LaZ - 27.03.2011

You forgot to use mysql_query( query );


Re: [HELP] MYSQL Login System - Camacorn - 27.03.2011

tried that, doesnt work.


Re: [HELP] MYSQL Login System - Camacorn - 27.03.2011

Someone told me to do this:

Quote:
Originally Posted by Sergei
Посмотреть сообщение
You are doing it wrong.

1. Don't extract password in pawn because you don't need it
2. Password is not integer.
3. SELECT .... WHERE name='this' AND password='that'
If you get any result password is right, otherwise not.
but i dont understand what to remove or change


Re: [HELP] MYSQL Login System - [NoV]LaZ - 27.03.2011

pawn Код:
format( query, sizeof (query), "SELECT * FROM `users` WHERE `name` = '%s' AND `password` = '%s' LIMIT 1;", ... );
mysql_query( query );
mysql_store_result( );
if ( mysql_num_rows( ) )
{
    // the player got the password right
}
else
{
    // not...
}
And why are you using dini too ?


Re: [HELP] MYSQL Login System - Camacorn - 27.03.2011

Quote:
Originally Posted by [NoV]LaZ
Посмотреть сообщение
pawn Код:
format( query, sizeof (query), "SELECT * FROM `users` WHERE `name` = '%s' AND `password` = '%s' LIMIT 1;", ... );
mysql_query( query );
mysql_store_result( );
if ( mysql_num_rows( ) )
{
    // the player got the password right
}
else
{
    // not...
}
did not work


Re: [HELP] MYSQL Login System - Hal - 27.03.2011

Quote:
Originally Posted by Camacorn
Посмотреть сообщение
Someone told me to do this:



but i dont understand what to remove or change
Camacorn, I'll look into what Sergi said, because it makes sense. But the password is only an integer because its hashed. It's using the very insecure ubd hash.

Put in [pawn] tags so people see the commenting.