Wrong Passwords
#1

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;

Reply
#2

Show OnDialogResponse callback...
Reply
#3

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

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;
           }
       } 
Reply
#5

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?
Reply
#6

Bump, any idea why this happens?
Reply
#7

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.
Reply
#8

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;

Reply
#9

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.
Reply
#10

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.
Reply
#11

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?
Reply
#12

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

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?
Reply
#14

Bump, any ideas?

E: Sure, one moment.
Reply
#15

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.
Reply
#16

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.
Reply
#17

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

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.
Reply
#19

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)