SA-MP Forums Archive
Saving a dialog for later - 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)
+--- Thread: Saving a dialog for later (/showthread.php?tid=375529)



Saving a dialog for later - RedFusion - 07.09.2012

How do i save a dialog into for e.g a variable? And then use it later?


Re: Saving a dialog for later - HuSs3n - 07.09.2012

pawn Код:
//On Top
new DialogStr[256];
//Saving the string
format(DialogStr,sizeof(DialogStr),".....................................");
//Using it
ShowPlayerDialog(playerid,ID,DIALOG_STYLE_MSGBOX,"Dialog",DialogStr,"1","2");



Re: Saving a dialog for later - [DOG]irinel1996 - 07.09.2012

You should put it in a constant, would be much better.
pawn Код:
#define DIALOG "Hello, my nickname is %s!"

new string[128];
format(string,128,""DIALOG" and this is another text included!","irinel1996");
ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"My name",string,"OK","");



Re: Saving a dialog for later - RedFusion - 07.09.2012

I need to save the dialogID aswell as there are several to choose from


Re: Saving a dialog for later - Cypress - 07.09.2012

The best way would be like this:

pawn Код:
new dialogID[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
      dialogID[playerid] = -1;
      return 1;
}


stock ShowDialogCase(playerid, caseid)
{
     switch (caseid)
     {
         case 0:
         {
              ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"My name dialog 1",string,"OK","");
              if(dialogID[playerid] != 0) dialogid[playerid] = 0;
         }
         case 1:
         {
              ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"My name dialog 2",string,"OK","");
              if(dialogID[playerid] != 1) dialogID[playerid] = 1;
         }
    }
    return caseid;
}

ShowDialogCase(playerid, dialogID[playerid]);

dialogID[playerid] = -1; // to reset

dialogID[playerid] = 1; // save the dialogid and then show by using ShowDialogCase
This is just a basic idea of how I'm doing that on my server. I'm sure you can manage it as you want.