Dialog Response problem
#1

Everytime I use one of my dialogs (not login/register) It does not give me what I want from the list items,how do I fix this?
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Error",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"Player Data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"ViPLevel",0);
                INI_WriteInt(File,"Money",0);
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"AdminLevel",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);
            }
        }

        case DIALOG_LOGIN:
        {
            if(!response)
            {
                Kick(playerid);
                ShowPlayerDialog(playerid,DIALOG_D_LOGIN, DIALOG_STYLE_MSGBOX,""COL_BLUE"***Kicked***",""COL_LIGHTBLUE"You have been Kicked because you decided not to Login","Ok","");
            }
            if(response)
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_BLUE"Success!",""COL_LIGHTBLUE"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_BLUE"Login",""COL_LIGHTBLUE"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
   
    switch( listitem )
    {
        case DIALOG_FSPBT:
        {
            if (!response)
            {
                SendClientMessage(playerid,COLOR_RED, "You declined the New Player Package!");
            }
            if(response)
            {
                if(listitem == 0)
                {
                    SendClientMessage(playerid,COLOR_BLUE, "You got given Full Armour from the Free Package");
                    GameTextForPlayer(playerid,"~g~Full Armour",3000,6);
                    SetPlayerArmour(playerid, 100.0);
                }
                if(listitem == 1)
                {
                    SendClientMessage(playerid,COLOR_BLUE, "You got given $10,000 from the Free Package");
                    GameTextForPlayer(playerid,"~g~$10,000",3000,6);
                    GivePlayerMoney(playerid, 10000);
                }
                if(listitem == 2)
                {
                    ResetPlayerWeapons(playerid);
                    SendClientMessage(playerid,COLOR_GREEN, "You got given Double Ammo from the Free Package");
                    GameTextForPlayer(playerid,"~g~Double Ammo",3000,6);
                    GivePlayerWeapon(playerid, 34, 160);
                }
            }
        }
       
        case DIALOG_FSPRT:
        {
            if (!response)
            {
                SendClientMessage(playerid,COLOR_RED, "You declined the New Player Package!");
            }
            if(response)
            {
                if(listitem == 0)
                {
                    SendClientMessage(playerid,COLOR_GREEN, "You got given Full Armour from the Free Package");
                    GameTextForPlayer(playerid,"~g~Full Armour",3000,6);
                    SetPlayerArmour(playerid, 100.0);
                }
                if(listitem == 1)
                {
                    SendClientMessage(playerid,COLOR_GREEN, "You got given $10,000 from the Free Package");
                    GameTextForPlayer(playerid,"~g~$10,000",3000,6);
                    GivePlayerMoney(playerid, 10000);
                }
                if(listitem == 2)
                {
                    ResetPlayerWeapons(playerid);
                    SendClientMessage(playerid,COLOR_GREEN, "You got given Double Ammo from the Free Package");
                    GameTextForPlayer(playerid,"~g~Double Ammo",3000,6);
                    GivePlayerWeapon(playerid, 34, 160);
                }
            }
        }
       
        case DIALOG_SHOP:
        {
            if ( !response ) return SendClientMessage(playerid,COLOR_RED, "You exited the Shop Menu!");
            if(response)
            {
                if(listitem == 0)
                {
                    if(GetPlayerMoney(playerid) > 999)
                    {
                        GivePlayerMoney(playerid, -1000);
                        GivePlayerWeapon(playerid, 34,80);
                        SendClientMessage(playerid,COLOR_GREEN, "You Have Bought 80 Shell's of Sniper Ammo");
                    }
                    else SendClientMessage(playerid,COLOR_RED, "ERROR: You Don't Have Enough Money To Buy A Sniper!");
                }
                if(listitem == 1)
                {
                    if(GetPlayerMoney(playerid) > 499)
                    {
                        SetPlayerArmour(playerid,100.0);
                        GivePlayerMoney(playerid, -500);
                        SendClientMessage(playerid,COLOR_GREEN, "You Have Brought Full Armour");
                    }
                    else SendClientMessage(playerid,COLOR_RED, "ERROR: You Don't Have Enough Money To Buy Armour!");
                    return 1;
                }
                return 1;
            }
            return 1;
        }
    }
    return 1;
}
Reply
#2

Hmm i see that youre using first switch( dialogid ) and then switch( listitem ) so change it
Reply
#3

Quote:
Originally Posted by dEcooR
Посмотреть сообщение
Hmm i see that youre using first switch( dialogid ) and then switch( listitem ) so change it
Change it it what exactly? can you show me? please
Reply
#4

well try this

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Error",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"Player Data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"ViPLevel",0);
                INI_WriteInt(File,"Money",0);
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"AdminLevel",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);
            }
        }

        case DIALOG_LOGIN:
        {
            if(!response)
            {
                Kick(playerid);
                ShowPlayerDialog(playerid,DIALOG_D_LOGIN, DIALOG_STYLE_MSGBOX,""COL_BLUE"***Kicked***",""COL_LIGHTBLUE"You have been Kicked because you decided not to Login","Ok","");
            }
            if(response)
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_BLUE"Success!",""COL_LIGHTBLUE"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_BLUE"Login",""COL_LIGHTBLUE"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                    return 1;
				}
            }
        }
        
        case DIALOG_FSPBT:
        {
            if (!response) return SendClientMessage(playerid,COLOR_RED, "You declined the New Player Package!");
            if(response)
            {
                switch(listitem)
                {
	                case 0:
	                {
	                    SendClientMessage(playerid,COLOR_BLUE, "You got given Full Armour from the Free Package");
	                    GameTextForPlayer(playerid,"~g~Full Armour",3000,6);
	                    SetPlayerArmour(playerid, 100.0);
	                }
	                case 1:
	                {
	                    SendClientMessage(playerid,COLOR_BLUE, "You got given $10,000 from the Free Package");
	                    GameTextForPlayer(playerid,"~g~$10,000",3000,6);
	                    GivePlayerMoney(playerid, 10000);
	                }
	                case 2:
	                {
	                    ResetPlayerWeapons(playerid);
	                    SendClientMessage(playerid,COLOR_GREEN, "You got given Double Ammo from the Free Package");
	                    GameTextForPlayer(playerid,"~g~Double Ammo",3000,6);
	                    GivePlayerWeapon(playerid, 34, 160);
	                }
            	}
       	 	}
		}

        case DIALOG_FSPRT:
        {
            if (!response) return SendClientMessage(playerid,COLOR_RED, "You declined the New Player Package!");
            if(response)
            {
                switch(listitem)
                {
	                case 0:
	                {
	                    SendClientMessage(playerid,COLOR_GREEN, "You got given Full Armour from the Free Package");
	                    GameTextForPlayer(playerid,"~g~Full Armour",3000,6);
	                    SetPlayerArmour(playerid, 100.0);
                    }
	                case 1:
	                {
	                    SendClientMessage(playerid,COLOR_GREEN, "You got given $10,000 from the Free Package");
	                    GameTextForPlayer(playerid,"~g~$10,000",3000,6);
	                    GivePlayerMoney(playerid, 10000);
                	}
                	case 2:
	                {
	                    ResetPlayerWeapons(playerid);
	                    SendClientMessage(playerid,COLOR_GREEN, "You got given Double Ammo from the Free Package");
	                    GameTextForPlayer(playerid,"~g~Double Ammo",3000,6);
	                    GivePlayerWeapon(playerid, 34, 160);
                	}
            	}
        	}
       	}

        case DIALOG_SHOP:
        {
            if ( !response ) return SendClientMessage(playerid,COLOR_RED, "You exited the Shop Menu!");
            if(response)
            {
                switch(listitem)
                {
	                case 0:
	                {
	                    if(GetPlayerMoney(playerid) > 999)
	                    {
	                        GivePlayerMoney(playerid, -1000);
	                        GivePlayerWeapon(playerid, 34,80);
	                        SendClientMessage(playerid,COLOR_GREEN, "You Have Bought 80 Shell's of Sniper Ammo");
	                    }
	                    else return SendClientMessage(playerid,COLOR_RED, "ERROR: You Don't Have Enough Money To Buy A Sniper!");
               		}
                	case 1:
	                {
	                    if(GetPlayerMoney(playerid) > 499)
	                    {
	                        SetPlayerArmour(playerid,100.0);
	                        GivePlayerMoney(playerid, -500);
	                        SendClientMessage(playerid,COLOR_GREEN, "You Have Brought Full Armour");
	                    }
	                    else return SendClientMessage(playerid,COLOR_RED, "ERROR: You Don't Have Enough Money To Buy Armour!");
                	}
            	}
        	}
    	}
    }
    return 1;
}
Reply
#5

Worked like a charm,thanks man,so I dont need to switch after the first switch at the top?
Reply
#6

No dude this if(dialogid == DIALODREGISTER) or with switch like this
Reply
#7

No man I mean like after I use switch for dialogid I dont have to use the "switch (listitem)" after it? but still use cases
Reply
#8

Oh,no you see that no only once and then just case case case u understand?
Reply
#9

Yes I understand thanks man,hey you know anyone that knows how to make gangzones?
Reply
#10

Yo dude i know anyone i learned from there too try this https://sampforum.blast.hk/showthread.php?tid=276352
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)