dialog response not happening?
#1

Hi guys,
So im having a little problem here: when a dialog is shown and the player chooses something from the 2 listed lines it doesnt respond like it should start a script but its not working.

Ill leave the code here:

PHP код:
if(clickedid == carselect17)
    {
        
SetPlayerPos(playeridplayerposescolherX[playerid],playerposescolherY[playerid],playerposescolherZ[playerid]);
         
SetPlayerInterior(playeridplayerintescolher[playerid]);
         
SetPlayerVirtualWorld(playeridplayervirtualworldescolher[playerid]);
        
TextDrawHideForPlayer(playeridcarselect0);
        
TextDrawHideForPlayer(playeridcarselect1);
        
TextDrawHideForPlayer(playeridcarselect2);
        
TextDrawHideForPlayer(playeridcarselect3);
        
TextDrawHideForPlayer(playeridcarselect4);
        
TextDrawHideForPlayer(playeridcarselect5);
        
TextDrawHideForPlayer(playeridcarselect6);
        
TextDrawHideForPlayer(playeridcarselect7);
        
TextDrawHideForPlayer(playeridcarselect8);
        
TextDrawHideForPlayer(playeridcarselect9);
        
TextDrawHideForPlayer(playeridcarselect10);
        
TextDrawHideForPlayer(playeridcarselect11);
        
TextDrawHideForPlayer(playeridcarselect12);
        
TextDrawHideForPlayer(playeridcarselect13);
        
TextDrawHideForPlayer(playeridcarselect14);
        
TextDrawHideForPlayer(playeridcarselect15);
        
TextDrawHideForPlayer(playeridcarselect16);
        
TextDrawHideForPlayer(playeridcarselect17);
        
TextDrawHideForPlayer(playeridcarselect18);
        
TextDrawHideForPlayer(playeridcarselect19);
        
TextDrawHideForPlayer(playeridcarselect20);
        
TextDrawHideForPlayer(playeridcarselect21);
        
TextDrawHideForPlayer(playeridcarselect22);
        
TextDrawHideForPlayer(playeridcarselect23);
        
TextDrawHideForPlayer(playeridcarselect24);
        
TextDrawHideForPlayer(playeridcarselect25);
        
SetCameraBehindPlayer(playerid);
        
CancelSelectTextDraw(playerid);
        
ShowPlayerDialog(playerid1070DIALOG_STYLE_LIST"Escolhe o tipo de combustivel:","Gasoleo\nGasolina","Escolher""Cancelar");
    } 
PHP код:
if(dialogid == 1070)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                new 
TCarModel carroapresentar[playerid];
                
escolhacombustivel[playerid] = 1;
                
tipocombustivel[playerid] = 1;
                new 
valorveiculo TCarModel-400;
                new 
precoveiculo VehiclePrices[valorveiculo][0];
                 for(new 
0sizeof(Businesses); i++)
                    {
                        if(
PlayerToPoint(25.0playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ]))
                        {
                            if(
GetPlayerVirtualWorld(playerid) == i)
                            {
                                if(
Businesses[i][BizType] == 9)
                                {
                                    for(new 
c=0;c<MAX_VEHICLES;c++)
                                    {
                                        if(
DynamicCars[c][comprado] == 0// Nгo comprado
                                        
{
                                            if(
DynamicCars[c][valor] == 0// Sem Preзo
                                            
{
                                                if(
DynamicCars[c][buy] == 1// Para venda
                                                
{
                                                    if(
DynamicCars[c][CarModel] == 481)
                                                    {
                                                        if(
IsValidModel(TCarModel))
                                                        {
                                                            
SendClientMessage(playeridCOLOR_GREY"========================================================================================================");
                                                            
SendClientMessage(playeridCOLOR_WHITE"Compraste o veiculo com sucesso. Este aparecerб na marinha de Palomino Creek em 10 horas ingame");
                                                            
SendClientMessage(playeridCOLOR_GREY"========================================================================================================");
                                                                
SetTimerEx("buyvehtime"2000false"iii"playeridTCarModelc);
                                                                if(
PlayerInfo[playerid][pVipActive] != 0)
                                                                {
                                                                
GivePlayerEuros(playerid, -precoveiculo/2);
                                                                
Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/2/100);
                                                                   
Businesses[i][Till]+=precoveiculo;
                                                                
OnPlayerDataSave(playerid);
                                                                }
                                                                else
                                                                {
                                                                
GivePlayerEuros(playerid, -precoveiculo);
                                                                
Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/100);
                                                                   
Businesses[i][Till]+=precoveiculo;
                                                                }
                                                                if(
PlayerInfo[playerid][pChave1] == 255)
                                                                {
                                                                   
PlayerInfo[playerid][pChave1] = c+1;
                                                                  return 
1;
                                                                  }
                                                                else if(
PlayerInfo[playerid][pChave2] == 255)
                                                                 {
                                                                  
PlayerInfo[playerid][pChave2] = c+1;
                                                                return 
1;
                                                                }
                                                                   else if(
PlayerInfo[playerid][pChave3] == 255)
                                                                  {
                                                                
PlayerInfo[playerid][pChave3] = c+1;
                                                                return 
1;
                                                                }
                                                                   else if(
PlayerInfo[playerid][pChave4] == 255)
                                                                  {
                                                                
PlayerInfo[playerid][pChave4] = c+1;
                                                                return 
1;
                                                                }
                                                                   else if(
PlayerInfo[playerid][pChave5] == 255)
                                                                   {
                                                                   
PlayerInfo[playerid][pChave5] = c+1;
                                                                  return 
1;
                                                                  }
                                                                else if(
PlayerInfo[playerid][pChave6] == 255)
                                                                {
                                                                   
PlayerInfo[playerid][pChave6] = c+1;
                                                                   return 
1;
                                                                }
                                                        }
                                                        else
                                                        {
                                                            
SendClientMessage(playeridCOLOR_RED,"{FF0000}[Erro]: {FFFFFF}Modelo Invбlido.");
                                                            return 
1;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                       return 
1;
                                }
                            }
                        }
                    }
            }
            if(
listitem == 1)
            {
                new 
TCarModel carroapresentar[playerid];
                
escolhacombustivel[playerid] = 1;
                
tipocombustivel[playerid] = 2;
                new 
valorveiculo TCarModel-400;
                new 
precoveiculo VehiclePrices[valorveiculo][0];
                
precoveiculo *= 0.9;
                for(new 
0sizeof(Businesses); i++)
                    {
                        if(
PlayerToPoint(25.0playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ]))
                        {
                            if(
GetPlayerVirtualWorld(playerid) == i)
                            {
                                if(
Businesses[i][BizType] == 9)
                                {
                                    for(new 
c=0;c<MAX_VEHICLES;c++)
                                    {
                                        if(
DynamicCars[c][comprado] == 0// Nгo comprado
                                        
{
                                            if(
DynamicCars[c][valor] == 0// Sem Preзo
                                            
{
                                                if(
DynamicCars[c][buy] == 1// Para venda
                                                
{
                                                    if(
DynamicCars[c][CarModel] == 481)
                                                    {
                                                        if(
IsValidModel(TCarModel))
                                                        {
                                                            
SendClientMessage(playeridCOLOR_GREY"========================================================================================================");
                                                            
SendClientMessage(playeridCOLOR_WHITE"Compraste o veiculo com sucesso. Este aparecerб na marinha de Palomino Creek em 10 horas ingame");
                                                            
SendClientMessage(playeridCOLOR_GREY"========================================================================================================");
                                                                
SetTimerEx("buyvehtime"2000false"iii"playeridTCarModelc);
                                                                if(
PlayerInfo[playerid][pVipActive] != 0)
                                                                {
                                                                
GivePlayerEuros(playerid, -precoveiculo/2);
                                                                
Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/2/100);
                                                                   
Businesses[i][Till]+=precoveiculo;
                                                                
OnPlayerDataSave(playerid);
                                                                }
                                                                else
                                                                {
                                                                
GivePlayerEuros(playerid, -precoveiculo);
                                                                
Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/100);
                                                                   
Businesses[i][Till]+=precoveiculo;
                                                                }
                                                                if(
PlayerInfo[playerid][pChave1] == 255)
                                                                {
                                                                   
PlayerInfo[playerid][pChave1] = c+1;
                                                                  return 
1;
                                                                  }
                                                                else if(
PlayerInfo[playerid][pChave2] == 255)
                                                                 {
                                                                  
PlayerInfo[playerid][pChave2] = c+1;
                                                                return 
1;
                                                                }
                                                                   else if(
PlayerInfo[playerid][pChave3] == 255)
                                                                  {
                                                                
PlayerInfo[playerid][pChave3] = c+1;
                                                                return 
1;
                                                                }
                                                                   else if(
PlayerInfo[playerid][pChave4] == 255)
                                                                  {
                                                                
PlayerInfo[playerid][pChave4] = c+1;
                                                                return 
1;
                                                                }
                                                                   else if(
PlayerInfo[playerid][pChave5] == 255)
                                                                   {
                                                                   
PlayerInfo[playerid][pChave5] = c+1;
                                                                  return 
1;
                                                                  }
                                                                else if(
PlayerInfo[playerid][pChave6] == 255)
                                                                {
                                                                   
PlayerInfo[playerid][pChave6] = c+1;
                                                                   return 
1;
                                                                }
                                                        }
                                                        else
                                                        {
                                                            
SendClientMessage(playeridCOLOR_RED,"{FF0000}[Erro]: {FFFFFF}Modelo Invбlido.");
                                                            return 
1;
                                                        }
                                                    }
                                                    else
                                                    {
                                                    
SendClientMessage(playeridCOLOR_RED"Teste1");
                                                    }
                                                }
                                                else
                                                {
                                                
SendClientMessage(playeridCOLOR_RED"Teste2");
                                                }
                                            }
                                            else
                                            {
                                            
SendClientMessage(playeridCOLOR_RED"Teste3");
                                            }
                                        }
                                        else
                                        {
                                        
SendClientMessage(playeridCOLOR_RED"Teste4");
                                        }
                                    }
                                       return 
1;
                                }
                                else
                                {
                                
SendClientMessage(playeridCOLOR_RED"Teste5");
                                }
                            }
                            else
                            {
                            
SendClientMessage(playeridCOLOR_RED"Teste6");
                            }
                        }
                        else
                        {
                        
SendClientMessage(playeridCOLOR_RED"Teste7");
                        }
                    }
            }
        }
    } 




Note: those sendclientmessage were for me too see if there was anything wrong with the script but didnt find out anything.
Reply
#2

does any 1 know whats really happening? please
Reply
#3

Maybe one of your if-statements doesn't equal with the value you have given there.

In
Код:
listitem == 0
you aren't returning anything when the if-statement doesn't equal, but in
Код:
listitem == 1
you do this.

I have improved your code a bit, because it was looking very very messy and there were meaningless lines.

pawn Код:
if(dialogid == 1070)
{
    if(response)
    {
        new TCarModel = carroapresentar[playerid];
        escolhacombustivel[playerid] = 1;
        new valorveiculo = TCarModel-400;
        new precoveiculo = VehiclePrices[valorveiculo][0];

        if(listitem == 0)
        {
            tipocombustivel[playerid] = 1;
        }
        if(listitem == 1)
        {
            tipocombustivel[playerid] = 2;
            precoveiculo *= 0.9;
        }

        for(new i = 0; i < sizeof(Businesses); i++)
        {

            if(!PlayerToPoint(25.0, playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ])) continue;

            if(!GetPlayerVirtualWorld(playerid) == i) continue;

            if(Businesses[i][BizType] != 9) continue;

            for(new c=0;c<MAX_VEHICLES;c++)
            {
                if(DynamicCars[c][comprado] != 0) continue;

                if(DynamicCars[c][valor] != 0) continue;

                if(DynamicCars[c][buy] != 1) continue;

                if(DynamicCars[c][CarModel] != 481) continue;
 
                if(!IsValidModel(TCarModel))
                    return SendClientMessage(playerid, COLOR_RED,"{FF0000}[Erro]: {FFFFFF}Modelo Invбlido.");

                SendClientMessage(playerid, COLOR_GREY, "========================================================================================================");
                SendClientMessage(playerid, COLOR_WHITE, "Compraste o veiculo com sucesso. Este aparecerб na marinha de Palomino Creek em 10 horas ingame");
                SendClientMessage(playerid, COLOR_GREY, "========================================================================================================");

                SetTimerEx("buyvehtime", 2000, false, "iii", playerid, TCarModel, c);

                if(PlayerInfo[playerid][pVipActive] != 0)
                {
                    GivePlayerEuros(playerid, -precoveiculo/2);
                    Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/2/100);
                    Businesses[i][Till]+=precoveiculo;
                    OnPlayerDataSave(playerid);
                }
                else
                {
                    GivePlayerEuros(playerid, -precoveiculo);
                    Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/100);
                    Businesses[i][Till]+=precoveiculo;
                }

                if(PlayerInfo[playerid][pChave1] == 255)
                {
                    PlayerInfo[playerid][pChave1] = c+1;
                    return 1;
                }
                else if(PlayerInfo[playerid][pChave2] == 255)
                {
                    PlayerInfo[playerid][pChave2] = c+1;
                    return 1;
                }
                else if(PlayerInfo[playerid][pChave3] == 255)
                {
                    PlayerInfo[playerid][pChave3] = c+1;
                    return 1;
                }
                else if(PlayerInfo[playerid][pChave4] == 255)
                {
                    PlayerInfo[playerid][pChave4] = c+1;
                    return 1;
                }
                else if(PlayerInfo[playerid][pChave5] == 255)
                {
                    PlayerInfo[playerid][pChave5] = c+1;
                    return 1;
                }
                else if(PlayerInfo[playerid][pChave6] == 255)
                {
                   PlayerInfo[playerid][pChave6] = c+1;
                   return 1;
                }
            }
            return 1;
        }
    }
}
Tip: Always comment your code.
Reply
#4

Thanks man. Im sorry for the messy stuff started coding a month ago and im only 14 id say for the stuff i can make im in a good path. But srsly thanks again

EDIT: Hum somehow the code still doesnt run. Goddangit :S
Reply
#5

please anyone?
Reply
#6

Quote:

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}

If you forgot to return 0; or did return 1; in any of your earlier filterscripts, it wont work. Check all your other Dialogs. And make sure to return 0; at the end of DialogResponse..
https://sampwiki.blast.hk/wiki/OnDialogResponse
Reply
#7

Checked changed to return 0 still doesnt work. All the others work but this one just doesnt want to work! any other ideas?
Reply
#8

PHP код:
print('Debug points'); 
PHP код:
printf('%i Listitem'listitem); 
Even use your SendClientMessage setup in different spots rather than simply on the fail. Do it before you check anything so you know what it is indeed returning.

I'd also suggest to go back to what you had in the first place if it was working in other sections.
Reply
#9

So i did that and i found out that nothing really happens when u press those buttons. I removed the bizz thing and replaced directly with the bizz id imma leave here what i did:
PHP код:
if(dialogid == 169)
{
    if(
response)
    {
        
SendClientMessage(playeridCOLOR_RED"test");
        new 
TCarModel carroapresentar[playerid];
        
escolhacombustivel[playerid] = 1;
        new 
valorveiculo TCarModel-400;
        new 
precoveiculo VehiclePrices[valorveiculo][0];
        if(
listitem == 0)
        {
            
tipocombustivel[playerid] = 1;
            
SendClientMessage(playeridCOLOR_RED"op1");
        }
        if(
listitem == 1)
        {
            
tipocombustivel[playerid] = 2;
            
SendClientMessage(playeridCOLOR_RED"op2");
            
precoveiculo *= 0.9;
        }
        
SendClientMessage(playeridCOLOR_RED"test999");
            for(new 
c=0;c<MAX_VEHICLES;c++)
            {
                if(
DynamicCars[c][comprado] != 0) continue;
                
SendClientMessage(playeridCOLOR_RED"test5");
                if(
DynamicCars[c][valor] != 0) continue;
                
SendClientMessage(playeridCOLOR_RED"test6");
                if(
DynamicCars[c][buy] != 1) continue;
                
SendClientMessage(playeridCOLOR_RED"test7");
                if(
DynamicCars[c][CarModel] != 481) continue;
                
SendClientMessage(playeridCOLOR_RED"test8");
                if(!
IsValidModel(TCarModel))
                    return 
SendClientMessage(playeridCOLOR_RED,"{FF0000}[Erro]: {FFFFFF}Modelo Invбlido.");
                
SendClientMessage(playeridCOLOR_GREY"========================================================================================================");
                
SendClientMessage(playeridCOLOR_WHITE"Compraste o veiculo com sucesso. Este aparecerб na marinha de Palomino Creek em 10 horas ingame");
                
SendClientMessage(playeridCOLOR_GREY"========================================================================================================");
                
SetTimerEx("buyvehtime"2000false"iii"playeridTCarModelc);
                if(
PlayerInfo[playerid][pVipActive] != 0)
                {
                    
GivePlayerEuros(playerid, -precoveiculo/2);
                    
Businesses[1][Products]=Businesses[1][Products]-(precoveiculo/2/100);
                       
Businesses[1][Till]+=precoveiculo;
                    
OnPlayerDataSave(playerid);
                }
                else
                {
                    
GivePlayerEuros(playerid, -precoveiculo);
                    
Businesses[1][Products]=Businesses[1][Products]-(precoveiculo/100);
                       
Businesses[1][Till]+=precoveiculo;
                }
                if(
PlayerInfo[playerid][pChave1] == 255)
                {
                       
PlayerInfo[playerid][pChave1] = c+1;
                      return 
1;
                }
                else if(
PlayerInfo[playerid][pChave2] == 255)
                {
                      
PlayerInfo[playerid][pChave2] = c+1;
                    return 
1;
                }
                else if(
PlayerInfo[playerid][pChave3] == 255)
                {
                    
PlayerInfo[playerid][pChave3] = c+1;
                    return 
1;
                }
                else if(
PlayerInfo[playerid][pChave4] == 255)
                {
                    
PlayerInfo[playerid][pChave4] = c+1;
                    return 
1;
                }
                else if(
PlayerInfo[playerid][pChave5] == 255)
                {
                    
PlayerInfo[playerid][pChave5] = c+1;
                      return 
1;
                }
                else if(
PlayerInfo[playerid][pChave6] == 255)
                {
                   
PlayerInfo[playerid][pChave6] = c+1;
                   return 
1;
                }
            }
            return 
1;
    }

From all those sendclientmessage only the first one works. Why is the script returning after the response?
Reply
#10

That's why I said to output the actual listitem... Then you'd know what it's putting out when you are using that.

With those messages though you should see test, and test999. If you don't then there's something really screwed up with it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)