player not kicked after leaving login
#1

Title pretty much explains my problem, if I press 'ESC' or 'Cancel' the player continues to the class selection, although this shouldn't be like this.

OnDialogResponse:
Код:
                   case DIALOG_REGISTER:
                    {
	                if(response)
	                {
	                    if(!response) return SetTimerEx("KickPlayer", 100, 0, "d", playerid);
	                    if(!strlen(inputtext))
	                    {
	                        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{00FFFF}Please enter your password to register.\n{FF0000}You can't leave this empty.", "OK", "Cancel");
	                        return 1;
	                    }
	                    new INI:file = INI_Open(Path(playerid));
	                    INI_WriteString(file,"Password",inputtext);
	                    INI_SetTag(file, "[Player Stats]");
	                    INI_WriteInt(file,"Score",0);
	                    INI_WriteInt(file,"Deaths",0);
	                    INI_WriteInt(file,"Admin",0);
	                    INI_WriteInt(file,"Gmute", 0);
	                    INI_WriteInt(file,"Vip", 0);
	                    INI_WriteInt(file,"Health", 100);
	                    INI_Close(file);
	                    return 1;
	                }
	            }
	            case DIALOG_LOGIN:
	            {
	                if(response)
	                {
	                    if(!response) return SetTimerEx("KickPlayer", 100, 0, "d", playerid);
	                    if(!strcmp(inputtext, pStats[playerid][password], false))
	                    {
	                        INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
	                        SendClientMessage(playerid,COLOR_WHITE,"You have successfully logged in.");
	                    }
	                    else
	                    {
	                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{00FFFF}Please enter your password to login.\n{FF0000}Incorrect password.", "OK", "Cancel");
	                        return 1;
	                    }
	                }
	            }
Forward & public from KickPlayer:
Код:
forward KickPlayer(playerid);

public KickPlayer(playerid)
{
     Kick(playerid);
     return 1;
}
Anything that can solve this problem? Regards.
Reply
#2

Quote:
Originally Posted by [WA]iRonan
Посмотреть сообщение
Title pretty much explains my problem, if I press 'ESC' or 'Cancel' the player continues to the class selection, although this shouldn't be like this.

OnDialogResponse:
Код:
                   case DIALOG_REGISTER:
                    {
	                if(response)
	                {
	                    if(!response) return SetTimerEx("KickPlayer", 100, 0, "d", playerid);
	                    if(!strlen(inputtext))
	                    {
	                        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{00FFFF}Please enter your password to register.\n{FF0000}You can't leave this empty.", "OK", "Cancel");
	                        return 1;
	                    }
	                    new INI:file = INI_Open(Path(playerid));
	                    INI_WriteString(file,"Password",inputtext);
	                    INI_SetTag(file, "[Player Stats]");
	                    INI_WriteInt(file,"Score",0);
	                    INI_WriteInt(file,"Deaths",0);
	                    INI_WriteInt(file,"Admin",0);
	                    INI_WriteInt(file,"Gmute", 0);
	                    INI_WriteInt(file,"Vip", 0);
	                    INI_WriteInt(file,"Health", 100);
	                    INI_Close(file);
	                    return 1;
	                }
	            }
	            case DIALOG_LOGIN:
	            {
	                if(response)
	                {
	                    if(!response) return SetTimerEx("KickPlayer", 100, 0, "d", playerid);
	                    if(!strcmp(inputtext, pStats[playerid][password], false))
	                    {
	                        INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
	                        SendClientMessage(playerid,COLOR_WHITE,"You have successfully logged in.");
	                    }
	                    else
	                    {
	                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{00FFFF}Please enter your password to login.\n{FF0000}Incorrect password.", "OK", "Cancel");
	                        return 1;
	                    }
	                }
	            }
Forward & public from KickPlayer:
Код:
forward KickPlayer(playerid);

public KickPlayer(playerid)
{
     Kick(playerid);
     return 1;
}
Anything that can solve this problem? Regards.
Yes, you have the if(!response) inside a response so it will actually never hit that point. You should do it like so:


pawn Код:
case DIALOG_REGISTER: {
            if(response) {
                if(!strlen(inputtext)) {
                    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{00FFFF}Please enter your password to register.\n{FF0000}You can't leave this empty.", "OK", "Cancel");
                    return 1;
                }
                new INI:file = INI_Open(Path(playerid));
                INI_WriteString(file,"Password",inputtext);
                INI_SetTag(file, "[Player Stats]");
                INI_WriteInt(file,"Score",0);
                INI_WriteInt(file,"Deaths",0);
                INI_WriteInt(file,"Admin",0);
                INI_WriteInt(file,"Gmute", 0);
                INI_WriteInt(file,"Vip", 0);
                INI_WriteInt(file,"Health", 100);
                INI_Close(file);
                return 1;
            } else {
                SetTimerEx("KickPlayer", 100, 0, "d", playerid); //Now it will kick the player properly.
            }
        }
        case DIALOG_LOGIN: {
            if(response) {
                if(!strcmp(inputtext, pStats[playerid][password], false)) {
                    INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
                    SendClientMessage(playerid,COLOR_WHITE,"You have successfully logged in.");
                } else {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{00FFFF}Please enter your password to login.\n{FF0000}Incorrect password.", "OK", "Cancel");
                    return 1;
                }
            } else {
                SetTimerEx("KickPlayer", 100, 0, "d", playerid);
            }
        }
Reply
#3

Try this. You had the "if(!response) in the wrong place .

Код:
case DIALOG_REGISTER:
                    {
                        if(!response) return SetTimerEx("KickPlayer", 100, 0, "d", playerid);
	                if(response)
	                {
	                    if(!strlen(inputtext))
	                    {
	                        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{00FFFF}Please enter your password to register.\n{FF0000}You can't leave this empty.", "OK", "Cancel");
	                        return 1;
	                    }
	                    new INI:file = INI_Open(Path(playerid));
	                    INI_WriteString(file,"Password",inputtext);
	                    INI_SetTag(file, "[Player Stats]");
	                    INI_WriteInt(file,"Score",0);
	                    INI_WriteInt(file,"Deaths",0);
	                    INI_WriteInt(file,"Admin",0);
	                    INI_WriteInt(file,"Gmute", 0);
	                    INI_WriteInt(file,"Vip", 0);
	                    INI_WriteInt(file,"Health", 100);
	                    INI_Close(file);
	                    return 1;
	                }
	            }
	            case DIALOG_LOGIN:
	            {
	                if(!response) return SetTimerEx("KickPlayer", 100, 0, "d", playerid);
	                if(response)
	                {

	                    if(!strcmp(inputtext, pStats[playerid][password], false))
	                    {
	                        INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
	                        SendClientMessage(playerid,COLOR_WHITE,"You have successfully logged in.");
	                    }
	                    else
	                    {
	                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{00FFFF}Please enter your password to login.\n{FF0000}Incorrect password.", "OK", "Cancel");
	                        return 1;
	                    }
	                }
	            }
Reply
#4

Tried those although it didn't work. I also tried using a stock and also added the return.
Reply
#5

Bump
Reply
#6

You should use it out of if(response) i think!
Код:
             case DIALOG_REGISTER:
                    {
	                if(response)
	                {
	                    if(!strlen(inputtext))
	                    {
	                        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{00FFFF}Please enter your password to register.\n{FF0000}You can't leave this empty.", "OK", "Cancel");
	                        return 1;
	                    }
	                    new INI:file = INI_Open(Path(playerid));
	                    INI_WriteString(file,"Password",inputtext);
	                    INI_SetTag(file, "[Player Stats]");
	                    INI_WriteInt(file,"Score",0);
	                    INI_WriteInt(file,"Deaths",0);
	                    INI_WriteInt(file,"Admin",0);
	                    INI_WriteInt(file,"Gmute", 0);
	                    INI_WriteInt(file,"Vip", 0);
	                    INI_WriteInt(file,"Health", 100);
	                    INI_Close(file);
	                    return 1;
	                }
	            }
	            case DIALOG_LOGIN:
	            {
	                if(response)
	                {
	                    if(!strcmp(inputtext, pStats[playerid][password], false))
	                    {
	                        INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
	                        SendClientMessage(playerid,COLOR_WHITE,"You have successfully logged in.");
	                    }
	                    else
	                    {
	                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "                {00FFFF}Please enter your password to login.\n{FF0000}Incorrect password.", "OK", "Cancel");
                           if(!response) return SetTimerEx("KickPlayer", 100, 0, "d", playerid);

	                        return 1;
	                    }
	                }
	            }
if not helped please use
Код:
 		if(response == 0)
		{
			SetTimerEx("KickPlayer", 100, 0, "d", playerid);//Add Function
		}
_________________
xXx Stunt Paradise Awesome

Server IP: [/size][/i]Click Here!

Hosted Tab Game-MP for 10 Euro / per month
Hosted Tab + Server host 50 slots + Control Panel for 15 Euro
Skype: MahdiAsali
Ђ10 Euro for Hosted List
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)