Help with Dialogs
#1

Hi there, i've some trouble with OnDialogResponse and i can't understand why.
In game it show me the dialogs but when i click or press enter to select an item it doesn't do anything, like the conditions if(response) or !response aren't called.

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
   	new str2[150];
	format(str2, 150, "Arma\tMunizioni\tDisponibile\n\
	Deagle\t9999\tN/D\n\
	Shotgun\t9999\tN/D\n\
	Mp5\t1000\t%d\n\
	M4\t1000\t%d\n\
	Sniper\t100\t%d\n", cwdisarmi[0], cwdisarmi[1], cwdisarmi[2]);
	if(dialogid == 5829)
	{
		if(response)
		{
		    switch(listitem)
		    {
				case 0: GivePlayerWeapon(playerid, 24, 9999);
				case 1: GivePlayerWeapon(playerid, 25, 9999);
				case 2:
						if(cwdisarmi[0] > 0)
						{
							GivePlayerWeapon(playerid, 28, 1000);
							cwdisarmi[0]--;
							SendClientMessage(playerid, -1, "a");
						}
						else
							ShowPlayerDialog(playerid, 5829, DIALOG_STYLE_TABLIST_HEADERS, "Arma n 1", str2, "Vai", "");
				case 3:
						if(cwdisarmi[1] > 0)
						{
							GivePlayerWeapon(playerid, 31, 1000);
							cwdisarmi[1]--;
						}
						else
							ShowPlayerDialog(playerid, 5829, DIALOG_STYLE_TABLIST_HEADERS, "Arma n 1", str2, "Vai", "");
				case 4: 
				        if(cwdisarmi[2] > 0)
						{
							GivePlayerWeapon(playerid, 34, 100);
							cwdisarmi[1]--;
						}
						else
							ShowPlayerDialog(playerid, 5829, DIALOG_STYLE_TABLIST_HEADERS, "Arma n 1", str2, "Vai", "");
			}
   			return ShowPlayerDialog(playerid, 5830, DIALOG_STYLE_TABLIST_HEADERS, "Arma n° 2", str2, "Vai", "");
		}
		else if(!response)
			return ShowPlayerDialog(playerid, 5829, DIALOG_STYLE_TABLIST_HEADERS, "Arma n 1", str2, "Vai", "");
	}
	if(dialogid == 5830)
	{
		if(response)
		{
		    switch(listitem)
		    {
		        case 0:
					if(GetPlayerWeapon(playerid) != 24)
						GivePlayerWeapon(playerid, 24, 9999), cwtimer[playerid][1] = 1;
					else
					    ShowPlayerDialog(playerid, 5830, DIALOG_STYLE_TABLIST_HEADERS, "Arma n° 2", str2, "Vai", "");
				case 1:
		        	if(GetPlayerWeapon(playerid) != 25)
						GivePlayerWeapon(playerid, 25, 9999), cwtimer[playerid][1] = 1;
					else
					    ShowPlayerDialog(playerid, 5830, DIALOG_STYLE_TABLIST_HEADERS, "Arma n° 2", str2, "Vai", "");
				case 2:
				    if(GetPlayerWeapon(playerid) != 28)
						GivePlayerWeapon(playerid, 28, 9999), cwtimer[playerid][1] = 1;
					else
					    ShowPlayerDialog(playerid, 5830, DIALOG_STYLE_TABLIST_HEADERS, "Arma n° 2", str2, "Vai", "");
				case 3:
                    if(GetPlayerWeapon(playerid) != 31)
						GivePlayerWeapon(playerid, 31, 9999), cwtimer[playerid][1] = 1;
					else
					    ShowPlayerDialog(playerid, 5830, DIALOG_STYLE_TABLIST_HEADERS, "Arma n° 2", str2, "Vai", "");
				case 4:
				    if(GetPlayerWeapon(playerid) != 34)
						GivePlayerWeapon(playerid, 34, 9999), cwtimer[playerid][1] = 1;
					else
					    ShowPlayerDialog(playerid, 5830, DIALOG_STYLE_TABLIST_HEADERS, "Arma n° 2", str2, "Vai", "");
			}
			return 1;
		}
		else if(!response)
			    return ShowPlayerDialog(playerid, 5830, DIALOG_STYLE_TABLIST_HEADERS, "Arma n° 2", str2, "Vai", "");
	}
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
Reply
#2

can you show us the command of showing this dialogs ?
Reply
#3

I have taken a really really quick look at it and from first glance it seems that no matter what the case is, you show the very same dialog each time.

When you press a button, a dialog is shown, and when you press that one, it is shown again, etc..

Again, I may be wrong so I looked at it so briefly while walking to the bus.
Reply
#4

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
       new 
str2[150];
    
format(str2150"Arma\tMunizioni\tDisponibile\n\
    Deagle\t9999\tN/D\n\
    Shotgun\t9999\tN/D\n\
    Mp5\t1000\t%d\n\
    M4\t1000\t%d\n\
    Sniper\t100\t%d\n"
cwdisarmi[0], cwdisarmi[1], cwdisarmi[2]);
    if(
dialogid == 5829)
    {
        if(
response)
        {
            switch(
listitem)
            {
                case 
0GivePlayerWeapon(playerid249999);
                case 
1GivePlayerWeapon(playerid259999);
                case 
2:
                        if(
cwdisarmi[0] > 0)
                        {
                            
GivePlayerWeapon(playerid281000);
                            
cwdisarmi[0]--;
                            
SendClientMessage(playerid, -1"a");
                        }
                case 
3:
                        if(
cwdisarmi[1] > 0)
                        {
                            
GivePlayerWeapon(playerid311000);
                            
cwdisarmi[1]--;
                        }
                case 
4
                        if(
cwdisarmi[2] > 0)
                        {
                            
GivePlayerWeapon(playerid34100);
                            
cwdisarmi[1]--;
                        }
            }
               return 
ShowPlayerDialog(playerid5830DIALOG_STYLE_TABLIST_HEADERS"Arma n° 2"str2"Vai""");
        }
    }
    if(
dialogid == 5830)
    {
        if(
response)
        {
            switch(
listitem)
            {
                case 
0:
                    if(
GetPlayerWeapon(playerid) != 24)
                        
GivePlayerWeapon(playerid249999), cwtimer[playerid][1] = 1;
                case 
1:
                    if(
GetPlayerWeapon(playerid) != 25)
                        
GivePlayerWeapon(playerid259999), cwtimer[playerid][1] = 1;
                case 
2:
                    if(
GetPlayerWeapon(playerid) != 28)
                        
GivePlayerWeapon(playerid289999), cwtimer[playerid][1] = 1;
                case 
3:
                    if(
GetPlayerWeapon(playerid) != 31)
                        
GivePlayerWeapon(playerid319999), cwtimer[playerid][1] = 1;
                case 
4:
                    if(
GetPlayerWeapon(playerid) != 34)
                        
GivePlayerWeapon(playerid349999), cwtimer[playerid][1] = 1;
            }
            return 
1;
        }
    }
    return 
0// You MUST return 0 here! Just like OnPlayerCommandText.

@Denying +1
Reply
#5

Quote:
Originally Posted by Denying
Посмотреть сообщение
I have taken a really really quick look at it and from first glance it seems that no matter what the case is, you show the very same dialog each time.

When you press a button, a dialog is shown, and when you press that one, it is shown again, etc..

Again, I may be wrong so I looked at it so briefly while walking to the bus.
There is only one button and if you look at the response condition you see that should go on calling other dialog, 5830


PHP код:
forward CWDialog(playerid);
public 
CWDialog(playerid)
{
    new 
str[15], str2[150];
    
SendClientMessage(playeridCOLOR_RED"*** Scegli entro 10 secondi il tuo set d'armi!");
    if(
GetPlayerWeapon(playerid) == 0)
    {
        
format(str15"Arma n° 1");
        
cwtimer[playerid][1] = SetTimerEx("CWDialog"10000false"i"playerid);
    }
    else
        
format(str15"Arma n° 2");
    
format(str2150"Arma\tMunizioni\tDisponibile\n\
    Deagle\t9999\tN/D\n\
    Shotgun\t9999\tN/D\n\
    Mp5\t1000\t%d\n\
    M4\t1000\t%d\n\
    Sniper\t100\t%d\n"
cwdisarmi[0], cwdisarmi[1], cwdisarmi[2]);
     
ShowPlayerDialog(playerid5829DIALOG_STYLE_TABLIST_HEADERSstrstr2"Vai""");
    return 
1;
}
CMD:joincw(playeridparams[])
{
    if(!
CWmod) return SendClientMessage(playeridCOLOR_RED"*** L'evento non и attivo!");
    
//if(pcw[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "*** Sei giа all'evento!");
    
if(posticw >= 20) return SendClientMessage(playeridCOLOR_RED"*** Posti finiti!");
    if((
posticw 2) == 0)
        
SettaVarCW(2playerid);
     else
        
SettaVarCW(3playerid);
    
ShowZoneForPlayer(playeridcwzoneCOLOR_RED, -1COLOR_YELLOW);
    
pcw[playerid] = 1;
    
SetPlayerTeam(playerid10);
    
SetPlayerHealth(playerid9999);
    
SetPlayerColor(playeridCOLOR_RED);
    
SetPlayerPos(playeridarenacw[idarenacw][4], arenacw[idarenacw][5], arenacw[idarenacw][6]+4);
    
SetPlayerFacingAngle(playeridarenacw[idarenacw][7]);
    
SetPlayerVirtualWorld(playerid3804);
    
SetPlayerInterior(playerid0);
    
ResetPlayerWeapons(playerid);
    
cwtimer[playerid][1] = SetTimerEx("CWDialog"5000false"i"playerid);
    new 
string[50];
    
format(stringsizeof string"*** Posti disponibili nell'evento: %d/20"20-(++posticw));
    
SendClientMessageToAll(COLOR_GREENstring);
    return 
1;

Reply
#6

Quote:
Originally Posted by Yaa
Посмотреть сообщение
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
       new 
str2[150];
    
format(str2150"Arma\tMunizioni\tDisponibile\n\
    Deagle\t9999\tN/D\n\
    Shotgun\t9999\tN/D\n\
    Mp5\t1000\t%d\n\
    M4\t1000\t%d\n\
    Sniper\t100\t%d\n"
cwdisarmi[0], cwdisarmi[1], cwdisarmi[2]);
    if(
dialogid == 5829)
    {
        if(
response)
        {
            switch(
listitem)
            {
                case 
0GivePlayerWeapon(playerid249999);
                case 
1GivePlayerWeapon(playerid259999);
                case 
2:
                        if(
cwdisarmi[0] > 0)
                        {
                            
GivePlayerWeapon(playerid281000);
                            
cwdisarmi[0]--;
                            
SendClientMessage(playerid, -1"a");
                        }
                case 
3:
                        if(
cwdisarmi[1] > 0)
                        {
                            
GivePlayerWeapon(playerid311000);
                            
cwdisarmi[1]--;
                        }
                case 
4
                        if(
cwdisarmi[2] > 0)
                        {
                            
GivePlayerWeapon(playerid34100);
                            
cwdisarmi[1]--;
                        }
            }
               return 
ShowPlayerDialog(playerid5830DIALOG_STYLE_TABLIST_HEADERS"Arma n° 2"str2"Vai""");
        }
    }
    if(
dialogid == 5830)
    {
        if(
response)
        {
            switch(
listitem)
            {
                case 
0:
                    if(
GetPlayerWeapon(playerid) != 24)
                        
GivePlayerWeapon(playerid249999), cwtimer[playerid][1] = 1;
                case 
1:
                    if(
GetPlayerWeapon(playerid) != 25)
                        
GivePlayerWeapon(playerid259999), cwtimer[playerid][1] = 1;
                case 
2:
                    if(
GetPlayerWeapon(playerid) != 28)
                        
GivePlayerWeapon(playerid289999), cwtimer[playerid][1] = 1;
                case 
3:
                    if(
GetPlayerWeapon(playerid) != 31)
                        
GivePlayerWeapon(playerid319999), cwtimer[playerid][1] = 1;
                case 
4:
                    if(
GetPlayerWeapon(playerid) != 34)
                        
GivePlayerWeapon(playerid349999), cwtimer[playerid][1] = 1;
            }
            return 
1;
        }
    }
    return 
0// You MUST return 0 here! Just like OnPlayerCommandText.

@Denying +1
I want to re-show the dialog if a weapon is no more available, so i must check the availability.
And must re-show the dialog if !response, then when a player type ESC
Reply
#7

Also i tested your code and doen't work for the same problems.
There's no dialog id in conflict with any scripts.
Reply
#8

Ok joke, some fs were in conflict.
Solved, thank you all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)