SA-MP Forums Archive
Making a dialog return to a different part of code. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Making a dialog return to a different part of code. (/showthread.php?tid=270405)



Making a dialog return to a different part of code. - slymatt - 20.07.2011

say i hade this dialog

ShowPlayerDialog(playerid, DIALOG_DMV, DIALOG_STYLE_MSGBOX, "DMV Car Licensing", "Would you like to take your car license now? It will cost you $600.", "Yes","No");

if i press yes how can i make it take me to the DMV code?

Regards Matt


Re: Making a dialog return to a different part of code. - Babul - 20.07.2011

in the dialog response callback, the
Код:
if(response)
{
gets triggered when you select the button 1,orselect a menu entry. also the listitem is important then...


Re: Making a dialog return to a different part of code. - slymatt - 20.07.2011

ye but how would that take me back to where the dialog was actually created. because it will look like this:
Код:
///DMV TEST
if(pickupid == dmvcartest)
{
ShowPlayerDialog(playerid, DIALOG_DMV, DIALOG_STYLE_MSGBOX, "DMV Car Licensing", "Would you like to take your car license now? It will cost you $600.", "Yes","No");

///THE DMV CODING

}
because when it reads the dialog box it takes you to
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
So how would i get it back from public on dialog to the pickup code and how would i skip showing the dialog box again =S if you get what i mean.


Re: Making a dialog return to a different part of code. - Grim_ - 20.07.2011

What are you trying to get executed when the player clicks the dialog? Not that right after you show the dialog, the code below it will be called, OnDialogResponse isn't called until the player actually clicks a button on the dialog. So, the "THE DMV CODING" is actually being called, just right after you show the dialog.


Re: Making a dialog return to a different part of code. - slymatt - 20.07.2011

so how would i go about making my dmv script? would i make a new forward? and if so how do you do it?


Re: Making a dialog return to a different part of code. - Grim_ - 20.07.2011

You would need to use the OnDialogResponse callback. You want to check if the player wants to take the test now. If he clicks "Yes" from the dialog (which would be the response of 1), it'll start the test.
pawn Код:
public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{
   switch( dialogid )
   {
      case DIALOG_DMV:
      {
         if( response ) // They've chosen "Yes" from the dialog
         {
            // Rest of your DMV code here
         }
         else // They've chosen "No" form the dialog
         {
            // Rest of "cancel" code here
         }
      }
   }
   return 1;
}



Re: Making a dialog return to a different part of code. - slymatt - 20.07.2011

Thanks alot that works =P


Re: Making a dialog return to a different part of code. - slymatt - 20.07.2011

I was wrong it doesnt seem to work when i enter the dialog it pops up and then if i press yes nothing happens if i press no nothing happens this is what ive got:
Код:
switch(dialogid)
	{
 		case DIALOG_DMVCARTEST:
 		{
 		if(response)
 		{
 		SendClientMessage(playerid, COLOUR_YELLOW, "Welcome to you the DMV Licensing Center");
 		SendClientMessage(playerid, COLOUR_YELLOW, "We will now start your test please head outside");
 		SendClientMessage(playerid, COLOUR_YELLOW, "to the test car outside.");
 		CreateVehicle(404, 1424.6630, -1700.2382, 13.0871, 358.1393, 0, 0, 0);
 		
 		}
   		else
   		{
        SendClientMessage(playerid, COLOUR_YELLOW, "Come back soon, You'll be getting find if you drive without a license.");
		}
 		
 		}

        }



Re: Making a dialog return to a different part of code. - TouR - 20.07.2011

pawn Код:
ShowPlayerDialog(playerid, DIALOG_DMVCARTEST, DIALOG_STYLE_MSGBOX, "DMV Car Licensing", "Would you like to take your car license now? It will cost you $600.", "Yes","No");
Use this to show the dialog


Re: Making a dialog return to a different part of code. - slymatt - 20.07.2011

The dialog shows but it wont show the SendClientMessage bit and wont spawn the car