Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. // easydialog.inc - By Emmet_ & Gammix - Last updated on 16 May, 2017
  2. #if defined easydialog_included
  3. #endinput
  4. #endif
  5. #define easydialog_included
  6.  
  7. #define DIALOG:%0(%1) \
  8. forward dialog_%0(%1); public dialog_%0(%1)
  9.  
  10. #define Dialog:%0(%1) \
  11. forward dialog_%0(%1); public dialog_%0(%1)
  12.  
  13. #define DIALOG_DEFAULT_ID (32700)
  14.  
  15. static Dialog_playerDialogId[MAX_PLAYERS][31];
  16.  
  17. /*stock Dialog_Open(playerid, function[], style, caption[], info[], button1[], button2[])
  18. {
  19. new ret = ShowPlayerDialog(playerid, DIALOG_DEFAULT_ID, style, caption, info, button1, button2);
  20. if (ret)
  21. {
  22. Dialog_playerDialogId[playerid] = "dialog_";
  23. strcat(Dialog_playerDialogId[playerid], function);
  24. }
  25. return ret;
  26. }*/
  27.  
  28. static
  29. s_DialogName[MAX_PLAYERS][32 char],
  30. s_DialogOpened[MAX_PLAYERS]
  31. ;
  32.  
  33. stock Dialog_Open(playerid, function[], style, caption[], info[], button1[], button2[], {Float,_}:...)
  34. {
  35. static
  36. string[4096],
  37. args
  38. ;
  39.  
  40. new ret;
  41.  
  42. if (!strlen(info))
  43. {
  44. return 0;
  45. }
  46. if ((args = numargs()) > 7)
  47. {
  48. while (--args >= 7)
  49. {
  50. #emit LCTRL 5
  51. #emit LOAD.alt args
  52. #emit SHL.C.alt 2
  53. #emit ADD.C 12
  54. #emit ADD
  55. #emit LOAD.I
  56. #emit PUSH.pri
  57. }
  58. #emit PUSH.S info
  59. #emit PUSH.C 4096
  60. #emit PUSH.C string
  61.  
  62. #emit LOAD.S.pri 8
  63. #emit CONST.alt 16
  64. #emit SUB
  65. #emit PUSH.pri
  66.  
  67. #emit SYSREQ.C format
  68. #emit LCTRL 5
  69. #emit SCTRL 4
  70.  
  71. ret = ShowPlayerDialog(playerid, 32700, style, caption, string, button1, button2);
  72. }
  73. else
  74. {
  75. ret = ShowPlayerDialog(playerid, 32700, style, caption, info, button1, button2);
  76. }
  77.  
  78. if (ret)
  79. {
  80. Dialog_playerDialogId[playerid] = "dialog_";
  81. strcat(Dialog_playerDialogId[playerid], function);
  82. }
  83.  
  84. s_DialogOpened[playerid] = 1;
  85.  
  86. strpack(s_DialogName[playerid], function, 32 char);
  87.  
  88. return 1;
  89. }
  90.  
  91. stock Dialog_Close(playerid)
  92. {
  93. s_DialogName[playerid]{0} = 0;
  94. s_DialogOpened[playerid] = 0;
  95.  
  96. return ShowPlayerDialog(playerid, -1, DIALOG_STYLE_MSGBOX, " ", " ", " ", "");
  97. }
  98.  
  99. #if defined _ALS_ShowPlayerDialog
  100. #undef ShowPlayerDialog
  101. #else
  102. #define _ALS_ShowPlayerDialog
  103. #endif
  104.  
  105. #define ShowPlayerDialog(%0,%1, \
  106. Dialog_Open(%0, #%1,
  107.  
  108. #define Dialog_Show(%0,%1, \
  109. Dialog_Open(%0, #%1,
  110.  
  111. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  112. {
  113. for (new i = 0, l = strlen(inputtext); i < l; i ++)
  114. {
  115. if (inputtext[i] == '%')
  116. {
  117. inputtext[i] = '#';
  118. }
  119. }
  120.  
  121. if (dialogid == DIALOG_DEFAULT_ID && Dialog_playerDialogId[playerid][0])
  122. {
  123. CallLocalFunction(Dialog_playerDialogId[playerid], "ddds", playerid, response, listitem, (!inputtext[0]) ? ("\1") : (inputtext));
  124. Dialog_playerDialogId[playerid][0] = EOS;
  125. }
  126. else return 0;
  127.  
  128. #if defined Dialog_OnDialogResponse
  129. return Dialog_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
  130. #else
  131. return 1;
  132. #endif
  133. }
  134. #if defined _ALS_OnDialogResponse
  135. #undef OnDialogResponse
  136. #else
  137. #define _ALS_OnDialogResponse
  138. #endif
  139. #define OnDialogResponse Dialog_OnDialogResponse
  140. #if defined Dialog_OnDialogResponse
  141. forward Dialog_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
  142. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement