Advertisement
Guest User

Untitled

a guest
Sep 10th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. /*///////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //
  4. //
  5. // » Reportavimo sistema by MantasPwn
  6. // • Naudojama mysql versija r39-2
  7. // • Naudojamas scanf2 pluginas
  8. //
  9. //
  10. //
  11. *////////////////////////////////////////////////////////////////////////////////////////////
  12.  
  13. #include <a_samp>
  14. #include <a_mysql>
  15. #include <sscanf2>
  16.  
  17. #define MySQL_HOST "localhost"
  18. #define MySQL_USER "root"
  19. #define MySQL_DATA "report"
  20. #define MySQL_PASS ""
  21.  
  22. new handle;
  23. new PasirinktasZaidejas[MAX_PLAYERS];
  24.  
  25. main()
  26. {
  27. print("\n----------------------------------");
  28. print("» Reportavimo sistema by MantasPwn");
  29. print("----------------------------------\n");
  30. }
  31.  
  32. stock GetPlayerID(const Name[])
  33. {
  34. for(new i; i<MAX_PLAYERS; i++)
  35. {
  36. if(IsPlayerConnected(i))
  37. {
  38. new pName[MAX_PLAYER_NAME];
  39. GetPlayerName(i, pName, sizeof(pName));
  40. if(strcmp(Name, pName, true)==0)
  41. {
  42. return i;
  43. }
  44. }
  45. }
  46. return -1;
  47. }
  48.  
  49.  
  50. public OnGameModeInit()
  51. {
  52. mysql_log(LOG_ALL);
  53. handle = mysql_connect(MySQL_HOST,MySQL_USER,MySQL_DATA,MySQL_PASS);
  54. return 1;
  55. }
  56.  
  57. public OnPlayerCommandText(playerid, cmdtext[])
  58. {
  59. if(!strcmp(cmdtext, "/report", true))
  60. {
  61. ShowPlayerDialog(playerid, 1234, DIALOG_STYLE_LIST, "Reportavimas", "{FFFFFF}[ {ff6600}x {ffFFff}] Reportuoti žaidėja\n{FFFFFF}[ {ff6600}x {ffFFff}] Reportuoti klaidą žaidime", "Toliau", "Atšaukti");
  62. return 1;
  63. }
  64. return 0;
  65. }
  66.  
  67. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  68. {
  69. if(dialogid == 1234)
  70. {
  71. if(response)
  72. {
  73. if(listitem == 0) ShowPlayerDialog(playerid, 1235, DIALOG_STYLE_INPUT, "Reportavimas", "{FFFFFF}[ {ff6600}x {ffFFff}] Įveskite žaidėjo slapyvardį, apie kurį norite pranešti\n{FFFFFF}[ {ff6600}x {ffFFff}] Žaidėjas turi būti serveryje!", "Toliau", "Atšaukti");
  74. if(listitem == 1) ShowPlayerDialog(playerid, 1237, DIALOG_STYLE_INPUT, "Reportavimas", "{FFFFFF}[ {ff6600}x {ffFFff}] Aprašykite klaidą:", "Toliau", "Atšaukti");
  75. }
  76. }
  77.  
  78. if(dialogid == 1235)
  79. {
  80. if(response)
  81. {
  82. new Name[MAX_PLAYER_NAME];
  83. new msg[180];
  84. new player;
  85. player = GetPlayerID(inputtext);
  86. if(sscanf(inputtext, "u", player)) return SendClientMessage(playerid, 0xAA3333AA, "* Laukelis negali būti tusčias!");
  87. if(!IsPlayerConnected(player)){
  88. SendClientMessage(playerid, 0xAA3333AA, "* Įvestas žaidėjas neprisijunges!");
  89. ShowPlayerDialog(playerid, 1235, DIALOG_STYLE_INPUT, "Reportavimas", "{FFFFFF}[ {ff6600}x {ffFFff}] Įveskite žaidėjo slapyvardį, apie kurį norite pranešti\n{FFFFFF}[ {ff6600}x {ffFFff}] Žaidėjas turi būti serveryje!", "Toliau", "Atšaukti");
  90. return 1;
  91. }
  92. PasirinktasZaidejas[playerid] = player;
  93. GetPlayerName(PasirinktasZaidejas[playerid], Name, MAX_PLAYER_NAME);
  94. format(msg, sizeof(msg), "{FFFFFF}[ {ff6600}x {ffFFff}] Įvestas žaidėjo slapyvardis: {ff6600}%s\n{FFFFFF}[ {ff6600}x {ffFFff}] Prašome įrašyti priežastį:", Name);
  95. ShowPlayerDialog(playerid, 1236, DIALOG_STYLE_INPUT, "Reportavimas", msg, "Reportuoti", "Atšaukti");
  96. }
  97. }
  98.  
  99. if(dialogid == 1236)
  100. {
  101. if(response)
  102. {
  103. new player = PasirinktasZaidejas[playerid];
  104. if(strlen(inputtext) < 5)
  105. {
  106. new msg[160];
  107. new Name[MAX_PLAYER_NAME];
  108. GetPlayerName(player, Name, MAX_PLAYER_NAME);
  109. format(msg, sizeof(msg), "{FFFFFF}[ {ff6600}x {ffFFff}] Įvestas žaidėjo slapyvardis: {ff6600}%s\n{FFFFFF}[ {ff6600}x {ffFFff}]Prašome įrašyti priežastį:\n{FF0000}• Priežastį turi sudaryti nemažiau kaip 5 raidės!", Name);
  110. ShowPlayerDialog(playerid, 1236, DIALOG_STYLE_INPUT, "Reportavimas", msg, "Reportuoti", "Atšaukti");
  111. SendClientMessage(playerid, 0xAA3333AA, "* Priežastį turi sudaryti nemažiau kaip 5 raidės!");
  112. return 1;
  113. }
  114.  
  115. new msg[150];
  116. new Pazeidejas[MAX_PLAYER_NAME];
  117. new Zaidejas[MAX_PLAYER_NAME];
  118.  
  119. GetPlayerName(playerid, Zaidejas, MAX_PLAYER_NAME);
  120. GetPlayerName(player, Pazeidejas, MAX_PLAYER_NAME);
  121.  
  122.  
  123. format(msg, sizeof(msg), "{FFFFFF}[{ff6600}REPORT{FFFFFF}] Žaidėjas {ff6600}%s{ffFFff} reportavo {ff6600}%s{ffFFff} dėl {ff6600}%s",Zaidejas, Pazeidejas, inputtext);
  124. SendClientMessageToAll(-1, msg);
  125. }
  126. }
  127.  
  128. if(dialogid == 1237)
  129. {
  130. if(response)
  131. {
  132. if(strlen(inputtext) < 15) return ShowPlayerDialog(playerid, 1237, DIALOG_STYLE_INPUT, "Reportavimas", "{FFFFFF}[ {ff6600}x {ffFFff}] Aprašykite klaidą:\n{FF0000}• Per mažai įvesta simbolių!", "Toliau", "Atšaukti");
  133. new rows, fields;
  134. new Zaidejas[MAX_PLAYER_NAME];
  135. new msg[150];
  136. new query[120];
  137. mysql_query(handle,"SELECT * FROM reports");
  138. cache_get_data(rows, fields);
  139. rows++;
  140.  
  141. GetPlayerName(playerid, Zaidejas, MAX_PLAYER_NAME);
  142.  
  143. format(query, sizeof(query), "INSERT INTO `reports` (ReportID,Zaidejas,Klaida) VALUES('%d','%s','%s')", rows, Zaidejas, inputtext);
  144. mysql_query(handle, query);
  145.  
  146. format(msg, sizeof(msg), "{FFFFFF}[{ff6600}REPORT ID %i{FFFFFF}] Ačiū! Klaida buvo įrašyta į d. baze!",rows);
  147. SendClientMessage(playerid, -1, msg);
  148.  
  149. }
  150. }
  151. return 1;
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement