Problem with a dialog
#1

Hey dudes.

Here is a dialog (for car license). I explain the problem: when i type the command, the dialog opens, ok.

But when a double click on a listitem, nothing happens. Why ?

Here is the code:

pawn Код:
if(dialogid==83) // Boite а l'autoEcole
        {
            if(!response) return 1;
            switch(listitem)
            {
                case 0:
                {
               
                    new ActDialog=pTest_actualDialog[playerid];
                    if(ActDialog==-1)
                    { // Boite par default
                        pTest_actualDialog[playerid]=0;
                        pTest_actualTest[playerid]=0;
                        //----------------------
               
                        if(PlayerInfo[playerid][pCarLic]!=0)
                            {SendClientMessage(playerid, COLOR_STATS, "[Permis] Vous avez dйja le permis de conduire."); return 1;}
                        if(PlayerInfo[playerid][pCash]<mairie[permis_car])
                        {
                            new string[MAX_STRING_MSG];
                            format(string,sizeof(string),"[Permis] Le passage du permis coute %d$, vous n'avez pas assez.",mairie[permis_car]);
                            SendClientMessage(playerid, COLOR_STATS, string);
                            return 1;
                        }
                        pay_tempPrice[playerid] = mairie[permis_car];
                        pay_tempType[playerid] = 10;
                        pay_tempArticle[playerid] = 1;
                        pay_showDialog(playerid, mairie[permis_car]);
                       
                        //------------------------------------------
                    }
                    else if(ActDialog>0 && ActDialog<10) // Affichage des diffйrents cours, tout est gerй par une fonction !
                    {
                        test_tutoGestionDialog(playerid,pTest_actualTest[playerid]);
                    }
                    else if(ActDialog>=10 && ActDialog<16) // Questions
                    {
                        if(ActDialog==10)
                        {
                            test_showQuestion(playerid,1,pTest_actualTest[playerid]);
                        }
                        else
                        {
                            test_responseQuestion(playerid,ActDialog-10,listitem,pTest_actualTest[playerid]);
                        }
                    }
                }
                case 1:
                { // Vol
               
                    new ActDialog=pTest_actualDialog[playerid];
                    if(ActDialog==-1)
                    { // Boite par default
                        pTest_actualDialog[playerid]=0;
                        pTest_actualTest[playerid]=0;
                        //----------------------
                        if(PlayerInfo[playerid][pFlyLic]!=0)
                            {SendClientMessage(playerid, COLOR_STATS, "[Permis] Vous avez dйja votre licence de vol."); return 1;}
                        if(PlayerInfo[playerid][pCash]<mairie[permis_fly])
                        {
                            new string[MAX_STRING_MSG];
                            format(string,sizeof(string),"[Permis] L'obtention de la licence de vol coute %d$, vous n'avez pas assez.",mairie[permis_fly]);
                            SendClientMessage(playerid, COLOR_STATS, string);
                            return 1;
                        }
                        pay_tempPrice[playerid] = mairie[permis_fly];
                        pay_tempType[playerid] = 10;
                        pay_tempArticle[playerid] = 2;
                        pay_showDialog(playerid, mairie[permis_fly]);
                       
                    //------------------------------------------
                    }
                    else if(ActDialog>0 && ActDialog<10) // Affichage des diffйrents cours, tout est gerй par une fonction !
                    {
                        test_tutoGestionDialog(playerid,pTest_actualTest[playerid]);
                    }
                    else if(ActDialog>=10 && ActDialog<16) // Questions
                    {
                        if(ActDialog==10)
                        {
                            test_showQuestion(playerid,1,pTest_actualTest[playerid]);
                        }
                        else
                        {
                            test_responseQuestion(playerid,ActDialog-10,listitem,pTest_actualTest[playerid]);
                        }
                    }
                }
                case 2:
                { // Rattrapage
                    new ActDialog=pTest_actualDialog[playerid];
                    if(ActDialog==-1)
                    { // Boite par default
                        pTest_actualDialog[playerid]=0;
                        pTest_actualTest[playerid]=0;
                        //----------------------
               
                        if(PlayerInfo[playerid][pCarLic]==0)
                            {SendClientMessage(playerid, COLOR_STATS, "[Permis] Vous n'avez pas le permis de conduire."); return 1;}
                        if(PlayerInfo[playerid][pLicencePoint]+NBR_PTPERMIS>LICENCE_MAX_POINTS)
                            {SendClientMessage(playerid, COLOR_STATS, "[Permis] Vous avez dйja suffisament de points."); return 1;}
                        new priceTotal=PRIX_PTPERMIS*NBR_PTPERMIS;
                        pay_tempPrice[playerid] = priceTotal;
                        pay_tempType[playerid] = 10;
                        pay_tempArticle[playerid] = 3;
                        pay_showDialog(playerid, priceTotal);
                       
                    //------------------------------------------
                    }
                    else if(ActDialog>0 && ActDialog<10) // Affichage des diffйrents cours, tout est gerй par une fonction !
                    {
                        test_tutoGestionDialog(playerid,pTest_actualTest[playerid]);
                    }
                    else if(ActDialog>=10 && ActDialog<16) // Questions
                    {
                        if(ActDialog==10)
                        {
                            test_showQuestion(playerid,1,pTest_actualTest[playerid]);
                        }
                        else
                        {
                            test_responseQuestion(playerid,ActDialog-10,listitem,pTest_actualTest[playerid]);
                        }
                    }
                }
            }
            return 1;
        }
Reply
#2

Make sure you have

pawn Код:
}
                return 1;
            }
            return 0;
        }
at the bottom of "OnDialogResponse" but no where else under that callback.
Reply
#3

still not work ..
Reply
#4

I have the EXACT same problem just with a different bit of code. Can anyone tell me what I did wrong?

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/v", cmdtext, true, 10) == 0)
	{
		ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Voertuig kiezen", "Turismo\nBMX", "Spawnen", "Annuleren");
		return 1;
	}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new Float:x,Float:y,Float:z;
	if (dialogid == 2 && response)
	{
	    switch(listitem)
	    {
	    
	    
	    
	       case 0:
		{
		    GetPlayerPos(playerid,x,y,z);
		    CreateVehicle(451,x-3.0,y,z,0.0,1,1,-1);
		}
		
		

		case 1:
		{
		    GetPlayerPos(playerid,x,y,z);
			CreateVehicle(481,x-3.0,y,z,0.0,1,1,-1);
		}
	}
}
	return 1;
}
Reply
#5

Quote:
Originally Posted by LilBob
Посмотреть сообщение
Hey dudes.

Here is a dialog (for car license). I explain the problem: when i type the command, the dialog opens, ok.

But when a double click on a listitem, nothing happens. Why ?

Here is the code:

pawn Код:
if(dialogid==83) // Boite а l'autoEcole
        {
            if(!response) return 1;
            switch(listitem)
            {
                case 0:
                {
               
                    new ActDialog=pTest_actualDialog[playerid];
                    if(ActDialog==-1)
                    { // Boite par default
                        pTest_actualDialog[playerid]=0;
                        pTest_actualTest[playerid]=0;
                        //----------------------
               
                        if(PlayerInfo[playerid][pCarLic]!=0)
                            {SendClientMessage(playerid, COLOR_STATS, "[Permis] Vous avez dйja le permis de conduire."); return 1;}
                        if(PlayerInfo[playerid][pCash]<mairie[permis_car])
                        {
                            new string[MAX_STRING_MSG];
                            format(string,sizeof(string),"[Permis] Le passage du permis coute %d$, vous n'avez pas assez.",mairie[permis_car]);
                            SendClientMessage(playerid, COLOR_STATS, string);
                            return 1;
                        }
                        pay_tempPrice[playerid] = mairie[permis_car];
                        pay_tempType[playerid] = 10;
                        pay_tempArticle[playerid] = 1;
                        pay_showDialog(playerid, mairie[permis_car]);
                       
                        //------------------------------------------
                    }
                    else if(ActDialog>0 && ActDialog<10) // Affichage des diffйrents cours, tout est gerй par une fonction !
                    {
                        test_tutoGestionDialog(playerid,pTest_actualTest[playerid]);
                    }
                    else if(ActDialog>=10 && ActDialog<16) // Questions
                    {
                        if(ActDialog==10)
                        {
                            test_showQuestion(playerid,1,pTest_actualTest[playerid]);
                        }
                        else
                        {
                            test_responseQuestion(playerid,ActDialog-10,listitem,pTest_actualTest[playerid]);
                        }
                    }
                }
                case 1:
                { // Vol
               
                    new ActDialog=pTest_actualDialog[playerid];
                    if(ActDialog==-1)
                    { // Boite par default
                        pTest_actualDialog[playerid]=0;
                        pTest_actualTest[playerid]=0;
                        //----------------------
                        if(PlayerInfo[playerid][pFlyLic]!=0)
                            {SendClientMessage(playerid, COLOR_STATS, "[Permis] Vous avez dйja votre licence de vol."); return 1;}
                        if(PlayerInfo[playerid][pCash]<mairie[permis_fly])
                        {
                            new string[MAX_STRING_MSG];
                            format(string,sizeof(string),"[Permis] L'obtention de la licence de vol coute %d$, vous n'avez pas assez.",mairie[permis_fly]);
                            SendClientMessage(playerid, COLOR_STATS, string);
                            return 1;
                        }
                        pay_tempPrice[playerid] = mairie[permis_fly];
                        pay_tempType[playerid] = 10;
                        pay_tempArticle[playerid] = 2;
                        pay_showDialog(playerid, mairie[permis_fly]);
                       
                    //------------------------------------------
                    }
                    else if(ActDialog>0 && ActDialog<10) // Affichage des diffйrents cours, tout est gerй par une fonction !
                    {
                        test_tutoGestionDialog(playerid,pTest_actualTest[playerid]);
                    }
                    else if(ActDialog>=10 && ActDialog<16) // Questions
                    {
                        if(ActDialog==10)
                        {
                            test_showQuestion(playerid,1,pTest_actualTest[playerid]);
                        }
                        else
                        {
                            test_responseQuestion(playerid,ActDialog-10,listitem,pTest_actualTest[playerid]);
                        }
                    }
                }
                case 2:
                { // Rattrapage
                    new ActDialog=pTest_actualDialog[playerid];
                    if(ActDialog==-1)
                    { // Boite par default
                        pTest_actualDialog[playerid]=0;
                        pTest_actualTest[playerid]=0;
                        //----------------------
               
                        if(PlayerInfo[playerid][pCarLic]==0)
                            {SendClientMessage(playerid, COLOR_STATS, "[Permis] Vous n'avez pas le permis de conduire."); return 1;}
                        if(PlayerInfo[playerid][pLicencePoint]+NBR_PTPERMIS>LICENCE_MAX_POINTS)
                            {SendClientMessage(playerid, COLOR_STATS, "[Permis] Vous avez dйja suffisament de points."); return 1;}
                        new priceTotal=PRIX_PTPERMIS*NBR_PTPERMIS;
                        pay_tempPrice[playerid] = priceTotal;
                        pay_tempType[playerid] = 10;
                        pay_tempArticle[playerid] = 3;
                        pay_showDialog(playerid, priceTotal);
                       
                    //------------------------------------------
                    }
                    else if(ActDialog>0 && ActDialog<10) // Affichage des diffйrents cours, tout est gerй par une fonction !
                    {
                        test_tutoGestionDialog(playerid,pTest_actualTest[playerid]);
                    }
                    else if(ActDialog>=10 && ActDialog<16) // Questions
                    {
                        if(ActDialog==10)
                        {
                            test_showQuestion(playerid,1,pTest_actualTest[playerid]);
                        }
                        else
                        {
                            test_responseQuestion(playerid,ActDialog-10,listitem,pTest_actualTest[playerid]);
                        }
                    }
                }
            }
            return 1;
        }
It looks like you are mixing up DIALOG IDs, make sure you didn't use ID 83 for multiple dialogs..

@dahley5

Make sure you didn't use Dialog ID 2 in more than one dialog.

And try this :

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
        switch(dialogid)
        {
            case 2:
            {
                switch(listitem)
                {
                    case 0:
                    {
                        new Float:x,Float:y,Float:z;
                        GetPlayerPos(playerid,x,y,z);
                        CreateVehicle(451,x-3.0,y,z,0.0,1,1,-1);
                    }
                    case 1:
                    {
                        new Float:X,Float:Y,Float:Z;
                        GetPlayerPos(playerid,X,Y,Z);
                        CreateVehicle(481,X-3.0,Y,Z,0.0,1,1,-1);
                    }
                }
            }
        }
        return 1;
    }
    return 0;
}
Reply
#6

Yes, I'm sure I didn't use ID2 for any other because the only other dialog I use is to buy weapons and that one actually works perfectly fine.

I used your script instead, it doesn't give any errors or warnings but it still won't spawn any vehicle when used ingame.

I was wondering how the script you mentioned knows that it's about dialog 2 and not some other dialog?
Reply
#7

Quote:
Originally Posted by dahley5
Посмотреть сообщение
Yes, I'm sure I didn't use ID2 for any other because the only other dialog I use is to buy weapons and that one actually works perfectly fine.

I used your script instead, it doesn't give any errors or warnings but it still won't spawn any vehicle when used ingame.

I was wondering how the script you mentioned knows that it's about dialog 2 and not some other dialog?
Look at the switch(dialogid) part to understand.

Anyway, can you show me your OnPlayerCommandText, cause that code works for me.

and again make sure that you didn't define / use dialogid 2 in a FS / GM.

P.S :

If you have TeamViewer, Can you send me your ID and Password? (In PM)
Reply
#8

i also had alot of dialog mix up problems before.
my friend is coding for samp since its in beta and today he still have this probleme sometime.
this is just to tell you this problem is very common and really not only to beginner !

i and him ended up using fdialog.
no , it is not better just a bit faster.
way easier to deal with id.

it work like that


Код:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "
Код:
fDialog(1)
{
    if(response)
     {
         switch(listitem)
        {
        	case 0:
        	{
and so on...
see how much easy it is... and IF ever you have a mix up , you will get a error at compile time !
using it is just IMPOSSIBLE to mix up the id.

in the GM im working on ( 20% done ) im using like 40 different dialog and have zero problem.

here a screen with mixed up id using fdialog


and here is the include if you want to give it a try
i recommend it to everyone
https://sampforum.blast.hk/showthread.php?tid=260298
Reply
#9

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/v", cmdtext, true, 10) == 0)
	{
		ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Voertuig kiezen", "Turismo\nBMX", "Spawnen", "Annuleren");
		return 1;
	}
	return 0;
}
Reply
#10

Does anyone know what I did wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)