Any player can log into any account by pressing escape.
#1

Well.. I was following a tutorial about creating a registration system, but seems like there's a bug or something in my code and I have no idea what is causing it. If somebody chooses the 2nd option which is named "Quit" or presses the esc button on their keyboard, they skip the login menu and get directly to the class selection. I've tried every single thing which I came up with, but there's no effect. Any kind of help is appreciated.
PHP код:
switch( dialogid )
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if (
response)
            {
                if(!
strlen(inputtext)) {
                
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT""WHITE"Registering...",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit");
                }
                if(
INI_Open(getINI(playerid))) {
                
INI_WriteString("Password",inputtext);
                
INI_WriteInt("Score",1);
                
INI_WriteInt("Cash",5000);
                
INI_WriteInt("Admin",0);
                
INI_WriteInt("Muted",0);
                
INI_Save();
                
INI_Close();
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
            }
        }
    }
        case 
DIALOG_LOGIN:
        {
            if (!
response) return Kick(playerid);
            if( 
response )
            {
                if(!
strlen(inputtext)) {
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
                }
                if(
INI_Open(getINI(playerid))) {
                
INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);
                if(
strcmp(inputtext,PlayerInfo[playerid][pPass],false)) {
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                }
                
SetPlayerScoreplayeridINI_ReadInt("Score" ) );
                
ResetPlayerMoneyplayerid );
                
GivePlayerMoneyplayeridINI_ReadInt"Cash" ) );
                
PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                
PlayerInfo[playerid][pHitman] = INI_ReadInt("Hitman");
                
PlayerInfo[playerid][pPhone] = INI_ReadInt("Phone");
                
PlayerInfo[playerid][pHealme] = INI_ReadInt("Healme");
                
PlayerInfo[playerid][pMuted] = INI_ReadInt("Muted");
                
PlayerInfo[playerid][pRestricted] = INI_ReadInt("Restricted");
                
INI_Close();
                }
            }
            
        }
    } 
Reply
#2

Make it like this, not (!response)

Код:
            if( response ) 
            {
                /// ini loading shit etc etc
             }
             else
             { //player didn't log in properly. kick him
                      return Kick(playerid);
              }
Reply
#3

Quote:
Originally Posted by Pizzy
Посмотреть сообщение
Make it like this, not (!response)

Код:
            if( response ) 
            {
                /// ini loading shit etc etc
             }
             else
             { //player didn't log in properly. kick him
                      return Kick(playerid);
              }
Still nothing, it lets me log into that account.
Reply
#4

Код:
new bool:pLogged[MAX_PLAYERS];
Код:
public OnPlayerRequestClass( playerid, classid )
{
	if(LOGGED[playerid] == false)
	{
         SendClientMessage(playerid, -1, "[ERROR] You can't spawn because you are not logged in.");
	} 
         return 0;
}
Under on player connect
Код:
public OnPlayerConnect(playerid)
{
	 LOGGED[playerid] = false;
	 return 1;
}
Код:
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if (response)
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""WHITE"Registering...",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit");
                }

                if(INI_Open(getINI(playerid))) {
                INI_WriteString("Password",inputtext);
                INI_WriteInt("Score",1);
                INI_WriteInt("Cash",5000);
                INI_WriteInt("Admin",0);
                INI_WriteInt("Muted",0);
                LOGGED[playerid] = true;
                INI_Save();
                INI_Close();

                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
            }
        }
    }
        case DIALOG_LOGIN:
        {
            if (!response) return Kick(playerid);
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
                }

                if(INI_Open(getINI(playerid))) {
                INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);

                if(strcmp(inputtext,PlayerInfo[playerid][pPass],false)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                }

                SetPlayerScore( playerid, INI_ReadInt("Score" ) );
                ResetPlayerMoney( playerid );
                GivePlayerMoney( playerid, INI_ReadInt( "Cash" ) );
                PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                PlayerInfo[playerid][pHitman] = INI_ReadInt("Hitman");
                PlayerInfo[playerid][pPhone] = INI_ReadInt("Phone");
                PlayerInfo[playerid][pHealme] = INI_ReadInt("Healme");
                PlayerInfo[playerid][pMuted] = INI_ReadInt("Muted");
                PlayerInfo[playerid][pRestricted] = INI_ReadInt("Restricted");
                INI_Close();
                LOGGED[playerid] = true;
                }
            }
            
        }
    }
Try this code,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)