SA-MP Forums Archive
Wrong Passwords - 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: Wrong Passwords (/showthread.php?tid=639827)



Wrong Passwords - aoky - 23.08.2017

If more than one person connects at the same time, the login bugs out. It keeps saying the password is incorrect, although it is 100 percent correct.

PHP код:
forward OnAccountCheck(playerid);
public 
OnAccountCheck(playerid)
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsmysql);
    if(
rows)
    {
        
cache_get_field_content(0"Password"PlayerInfo[playerid][pPass], mysql129);
        
PlayerInfo[playerid][pID] = cache_get_field_content_int(0"ID");
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Koky's Gang Wars""{FFFFFF}Welcome back to {DADADA}Koky's Gang Wars.{FFFFFF}\nType in your password below to login.""Login""Quit");
    }
    else
    {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Koky's Gang Wars""{FFFFFF} Welcome to {DADADA}Koky's Gang Wars!{FFFFFF}\nType in your desired password below to register. ""Register""Quit");
    }
    return 
1;




Re: Wrong Passwords - 10MIN - 23.08.2017

Show OnDialogResponse callback...


Re: Wrong Passwords - Xeon™ - 23.08.2017

wait don't tell me. mysql is a global string right?


Re: Wrong Passwords - aoky - 23.08.2017

PHP код:
    else if(dialogid == DIALOG_LOGIN)
    {
        if(!
response) return DIALOG_LOGIN;
        else
          {
               new 
hpass[129];
             
WP_Hash(hpass129inputtext);
              if(!
strcmp(hpassPlayerInfo[playerid][pPass]))
               {
                 
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `users` WHERE `Username` = '%e' LIMIT 1"Name[playerid]);
                  
mysql_tquery(mysqlquery"OnAccountLoad""i"playerid);
                
TextDrawHideForPlayer(playerid,Login1[playerid]);
                
TextDrawHideForPlayer(playerid,Login2[playerid]);
                
TextDrawHideForPlayer(playerid,Login3[playerid]);
                
TextDrawHideForPlayer(playerid,Login4[playerid]);
                
TextDrawHideForPlayer(playerid,Login5[playerid]);
                
TextDrawHideForPlayer(playerid,Login6[playerid]);
                
TextDrawHideForPlayer(playerid,Login7[playerid]);
                
TogglePlayerSpectating(playeridfalse);
                
PlayTimer[playerid] = SetTimerEx("PlayingTime"600001"i"playerid);
                
StopAudioStreamForPlayer(playerid);
            }
            else
               {
                  
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_MSGBOX,""COL_RED"KICKED",""COL_RED"You have been kicked for entering an incorrect password.","QUIT","");
                
KickPlayer(playerid);
            }
               return 
1;
           }
       } 



Re: Wrong Passwords - aoky - 23.08.2017

Quote:
Originally Posted by XeonMaster
Посмотреть сообщение
wait don't tell me. mysql is a global string right?
Not sure if this is what you mean? But here's how I've set it up.
PHP код:
static
    
mysql,
    
IP[MAX_PLAYERS][16],
    
Name[MAX_PLAYERS][24]; 
Could this be the issue?


Re: Wrong Passwords - aoky - 23.08.2017

Bump, any idea why this happens?


Re: Wrong Passwords - GoldenLion - 23.08.2017

Show the line where you send the OnAccountCheck query. My guess is that you forgot to pass playerid to OnAccountCheck and the playerid is always 0 there, that happened to me once.


Re: Wrong Passwords - aoky - 23.08.2017

Thanks for the reply.
PHP код:
forward LoggingTimer(playerid);
public 
LoggingTimer(playerid)
{
    new 
query[512];
    
GetPlayerIp(playeridIP[playerid], 16);
    
GetPlayerName(playeridName[playerid], 24);
    
mysql_format(mysqlquerysizeof(query),"SELECT `Password`, `ID` FROM `users` WHERE `Username` = '%e' LIMIT 1"Name[playerid]);
    
mysql_tquery(mysqlquery"OnAccountCheck""i"playerid);
    
TextDrawShowForPlayer(playerid,Login1[playerid]);
    
TextDrawShowForPlayer(playerid,Login2[playerid]);
    
TextDrawShowForPlayer(playerid,Login3[playerid]);
    
TextDrawShowForPlayer(playerid,Login4[playerid]);
    
TextDrawShowForPlayer(playerid,Login5[playerid]);
    
TextDrawShowForPlayer(playerid,Login6[playerid]);
    
TextDrawShowForPlayer(playerid,Login7[playerid]);
    
InterpolateCameraPos(playerid, -1781.663330428.00616477.410369, -1162.0170891080.10339377.41864040000);
    
InterpolateCameraLookAt(playerid, -1778.375610431.43362475.847175, -1158.8074951083.44946275.54736340000);
    return 
1;




Re: Wrong Passwords - GoldenLion - 23.08.2017

Can you also show the line where you set the timer for LoggingTimer? By the way you don't need to escape players' names because they can't have any apostrophes in them. Not that it would change anything, but just so you know if you already didn't. Also LIMIT 1 is absolutely unneccessary as there shouldn't be more than one account with the same name.


Re: Wrong Passwords - aoky - 23.08.2017

LoggingTimer is used on OnPlayerConnect, and I never knew that. Thank's for the heads up.

E: If the players log in-game one by one, it doesn't happen. If they connect at once, it bugs out.


Re: Wrong Passwords - GoldenLion - 23.08.2017

Quote:
Originally Posted by aoky
Посмотреть сообщение
LoggingTimer is used on OnPlayerConnect, and I never knew that. Thank's for the heads up.

E: If the players log in-game one by one, it doesn't happen. If they connect at once, it bugs out.
Try printing the passwords (the hashed ones of course, the pPass). Are they the same as in the database?


Re: Wrong Passwords - aoky - 24.08.2017

After doing as you said, it only resulted in one password showing. We tried typing eachothers passwords, same result in the player being kicked.


Re: Wrong Passwords - GoldenLion - 24.08.2017

Well, I don't know what could be the problem because the code looks fine for me. Can you post your latest MySQL logs here after the two players connect?


Re: Wrong Passwords - aoky - 24.08.2017

Bump, any ideas?

E: Sure, one moment.


Re: Wrong Passwords - aoky - 24.08.2017

Here are the results, although I've made changes to the system so it doesn't kick the player, the dialog just reappears. Then, when he kept getting the error of the password being wrong, I quit and he put his password in again and it resulted in the same error.

Here is the debug/log you requested @GoldenLion, https://pastebin.com/q0DY9VNs.


Re: Wrong Passwords - Kane - 24.08.2017

To be honest, if you wanna make this easier, you could just change your method of how you login, for example:

PHP код:
case DIALOG_LOGIN:
{
      new 
hpass[129];
             
WP_Hash(hpass129inputtext);
 
    
mysql_format(ourConnectioncontinueChecksizeof(continueCheck), "SELECT * FROM characters WHERE AccountName = '%e' AND AccountPass = '%e' LIMIT 1"ReturnName(playerid), hpass);
                
    
mysql_tquery(ourConnectioncontinueCheck"OnPlayerLogin""i"playerid);

PHP код:
public OnPlayerLogin(playerid)
{
      if(!
cache_num_rows())
     {
          
//Bad password.
          
return 1;
     }
     
//Password is a success.
    
return 1;

Just a thought.


Re: Wrong Passwords - GoldenLion - 25.08.2017

The log seems to be fine for me as well. You could try Arthur Kane's way.


Re: Wrong Passwords - thegamer355 - 25.08.2017

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
To be honest, if you wanna make this easier, you could just change your method of how you login, for example:

PHP код:
case DIALOG_LOGIN:
{
      new 
hpass[129];
             
WP_Hash(hpass129inputtext);
 
    
mysql_format(ourConnectioncontinueChecksizeof(continueCheck), "SELECT * FROM characters WHERE AccountName = '%e' AND AccountPass = '%e' LIMIT 1"ReturnName(playerid), hpass);
                
    
mysql_tquery(ourConnectioncontinueCheck"OnPlayerLogin""i"playerid);

PHP код:
public OnPlayerLogin(playerid)
{
      if(!
cache_num_rows())
     {
          
//Bad password.
          
return 1;
     }
     
//Password is a success.
    
return 1;

Just a thought.
This is the way i've been doing it a looong time, i've used the way you do before, and had the exact same issues.


Re: Wrong Passwords - aoky - 25.08.2017

Looks like the code just wasn't working correctly, I managed to get my way around it by re-making it and doing Artur's way.

Thank you all for the great help, you have all been repped.