AXV09

SAPI - Prograjek, published only Pawno.PL

Apr 24th, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. /*
  2. @platform: SA-MP
  3. @published only Pawno.PL.
  4. @name: script using SMS-API from Prograjek.pl
  5. @Prograjek URL: http://prograjek.pl/
  6. @original idea: brother300 <[email protected]>
  7. @author: brother300 <[email protected]>, edited by: l0nger <[email protected]>
  8. @date created: 24-04-2014 12:01
  9. @date released: 24-04-2014 12:01
  10. @date updated: 24-04-2014 22:45
  11. @version: 0.1.5.2414
  12.  
  13. (c) 2014, <[email protected]>
  14. */
  15.  
  16. // Main
  17. #include <a_samp>
  18.  
  19. // Definitions
  20. #define PG_USERID "Your userid from prograjek.pl/Twoj userid z prograjek.pl"
  21.  
  22. #define SAPI_COMMAND_NAME "/sms" // tresc komendy
  23.  
  24. // Do not touch
  25. #define SCRIPT_AUTHOR "brother300, edited by: l0nger"
  26. #define SCRIPT_VERSION "0.1.5.1814"
  27.  
  28. // Variables
  29. enum (+=1)
  30. {
  31. DIALOG_SAPI_MAIN=7800, // glowne menu informacji
  32. DIALOG_SAPI_PAID, // zaplata (klient musi wyslac sms i wpisac otrzymany kod w okno gui)
  33. DIALOG_SAPI_PAIDINFO, // informacja o zaplacie
  34. };
  35.  
  36. enum E_SAPI_POSSIBLEPAY
  37. {
  38. esp_payNetto,
  39. Float:esp_payBrutto,
  40. esp_text[10],
  41. esp_codeText
  42. };
  43.  
  44. static stock
  45. sapi_possiblePayments[12][E_SAPI_POSSIBLEPAY] =
  46. {
  47. // netto, brutto, tresc sms, numer sms
  48. {1, 1.23, "HPAY.PG", 7155},
  49. {2, 2.46, "HPAY.PG", 7255},
  50. {3, 3.69, "HPAY.PG", 7355},
  51. {4, 4.92, "HPAY.PG1", 7455},
  52. {6, 6.15, "HPAY.PG", 7555},
  53. {9, 11.07, "HPAY.PG", 7655},
  54. {11, 13.53, "HPAY.PG", 91155},
  55. {14, 17.22, "HPAY.PG", 91455},
  56. {19, 23.37, "HPAY.PG", 91955},
  57. {20, 24.6, "HPAY.PG", 92055},
  58. {25, 30.75, "HPAY.PG", 92555},
  59. };
  60.  
  61. // Callbacks
  62. public OnFilterScriptInit()
  63. {
  64. printf("\n\n*** SMS-API ProGrajek was loaded!");
  65. printf("Version: "SCRIPT_VERSION" ***\n\n");
  66. return 1;
  67. }
  68.  
  69. public OnFilterScriptInit()
  70. {
  71. printf("\n\n*** SMS-API ProGrajek was unloaded!")
  72. return 1;
  73. }
  74.  
  75. public OnDialogRespone(playerid, dialogid, response, listitem, inputtext[])
  76. {
  77.  
  78. switch(dialogid)
  79. {
  80. case DIALOG_SAPI_MAIN:
  81. {
  82. if(!response) return 1;
  83.  
  84. strdel(inputtext, strfind(inputtext, "("), strlen(inputtext));
  85. new price=strval(inputtext), buf[128], bool:error=false;
  86. SetPVarInt(playerid, "sapi:selectedPrice", price);
  87. for(new i; i<sizeof(sapi_possiblePayments); i++)
  88. {
  89. error=true;
  90. if(price==sapi_possiblePayments[i][esp_payNetto])
  91. {
  92. format(buf, sizeof(buf), "Wyslij SMS o tresci %s na numer %d\nPamietaj, ze koszt tego SMS'a wynosi: %d (brutto: %.0f)\nKod zwrotny wpisz w ponizsze pole edycji.", sapi_possiblePayments[i][esp_text], sapi_possiblePayments[i][esp_codeText], sapi_possiblePayments[i][esp_payNetto], sapi_possiblePayments[i][esp_payBrutto]);
  93. error=false;
  94. break;
  95. }
  96. }
  97. if(error)
  98. {
  99. OnPlayerCommandText(playerid, SAPI_COMMAND_NAME);
  100. SendClientMessage(playerid, -1, "Wystapil blad, sprobuj ponownie.");
  101. return true;
  102. } else {
  103. ShowPlayerDialog(playerid, DIALOG_SAPI_PAID, DIALOG_STYLE_INPUT, "SAPI - Kupno", buf, "Gotowe", "Anuluj");
  104. return true;
  105. }
  106. }
  107. case DIALOG_SAPI_PAID:
  108. {
  109. if(!respone) return 1;
  110. new buf[320];
  111. format(buf, sizeof(buf), "prograjek.pl/api/payment/api_code_verify.php?payment=dotpay&userid=%s&code=%s", PG_USERID, inputtext);
  112. HTTP(playerid, HTTP_GET, buf, "", "onClientSendRequestPay");
  113. } return true;
  114. }
  115. return false;
  116. }
  117.  
  118. // Functions
  119. forward onClientSendRequestPay(plr, response, s[]);
  120. public onClientSendRequestPay(plr, response, s[])
  121. {
  122. if(response!=200) {
  123. ShowPlayerDialog(plr, DIALOG_SAPI_PAIDINFO, DIALOG_STYLE_MSGBOX, "SAPI - Informacja", "Wystapil nieoczekiwany problem z hostem... Sprobuj ponownie.", "Zamknij", "");
  124. return;
  125. }
  126.  
  127. if(strfind(s, "ok", false)!=-1)
  128. {
  129. ShowPlayerDialog(plr, DIALOG_SAPI_PAIDINFO, DIALOG_STYLE_MSGBOX, "SAPI - Informacja", "Weryfikacja kodu zwrotnego przeszla pomyslnie!\nTrwa aktywacja uslugi... (czegos tam)", "Zamknij", "");
  130. } else {
  131. ShowPlayerDialog(plr, DIALOG_SAPI_PAIDINFO, DIALOG_STYLE_MSGBOX, "SAPI - Informacja", "Weryfikacja kodu zwrotnego nie przeszla pomyslnie.\nPrawdopodobnie kod jest niepoprawny, lub wystapil nieoczekiwany problem z hostem.", "Zamknij", "");
  132. }
  133. }
  134.  
  135. // Commands
  136. public OnPlayerCommandText(playerid, cmdtext[])
  137. {
  138. if(!strcmp(SAPI_COMMAND_NAME, cmdtext, false))
  139. {
  140. new buf[10*30];
  141. for(new i; i<sizeof(sapi_possiblePayments); i++)
  142. {
  143. format(buf, sizeof(buf), "%s\n%d (%.0f)", sapi_possiblePayments[i][esp_payNetto], sapi_possiblePayments[i][esp_payBrutto]);
  144. }
  145. ShowPlayerDialog(playerid, DIALOG_MAIN, DIALOG_STYLE_LIST, "SAPI - Menu glowne", buf, "Wybierz", "Anuluj");
  146. return true;
  147. }
  148. return false;
  149. }
Advertisement
Add Comment
Please, Sign In to add comment