1
0

reports.inc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. #define MAX_REPORTS (200)
  2. #define DIALOG_REPORTS 14879
  3. #define DIALOG_REPORTS_ACCEPT 14880
  4. enum reportsinfo
  5. {
  6. rReporterName[MAX_PLAYER_NAME], // name of the reporter
  7. rReporterID, // id of the reporter
  8. bool:rEnabled, // if that report is active or not
  9. rText[128] // text of the report
  10. };
  11. new reportscount = 0;
  12. new Report[MAX_REPORTS][reportsinfo];
  13. new viewingreport[MAX_PLAYERS];
  14. new speakingtoadmin[MAX_PLAYERS], speakingtoplayer[MAX_PLAYERS], Reported[MAX_PLAYERS], bool:areported[MAX_PLAYERS], tstr[128];
  15. Hook:reports_OnGameModeInit()
  16. {
  17. for(new i = 0; i < MAX_REPORTS; i++)
  18. {
  19. Report[i][rReporterID] = INVALID_PLAYER_ID;
  20. Report[i][rEnabled] = false;
  21. }
  22. return 1;
  23. }
  24. Hook:reports_OnPlayerConnect(playerid)
  25. {
  26. speakingtoadmin[playerid] = INVALID_PLAYER_ID;
  27. speakingtoplayer[playerid] = INVALID_PLAYER_ID;
  28. return 1;
  29. }
  30. Hook:reports_OnPlayerDisconnect(playerid, reason)
  31. {
  32. for(new i = 0; i < MAX_REPORTS; i ++)
  33. {
  34. if(Report[i][rReporterID] == playerid && Report[i][rEnabled] == true)
  35. {
  36. Report[i][rReporterID] = INVALID_PLAYER_ID;
  37. if(0 <= speakingtoadmin[playerid] < MAX_PLAYERS)
  38. {
  39. speakingtoplayer[speakingtoadmin[playerid]] = INVALID_PLAYER_ID;
  40. speakingtoadmin[playerid] = INVALID_PLAYER_ID;
  41. }
  42. if(0 <= speakingtoplayer[playerid] < MAX_PLAYERS)
  43. {
  44. speakingtoadmin[speakingtoplayer[playerid]] = INVALID_PLAYER_ID;
  45. speakingtoplayer[playerid] = INVALID_PLAYER_ID;
  46. }
  47. Report[i][rEnabled] = false;
  48. reportscount--;
  49. }
  50. }
  51. return 1;
  52. }
  53. Hook:reports_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  54. {
  55. if(dialogid == DIALOG_REPORTS)
  56. {
  57. if(response)
  58. {
  59. new fakeListitem = 0, selectedreport;
  60. for(new i = 0; i < MAX_REPORTS; i++)
  61. {
  62. if(Report[i][rEnabled] == true)
  63. {
  64. if(fakeListitem == listitem) selectedreport = i;
  65. fakeListitem++;
  66. }
  67. }
  68. format(tstr, sizeof(tstr), "%s's Report %d", Report[selectedreport][rReporterName], selectedreport);
  69. new rinfostr[128];
  70. viewingreport[playerid] = selectedreport;
  71. format(rinfostr, sizeof(rinfostr), "%s", Report[selectedreport][rText]);
  72. ShowPlayerDialog(playerid, DIALOG_REPORTS_ACCEPT, DIALOG_STYLE_MSGBOX, tstr, rinfostr, "Accept", "Back");
  73. }
  74. }
  75. if(dialogid == DIALOG_REPORTS_ACCEPT)
  76. {
  77. new year, month, day;
  78. getdate(year, month, day);
  79. new hour, minute, second;
  80. gettime(hour, minute, second);
  81. hour = FixHour(hour);
  82. new reportid = viewingreport[playerid];
  83. if(response)
  84. {
  85. if(Report[reportid][rEnabled] == false)
  86. {
  87. SendClientMessage(playerid, COLOR_GREY, "This report is no longer active or another administrator is current dealing with it.");
  88. viewingreport[playerid] = -1;
  89. }
  90. else if(speakingtoadmin[Report[reportid][rReporterID]] != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "That player is currently speaking to an administrator.");
  91. else
  92. {
  93. format(tstr, sizeof(tstr), "%s has accepted %s's report (reportid: %d)", PlayerOOCName(playerid), Report[reportid][rReporterName], reportid);
  94. ABroadCast(COLOR_LIGHTYELLOW, tstr, 1);
  95. SendClientMessage(playerid, COLOR_LIGHTYELLOW, "Use /ac to communicate with the player, /endac to end the chat session.");
  96. printf("%s has accepted %s's report at %02d %s %02d:%02d:%02d", PlayerOOCName(playerid), Report[reportid][rReporterName], day, GetMonthFromInt(month), hour, minute, second);
  97. if(PlayerInfo[playerid][pAdmin] >= 2 && PlayerInfo[playerid][pStealthed] != 1)
  98. {
  99. format(tstr, sizeof(tstr), "%s has accepted your report, /ac to communicate.", PlayerOOCName(playerid));
  100. SendClientMessage(Report[reportid][rReporterID], COLOR_GREY, tstr);
  101. printf("%s has accepted %s's report at %02d %s %02d:%02d:%02d", PlayerOOCName(playerid), Report[reportid][rReporterName], day, GetMonthFromInt(month), hour, minute, second);
  102. }
  103. else if(PlayerInfo[playerid][pAdmin] == 1 || PlayerInfo[playerid][pStealthed] == 1)
  104. {
  105. SendClientMessage(Report[reportid][rReporterID], COLOR_GREY, "A probationary admin has accepted your report, /ac to communicate.");
  106. printf("[PROBIE ADMIN]%s has accepted %s's report at %02d %s %02d:%02d:%02d", PlayerOOCName(playerid), Report[reportid][rReporterName], day, GetMonthFromInt(month), hour, minute, second);
  107. }
  108. Report[reportid][rEnabled] = false;
  109. speakingtoplayer[playerid] = Report[reportid][rReporterID];
  110. speakingtoadmin[Report[reportid][rReporterID]] = playerid;
  111. Report[reportid][rReporterID] = INVALID_PLAYER_ID;
  112. reportscount--;
  113. }
  114. }
  115. if(!response)
  116. {
  117. new finalreportstr[8000];
  118. for(new i = 0; i < MAX_REPORTS; i++)
  119. {
  120. if(Report[i][rEnabled] == true)
  121. {
  122. format(finalreportstr, sizeof(finalreportstr), "%s%d. %s (%d): %s\n", finalreportstr, i, Report[i][rReporterName], Report[i][rReporterID], Report[i][rText]);
  123. }
  124. }
  125. ShowPlayerDialog(playerid, DIALOG_REPORTS, DIALOG_STYLE_LIST, "Active Reports", finalreportstr, "View", "Cancel");
  126. }
  127. }
  128. return 1;
  129. }
  130. CMD:report(playerid, params[])
  131. {
  132. new now = gettime();
  133. if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /report [text]");
  134. //if(PlayerInfo[playerid][pAdmin] >= 1) return SendClientMessage(playerid, COLOR_GREY, "Please do not /report as an administrator, thank you.");
  135. for(new i = 0; i < MAX_REPORTS; i++)
  136. {
  137. if(Report[i][rReporterID] == playerid && Report[i][rEnabled] == true) return SendClientMessage(playerid, COLOR_GREY, "You already have an on-going report, /cancelreport to cancel it.");
  138. }
  139. new text[128];
  140. if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /report [text]");
  141. if(now < (Reported[playerid] + 20))
  142. {
  143. format(tstr, sizeof(tstr), "You have to wait %d seconds before you can use /report again!", (Reported[playerid] + 20) - now);
  144. SendClientMessage(playerid, COLOR_GREY, tstr);
  145. }
  146. else
  147. {
  148. for(new i = 0; i < MAX_REPORTS; i++)
  149. {
  150. if(Report[i][rEnabled] == true) continue;
  151. Report[i][rEnabled] = true;
  152. format(Report[i][rText], 128, "%s", params);
  153. Report[i][rReporterID] = playerid;
  154. GetPlayerName(playerid, Report[i][rReporterName], MAX_PLAYER_NAME);
  155. format(tstr, sizeof(tstr), "Report (%d) from [%d]%s: %s", i, playerid, PlayerOOCName(playerid), text);
  156. ABroadCast(COLOR_LIGHTYELLOW, tstr, 1);
  157. SendClientMessage(playerid, COLOR_YELLOW, "Your report message was sent to online administrators, thank you.");
  158. Reported[playerid] = gettime();
  159. areported[playerid] = true;
  160. reportscount++;
  161. break;
  162. }
  163. }
  164. return 1;
  165. }
  166. CMD:reports(playerid, params[])
  167. {
  168. if(PlayerInfo[playerid][pAdmin] == 1 && ADuty[playerid] == false) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
  169. if(PlayerInfo[playerid][pAdmin] >= 1)
  170. {
  171. new finalreportstr[10000];
  172. for(new i = 0; i < MAX_REPORTS; i++)
  173. {
  174. if(Report[i][rEnabled] == true)
  175. {
  176. format(finalreportstr, sizeof(finalreportstr), "%s%d. %s (%d): %s\n", finalreportstr, i, Report[i][rReporterName], Report[i][rReporterID], Report[i][rText]);
  177. }
  178. }
  179. ShowPlayerDialog(playerid, DIALOG_REPORTS, DIALOG_STYLE_LIST, "Active Reports", finalreportstr, "View", "Cancel");
  180. }
  181. return 1;
  182. }
  183. CMD:ar(playerid, params[]) return cmd_acceptreport(playerid, params);
  184. CMD:acceptreport(playerid, params[])
  185. {
  186. new year, month, day;
  187. getdate(year, month, day);
  188. new hour, minute, second;
  189. gettime(hour, minute, second);
  190. hour = FixHour(hour);
  191. if(PlayerInfo[playerid][pAdmin] < 1) return AdmErrorMsg;
  192. if(PlayerInfo[playerid][pAdmin] == 1 && ADuty[playerid] == false) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
  193. new reportid;
  194. if(sscanf(params, "i", reportid)) return SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /acceptreport [reportid]");
  195. if(Report[reportid][rEnabled] == false) return SendClientMessage(playerid, COLOR_GREY, "Invalid report ID.");
  196. else if(speakingtoadmin[Report[reportid][rReporterID]] != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "That player is currently speaking to an administrator.");
  197. format(tstr, sizeof(tstr), "%s has accepted %s's report (reportid: %d)", PlayerOOCName(playerid), Report[reportid][rReporterName], reportid);
  198. ABroadCast(COLOR_LIGHTYELLOW, tstr, 1);
  199. SendClientMessage(playerid, COLOR_LIGHTYELLOW, "Use /ac to communicate with the player, /endac to end the chat session.");
  200. printf("%s has accepted %s's report at %02d %s %02d:%02d:%02d", PlayerOOCName(playerid), Report[reportid][rReporterName], day, GetMonthFromInt(month), hour, minute, second);
  201. if(PlayerInfo[playerid][pAdmin] >= 2 && PlayerInfo[playerid][pStealthed] != 1)
  202. {
  203. format(tstr, sizeof(tstr), "%s has accepted your report, /ac to communicate.", PlayerOOCName(playerid));
  204. SendClientMessage(Report[reportid][rReporterID], COLOR_GREY, tstr);
  205. }
  206. else if(PlayerInfo[playerid][pAdmin] == 1 || PlayerInfo[playerid][pStealthed] == 1)
  207. {
  208. SendClientMessage(Report[reportid][rReporterID], COLOR_GREY, "A silent admin has accepted your report, /ac to communicate.");
  209. }
  210. Report[reportid][rEnabled] = false;
  211. speakingtoplayer[playerid] = Report[reportid][rReporterID];
  212. speakingtoadmin[Report[reportid][rReporterID]] = playerid;
  213. Report[reportid][rReporterID] = INVALID_PLAYER_ID;
  214. reportscount--;
  215. return 1;
  216. }
  217. CMD:tr(playerid, params[]) return cmd_trashreport(playerid, params);
  218. CMD:trashreport(playerid, params[])
  219. {
  220. new year, month, day;
  221. getdate(year, month, day);
  222. new hour, minute, second;
  223. gettime(hour, minute, second);
  224. hour = FixHour(hour);
  225. if(PlayerInfo[playerid][pAdmin] < 1) return AdmErrorMsg;
  226. if(PlayerInfo[playerid][pAdmin] == 1 && ADuty[playerid] == false) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
  227. new reportid;
  228. if(sscanf(params, "i", reportid)) return SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /(t)rash(r)eport [reportid]");
  229. if(Report[reportid][rEnabled] == false) return SendClientMessage(playerid, COLOR_GREY, "Invalid report ID.");
  230. format(tstr, sizeof(tstr), "%s has trashed %s's report (reportid: %d)", PlayerOOCName(playerid), Report[reportid][rReporterName], reportid);
  231. ABroadCast(COLOR_LIGHTYELLOW, tstr, 1);
  232. printf("%s has trashed %s's report (reportid: %d) at %02d %s %02d:%02d:%02d", PlayerOOCName(playerid), Report[reportid][rReporterName], reportid, day, GetMonthFromInt(month), hour, minute, second);
  233. Report[reportid][rEnabled] = false;
  234. if(0 <= speakingtoplayer[playerid] < MAX_PLAYERS) speakingtoadmin[speakingtoplayer[playerid]] = INVALID_PLAYER_ID;
  235. speakingtoplayer[playerid] = INVALID_PLAYER_ID;
  236. Report[reportid][rReporterID] = INVALID_PLAYER_ID;
  237. reportscount--;
  238. return 1;
  239. }
  240. CMD:ac(playerid, params[])
  241. {
  242. if(PlayerInfo[playerid][pAdmin] == 1 && ADuty[playerid] == false) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
  243. if(speakingtoplayer[playerid] == INVALID_PLAYER_ID && PlayerInfo[playerid][pAdmin] >= 1) return SendClientMessage(playerid, COLOR_GREY, "You are not speaking to any player.");
  244. if(speakingtoadmin[playerid] == INVALID_PLAYER_ID && PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not speaking to any admin.");
  245. new text[128];
  246. if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /ac [message]");
  247. if(PlayerInfo[playerid][pAdmin] < 1)
  248. {
  249. for(new i = 0; i <= GetPlayerPoolSize(); i++)
  250. {
  251. if(speakingtoplayer[i] == playerid && PlayerInfo[i][pAdmin] >= 1 && speakingtoadmin[playerid] == i)
  252. {
  253. format(tstr, sizeof(tstr), "{008000}%s: %s", PlayerOOCName(playerid), text);
  254. SendClientMessage(playerid, -1, tstr);
  255. SendClientMessage(i, -1, tstr);
  256. SendShadowMsg(COLOR_GREY, tstr);
  257. format(tstr, sizeof(tstr), "{008000}Admin %s: %s", PlayerOOCName(playerid), text);
  258. logswrite("adminreplies.log", tstr);
  259. }
  260. }
  261. }
  262. if(PlayerInfo[playerid][pAdmin] == 1 || PlayerInfo[playerid][pStealthed] == 1)
  263. {
  264. for(new i = 0; i <= GetPlayerPoolSize(); i++)
  265. {
  266. if(speakingtoadmin[i] == playerid && speakingtoplayer[playerid] == i)
  267. {
  268. format(tstr, sizeof(tstr), "{008000}Silent Admin: %s", text);
  269. SendClientMessage(playerid, -1, tstr);
  270. SendClientMessage(i, -1, tstr);
  271. SendShadowMsg(COLOR_GREY, tstr);
  272. format(tstr, sizeof(tstr), "{008000}Admin %s: %s", PlayerOOCName(playerid), text);
  273. logswrite("adminreplies.log", tstr);
  274. }
  275. }
  276. }
  277. if(PlayerInfo[playerid][pAdmin] > 1 && PlayerInfo[playerid][pStealthed] != 1)
  278. {
  279. for(new i = 0; i <= GetPlayerPoolSize(); i++)
  280. {
  281. if(speakingtoadmin[i] == playerid && speakingtoplayer[playerid] == i)
  282. {
  283. format(tstr, sizeof(tstr), "{008000}Admin %s: %s", PlayerOOCName(playerid), text);
  284. SendClientMessage(playerid, -1, tstr);
  285. SendClientMessage(i, -1, tstr);
  286. SendShadowMsg(COLOR_GREY, tstr);
  287. format(tstr, sizeof(tstr), "{008000}Admin %s: %s", PlayerOOCName(playerid), text);
  288. logswrite("adminreplies.log", tstr);
  289. }
  290. }
  291. }
  292. return 1;
  293. }
  294. CMD:startac(playerid, params[])
  295. {
  296. new year, month, day;
  297. getdate(year, month, day);
  298. new hour, minute, second;
  299. gettime(hour, minute, second);
  300. hour = FixHour(hour);
  301. if(PlayerInfo[playerid][pAdmin] < 1) return AdmErrorMsg;
  302. if(PlayerInfo[playerid][pAdmin] == 1 && ADuty[playerid] == false) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
  303. if(speakingtoplayer[playerid] != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "You are already speaking to a player, /endac to end the chat session.");
  304. new targetid;
  305. if(sscanf(params, "i", targetid)) return SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /startac [playerid]");
  306. //if(PlayerInfo[targetid][pAdmin] >= 1) return SendClientMessage(playerid, COLOR_GREY, "Use /a for that.");
  307. if(speakingtoadmin[targetid] != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "That person is already speaking to an administrator.");
  308. speakingtoadmin[targetid] = playerid;
  309. speakingtoplayer[playerid] = targetid;
  310. format(tstr, sizeof(tstr), "You have started a chat session with %s, /ac to communicate, /endac to end the chat session.", PlayerOOCName(targetid));
  311. SendClientMessage(playerid, COLOR_GREY, tstr);
  312. printf("%s has started AC with %s at %02d %s %02d:%02d:%02d", PlayerOOCName(playerid), PlayerOOCName(targetid), day, GetMonthFromInt(month), hour, minute, second);
  313. if(PlayerInfo[playerid][pAdmin] == 1 || PlayerInfo[playerid][pStealthed] == 1) SendClientMessage(targetid, COLOR_GREY, "A silent admin has started a chat session with you, /ac to communicate.");
  314. else if(PlayerInfo[playerid][pAdmin] > 1)
  315. {
  316. format(tstr, sizeof(tstr), "Admin %s has started a chat session with you, /ac to communicate.", PlayerOOCName(playerid));
  317. SendClientMessage(targetid, COLOR_GREY, tstr);
  318. }
  319. return 1;
  320. }
  321. CMD:endac(playerid, params[])
  322. {
  323. new year, month, day;
  324. getdate(year, month, day);
  325. new giveplayerid;
  326. new hour, minute, second;
  327. gettime(hour, minute, second);
  328. hour = FixHour(hour);
  329. if(PlayerInfo[playerid][pAdmin] < 1) return AdmErrorMsg;
  330. if(PlayerInfo[playerid][pAdmin] == 1 && ADuty[playerid] == false) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
  331. if(speakingtoplayer[playerid] == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "You are not speaking to any player.");
  332. format(tstr, sizeof(tstr), "You have ended the chat session with %s.", PlayerOOCName(speakingtoplayer[playerid]));
  333. SendClientMessage(playerid, COLOR_GREY, tstr);
  334. if(PlayerInfo[playerid][pAdmin] == 1 || PlayerInfo[playerid][pStealthed] == 1) SendClientMessage(speakingtoplayer[playerid], COLOR_GREY, "The silent admin has ended the chat session with you.");
  335. else if(PlayerInfo[playerid][pAdmin] > 1)
  336. {
  337. format(tstr, sizeof(tstr), "Admin %s has ended the chat session with you.", PlayerOOCName(playerid));
  338. SendClientMessage(speakingtoplayer[playerid], COLOR_GREY, tstr);
  339. printf("%s has ended AC with %s at %02d %s %02d:%02d:%02d", PlayerOOCName(playerid), PlayerOOCName(giveplayerid), day, GetMonthFromInt(month), hour, minute, second);
  340. }
  341. if(0 <= speakingtoplayer[playerid] < MAX_PLAYERS) speakingtoadmin[speakingtoplayer[playerid]] = INVALID_PLAYER_ID;
  342. speakingtoplayer[playerid] = INVALID_PLAYER_ID;
  343. return 1;
  344. }
  345. CMD:cancelreport(playerid, params[])
  346. {
  347. for(new i = 0; i < MAX_REPORTS; i++)
  348. {
  349. if(Report[i][rEnabled] == true && Report[i][rReporterID] == playerid)
  350. {
  351. SendClientMessage(playerid, COLOR_GREY, "You have cancelled your /report request.");
  352. Report[i][rEnabled] = false;
  353. Report[i][rReporterID] = INVALID_PLAYER_ID;
  354. reportscount--;
  355. break;
  356. }
  357. else if(i == 199 && Report[i][rEnabled] == false)
  358. {
  359. SendClientMessage(playerid, COLOR_GREY, "You got no on-going reports.");
  360. break;
  361. }
  362. }
  363. return 1;
  364. }