[HELP]dialog response
#1

Hello I was made dialog for buying house for example player is near house and he get in dialog this house is on buy. Know he must click Buy or Exit how can I make if player click on exit then I want to send some message I was try like this but it doens't work I go exit and nothing happens

pawn Код:
if(dialogid == 371)
    {
        if(!response)
        {
            SendClientMessage(playerid,COLOR_YELLOW,"You exit from dialog!");
            return 1; I was try with return and without it but it doens't send anything if I press Exit in dialog
        }
        if(response)
        {
//here is code for house buy
        }
    }]
Reply
#2

Are you sure the dialogid is 371?
Reply
#3

yes and the dialog is dialog_style_msxbox I just read on wiki and it says to put like these


pawn Код:
if(dialogid == 371)
    {
        if(response)
        {
//code for response
        }
        else //if player click cancel or something
        {
            and I click cancel but nothing happens but I put some text if player click cancel
        }
    }
Reply
#4

Can you show us the ShowPlayerDialog for dialogid 371?
Reply
#5

pawn Код:
new message1[256];
                format(message1,sizeof(message1),"{33AA33}This vehicle is renting!\n\n{FFFFFF}The price of vehicle: {33AA33}%d$\n\n{FFFFFF}Click on {33AA33}Rent {FFFFFF}or {33AA33}Cancel",RentACar2[x][2]);
                ShowPlayerDialog(playerid,371,DIALOG_STYLE_MSGBOX,"{33AA33}Rent Car",message1,"Rent","Cancel");
when I click on rent car it's okay I rent the vehicle but the problem is with cancel
Reply
#6

Is that code in your gamemode?
And do you have some filterscripts loaded as well?

In that case, check your filterscripts and check the OnDialogResponse callback in those filterscripts.
At the end of the callback, when no dialog has been processed there, it should hold "return 0;", like this:
pawn Код:
// This callback gets called when a player interacts with a dialog
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    // Select the proper dialog to process
    switch (dialogid)
    {
        case DialogSupportSettings: Dialog_SupportSettings(playerid, response, listitem); // Process the SupportSettings main-menu
        case DialogNewGlobConsumptionMul: Dialog_NewGlobConsumptionMul(playerid, response, inputtext); // Process the value given for a new GlobalConsumptionMul setting
        case DialogNewPricePerLitre: Dialog_NewPricePerLitre(playerid, response, inputtext); // Process the value given for a new PricePerLitre setting
        case DialogNewFinePerUnit: Dialog_NewFinePerUnit(playerid, response, inputtext); // Process the value given for a new FinePerUnit setting

        case DialogRegister: Dialog_Register(playerid, response, inputtext); // The "Register"-dialog
        case DialogLogin: Dialog_Login(playerid, response, inputtext); // The "Login"-dialog

        case DialogSelectVehicleClass: Dialog_SelectVehicleClass(playerid, response, listitem); // Process the chosen vehicle-class when using the /v or /editv commands
        case DialogSelectVehicle: Dialog_SelectVehicle(playerid, response, listitem); // Spawn a vehicle with /v or edit it's model-data using /editv
        case DialogSelectVehicleModelData: Dialog_SelectVehicleModelData(playerid, response, listitem); // Process the chosen vehiclemodel-data to be edited
        case DialogVModelNewPrice: Dialog_VModelNewPrice(playerid, response, inputtext);
        case DialogVModelNewMaxFuel: Dialog_VModelNewMaxFuel(playerid, response, inputtext);
        case DialogVModelNewConsumption: Dialog_VModelNewConsumption(playerid, response, inputtext);
        case DialogVModelNewRefuelTime: Dialog_VModelNewRefuelTime(playerid, response, inputtext);

        case DialogBuyCompany: Dialog_BuyCompany(playerid, response);
        case DialogBuyCompanyAskName: Dialog_BuyCompanyAskName(playerid, response, inputtext);
        case DialogInviteToCompany: Dialog_InviteToCompany(playerid, response);
        case DialogCompanyData: Dialog_CompanyData(playerid, response, listitem);
        case DialogCompanyLeave: Dialog_CompanyLeave(playerid, response);
    }

    // A filterscript should always return 0 here, otherwise the other filterscripts and the gamemode cannot process any dialog
    return 0;
}
The last line MUST return 0 in filterscripts in case no dialog was processed.
If it returns 1 in a filterscript, processing dialogs stops right there and the server won't process any other dialogs from other filterscripts and the gamemode.
Reply
#7

Do I need then return 0 in callback ondialogresponse in my gamemode? I know have return 1 at the end. Thanks
Reply
#8

Quote:

Returning 0 in this callback will pass the dialog to another script in case no matching code were found in your gamemode's callback.

You mustn't "return 1;" at any other filterscripts as they block the OnDialogResponse on the gamemode
Reply
#9

I delete all filterscripts and know I go to server and click on cancel and nothing happens.
Reply
#10

Proper way to use dialogs
If you found no problems try to make a new blank gamemode with only the command that shows the dialog and the response, just for testing.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)