Guest User

Easy Dialogs v. 1.1 by White_116

a guest
Feb 27th, 2013
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.60 KB | None | 0 0
  1. /*
  2. === White_116 ================================
  3.             Easy Dialogs Include
  4.                 27.02.2013
  5. ================================= v1.1 =======
  6.     Is based on Easy Dialogs by Emmet_
  7.     http://forum.sa-mp.com/showthread.php?t=377140
  8. ==============================================
  9. native HideDialog(playerid);
  10. native ShowDialog(playerid, dialog[], style, caption[], info[], button1[], button2[]);
  11. */
  12. #define Dialog:%0() forward dialog_%0(playerid, response, listitem, inputtext[]); public dialog_%0(playerid, response, listitem, inputtext[])
  13. //#define Show:<%0> #dialog_%0
  14. #define D: #dialog_
  15.  
  16. forward HideDialog(playerid);
  17. public HideDialog(playerid)
  18. {
  19.     DeletePVar(playerid, "CurrentDialog");// Очистим название функции.
  20.     return ShowPlayerDialog(playerid, -1, 0, "", "", "", "");// Вызовим игроку диалог который закроет диалог.
  21. }
  22.  
  23. forward ShowDialog(playerid, dialog[], style, caption[], info[], button1[], button2[]);
  24. public ShowDialog(playerid, dialog[], style, caption[], info[], button1[], button2[])
  25. {
  26.     SetPVarString(playerid,"CurrentDialog",dialog);// Запишем название функции.
  27.     return ShowPlayerDialog(playerid, random(256), style, caption, info, button1, button2);// Вызовим игроку диалог
  28. }
  29.  
  30. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  31. {
  32.     new CurrentDialog[32];// Переменая для хранения названия функции
  33.     GetPVarString(playerid, "CurrentDialog", CurrentDialog, 32);// Достанем название функции.
  34.     new itr=strlen(inputtext);// Узнаем количество символов
  35.     if(itr == 0)// Если есть символы
  36.     {
  37.         if(strlen(CurrentDialog))// Если есть название функции.
  38.         if(funcidx(CurrentDialog) != -1)// Если существует функция
  39.         {
  40.             DeletePVar(playerid, "CurrentDialog");// Очистим название функции.
  41.             if(CallLocalFunction(CurrentDialog, "ddd", playerid, response, listitem))return 1;// Вызовим функцию без текста и выйдем
  42.         }
  43.     }
  44.     else
  45.     {
  46. //      -Stranger-      --------------------------------------------------------
  47. // http://forum.sa-mp.com/showpost.php?p=2282738&postcount=443
  48.         for(itr--; itr > -1; itr--)// Пока есть символы
  49.         switch(inputtext[itr])// Ищем символ
  50.         {
  51.             case 0x25: inputtext[itr]=0x23; // Меняем '%' на '#'.
  52.             case 0x00 .. 0x1F: inputtext[itr]=0x3F; // Меняем 'Управляющие символы' на '?'.
  53.         }
  54. //------------------------------------------------------------------------------
  55.         if(strlen(CurrentDialog))// Если есть название функции.
  56.         if(funcidx(CurrentDialog) != -1)// Если существует функция
  57.         {
  58.             DeletePVar(playerid, "CurrentDialog");// Очистим название функции.
  59.             if(CallLocalFunction(CurrentDialog, "ddds", playerid, response, listitem, inputtext))return 1;// Вызовим функцию с текстом и выйдем
  60.         }
  61.     }
  62.     return W_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);// Вызовим стандартный паблик (Уже подменён)
  63. }
  64.  
  65. #if defined _ALS_OnDialogResponse
  66.     #undef OnDialogResponse
  67. #else
  68.     #define _ALS_OnDialogResponse
  69. #endif
  70. #define OnDialogResponse W_OnDialogResponse
  71. forward W_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
  72. //**************************        EOS         ********************************
Advertisement
Add Comment
Please, Sign In to add comment