Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // easydialog.inc - By Emmet_ & Gammix - Last updated on 16 May, 2017
- #if defined easydialog_included
- #endinput
- #endif
- #define easydialog_included
- #define DIALOG:%0(%1) \
- forward dialog_%0(%1); public dialog_%0(%1)
- #define Dialog:%0(%1) \
- forward dialog_%0(%1); public dialog_%0(%1)
- #define DIALOG_DEFAULT_ID (32700)
- static Dialog_playerDialogId[MAX_PLAYERS][31];
- /*stock Dialog_Open(playerid, function[], style, caption[], info[], button1[], button2[])
- {
- new ret = ShowPlayerDialog(playerid, DIALOG_DEFAULT_ID, style, caption, info, button1, button2);
- if (ret)
- {
- Dialog_playerDialogId[playerid] = "dialog_";
- strcat(Dialog_playerDialogId[playerid], function);
- }
- return ret;
- }*/
- static
- s_DialogName[MAX_PLAYERS][32 char],
- s_DialogOpened[MAX_PLAYERS]
- ;
- stock Dialog_Open(playerid, function[], style, caption[], info[], button1[], button2[], {Float,_}:...)
- {
- static
- string[4096],
- args
- ;
- new ret;
- if (!strlen(info))
- {
- return 0;
- }
- if ((args = numargs()) > 7)
- {
- while (--args >= 7)
- {
- #emit LCTRL 5
- #emit LOAD.alt args
- #emit SHL.C.alt 2
- #emit ADD.C 12
- #emit ADD
- #emit LOAD.I
- #emit PUSH.pri
- }
- #emit PUSH.S info
- #emit PUSH.C 4096
- #emit PUSH.C string
- #emit LOAD.S.pri 8
- #emit CONST.alt 16
- #emit SUB
- #emit PUSH.pri
- #emit SYSREQ.C format
- #emit LCTRL 5
- #emit SCTRL 4
- ret = ShowPlayerDialog(playerid, 32700, style, caption, string, button1, button2);
- }
- else
- {
- ret = ShowPlayerDialog(playerid, 32700, style, caption, info, button1, button2);
- }
- if (ret)
- {
- Dialog_playerDialogId[playerid] = "dialog_";
- strcat(Dialog_playerDialogId[playerid], function);
- }
- s_DialogOpened[playerid] = 1;
- strpack(s_DialogName[playerid], function, 32 char);
- return 1;
- }
- stock Dialog_Close(playerid)
- {
- s_DialogName[playerid]{0} = 0;
- s_DialogOpened[playerid] = 0;
- return ShowPlayerDialog(playerid, -1, DIALOG_STYLE_MSGBOX, " ", " ", " ", "");
- }
- #if defined _ALS_ShowPlayerDialog
- #undef ShowPlayerDialog
- #else
- #define _ALS_ShowPlayerDialog
- #endif
- #define ShowPlayerDialog(%0,%1, \
- Dialog_Open(%0, #%1,
- #define Dialog_Show(%0,%1, \
- Dialog_Open(%0, #%1,
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- for (new i = 0, l = strlen(inputtext); i < l; i ++)
- {
- if (inputtext[i] == '%')
- {
- inputtext[i] = '#';
- }
- }
- if (dialogid == DIALOG_DEFAULT_ID && Dialog_playerDialogId[playerid][0])
- {
- CallLocalFunction(Dialog_playerDialogId[playerid], "ddds", playerid, response, listitem, (!inputtext[0]) ? ("\1") : (inputtext));
- Dialog_playerDialogId[playerid][0] = EOS;
- }
- else return 0;
- #if defined Dialog_OnDialogResponse
- return Dialog_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnDialogResponse
- #undef OnDialogResponse
- #else
- #define _ALS_OnDialogResponse
- #endif
- #define OnDialogResponse Dialog_OnDialogResponse
- #if defined Dialog_OnDialogResponse
- forward Dialog_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement