1
0

newstaffban.pwn 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Staff Ban System
  11. Winterfield,
  12. Westen
  13. Next Generation Gaming, LLC
  14. (created by Next Generation Gaming Development Team)
  15. * Copyright (c) 2016, Next Generation Gaming, LLC
  16. *
  17. * All rights reserved.
  18. *
  19. * Redistribution and use in source and binary forms, with or without modification,
  20. * are not permitted in any case.
  21. *
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  26. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  27. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  28. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  30. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  31. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. /* self notes & comments:
  36. - A player may be staff banned by a head admin or above, or a member of HR (pAdmin 1337 | pHR > 1).
  37. - Shane requested that we remove the pStaffBanned and instead use a separate table for quicker loading etc.
  38. - Staff banning and the removal of must also be able to be done offline.
  39. - For checking if a player is staff banned, there're one of two posibilities - retrieve from the table, or use an integer. Probably faster to use integer.
  40. - TODO:
  41. - /staffban
  42. - /unstaffban
  43. - /ostaffban
  44. - /ounstaffban
  45. - /staffbans
  46. - Alter /makeadmin or any commands like that so they cannot be made an admin if they are staff banned, a la blacklist system for HMA.
  47. */
  48. stock IsStaffBanned(playerid)
  49. {
  50. if(PlayerInfo[playerid][pStaffBanned]) return 1;
  51. return 0;
  52. }
  53. CMD:staffban(playerid, params[])
  54. {
  55. if(PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pHR] > 0)
  56. {
  57. new iTarget, szReason[128], iDays;
  58. if(sscanf(params, "ds[128]d", iTarget, szReason, iDays))
  59. {
  60. SendClientMessage(playerid, COLOR_GREY, "USAGE: /staffban [playerid] [reason] [duration (days)]");
  61. SendClientMessage(playerid, COLOR_GREY, "Players will automatically be unbanned after the duration has expired. To make a ban indefinite, set days as 0.");
  62. return 1;
  63. }
  64. if(!IsPlayerConnected(iTarget)) return SendClientMessage(playerid, COLOR_GRAD2, "That player is not connected.");
  65. if(PlayerInfo[iTarget][pAdmin] >= PlayerInfo[playerid][pAdmin] && PlayerInfo[playerid][pAdmin] != 99999) return SendClientMessage(playerid, COLOR_GRAD2, "You cannot perform this action on an equal or higher level administrator.");
  66. if(PlayerInfo[iTarget][pStaffBanned]) return SendClientMessage(playerid, COLOR_GRAD2, "That player is already staff banned.");
  67. // 7810 is the date just before 19 January 2038. Given that bans are specified in unix, anything above this goes above the max integer value. Crashes = :(
  68. if(iDays < 0 || iDays > 7810) return SendClientMessage(playerid, COLOR_GRAD2, "You have specified an invalid amount of days. Days must be between 0 and 7,810.");
  69. new iCreationDate, iExpireDate;
  70. iCreationDate = gettime();
  71. iExpireDate = gettime() + (iDays * 86400);
  72. if(iDays == 0) iExpireDate = 2147483640;
  73. mysql_format(MainPipeline, szMiscArray, sizeof szMiscArray, "INSERT INTO `staffbans` (`details`, `issuer`, `playerid`, `expiredate`, `created`) VALUES('%e', %d, %d, %d, %d)",
  74. szReason, GetPlayerSQLId(playerid), GetPlayerSQLId(iTarget), iExpireDate, iCreationDate);
  75. // We have to make sure the query goes through before they can be staff banned.
  76. mysql_tquery(MainPipeline, szMiscArray, "OnlineStaffBan", "ddsdd", playerid, iTarget, szReason, iCreationDate, iDays);
  77. }
  78. else SendClientMessage(playerid, COLOR_GRAD2, "You're not authorised to use this command.");
  79. return 1;
  80. }
  81. CMD:unstaffban(playerid, params[])
  82. {
  83. if(PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pHR] > 0)
  84. {
  85. new iTarget, szReason[128];
  86. if(sscanf(params, "ds[128]", iTarget, szReason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /unstaffban [playerid] [reason]");
  87. if(!IsPlayerConnected(iTarget)) return SendClientMessage(playerid, COLOR_GRAD2, "That player is not connected.");
  88. if(!PlayerInfo[iTarget][pStaffBanned]) return SendClientMessage(playerid, COLOR_GRAD2, "That player is not staff banned.");
  89. mysql_format(MainPipeline, szMiscArray, sizeof szMiscArray, "UPDATE `staffbans` SET `status`=2 WHERE `playerid`=%d AND `status`=1", GetPlayerSQLId(iTarget));
  90. mysql_tquery(MainPipeline, szMiscArray, "RemoveStaffBan", "dds", playerid, iTarget, szReason);
  91. }
  92. else SendClientMessage(playerid, COLOR_GRAD2, "You're not authorised to use this command.");
  93. return 1;
  94. }
  95. CMD:ostaffban(playerid, params[])
  96. {
  97. if(PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pHR] > 0)
  98. {
  99. new szTarget[MAX_PLAYER_NAME], szReason[128], iDays;
  100. if(sscanf(params, "s[24]s[128]d", szTarget, szReason, iDays)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /ostaffban [account name] [reason] [duration (in days)]");
  101. if(IsPlayerConnected(ReturnUser(szTarget))) return SendClientMessageEx(playerid, COLOR_GREY, "That player is currently connected, use /staffban.");
  102. if(iDays < 0 || iDays > 7810) return SendClientMessage(playerid, COLOR_GRAD2, "You have specified an invalid amount of days. Days must be between 0 and 7,810.");
  103. mysql_format(MainPipeline, szMiscArray,sizeof(szMiscArray),"UPDATE `accounts` SET `AdminLevel` = 0, `HR` = 0, `AP` = 0, `Security` = 0, `ShopTech` = 0, `FactionModerator` = 0, `GangModerator` = 0, \
  104. `Undercover` = 0, `BanAppealer` = 0, `Helper` = 0, `pVIPMod` = 0, `SecureIP` = '0.0.0.0', `SeniorModerator` = 0, `BanAppealer` = 0, `ShopTech` = 0, `StaffBanned` = 1 WHERE `Username`= '%s' AND `AdminLevel` < %d AND `StaffBanned` = 0", szTarget, PlayerInfo[playerid][pAdmin]);
  105. mysql_tquery(MainPipeline, szMiscArray, "OfflineStaffBan", "dssd", playerid, szTarget, szReason, iDays);
  106. for(new i = 0; i < MAX_PLAYER_NAME; i++) if(szTarget[i] == '_') szTarget[i] = ' '; // Remove the underscore, looks nicer for the person using the command.
  107. format(szMiscArray, sizeof szMiscArray, "Attempting to staff ban %s.", szTarget);
  108. SendClientMessage(playerid, COLOR_WHITE, szMiscArray);
  109. }
  110. else SendClientMessage(playerid, COLOR_GRAD2, "You're not authorised to use this command.");
  111. return 1;
  112. }
  113. CMD:ounstaffban(playerid, params[])
  114. {
  115. if(PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pHR] > 0)
  116. {
  117. new szTarget[MAX_PLAYER_NAME];
  118. if(sscanf(params, "s[24]", szTarget)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /ounstaffban [account name]");
  119. if(IsPlayerConnected(ReturnUser(szTarget))) return SendClientMessageEx(playerid, COLOR_GREY, "That player is currently connected, use /unstaffban.");
  120. mysql_format(MainPipeline, szMiscArray,sizeof(szMiscArray),"UPDATE `accounts` SET `StaffBanned`=0 WHERE `Username`= '%s' AND `StaffBanned` = 1", szTarget, PlayerInfo[playerid][pAdmin]);
  121. mysql_tquery(MainPipeline, szMiscArray, "OfflineRemoveStaffBan", "ds", playerid, szTarget);
  122. for(new i = 0; i < MAX_PLAYER_NAME; i++) if(szTarget[i] == '_') szTarget[i] = ' '; // Remove the underscore, looks nicer for the person using the command.
  123. format(szMiscArray, sizeof szMiscArray, "Attempting to remove %s's staff ban.", szTarget);
  124. SendClientMessage(playerid, COLOR_WHITE, szMiscArray);
  125. }
  126. else SendClientMessage(playerid, COLOR_GRAD2, "You're not authorised to use this command.");
  127. return 1;
  128. }
  129. CMD:staffbans(playerid, params[])
  130. {
  131. if(PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pHR] > 0)
  132. {
  133. SendClientMessage(playerid, COLOR_GREEN,"_______________________________________");
  134. SendClientMessage(playerid, COLOR_GRAD3, "List of online staff bans: ");
  135. foreach(new i: Player)
  136. {
  137. if(PlayerInfo[i][pStaffBanned] == 1)
  138. {
  139. mysql_format(MainPipeline, szMiscArray, sizeof szMiscArray, "SELECT * FROM `staffbans` WHERE `playerid`=%d", GetPlayerSQLId(i));
  140. mysql_tquery(MainPipeline, szMiscArray, "DisplayStaffBan", "dd", playerid, i);
  141. }
  142. }
  143. SendClientMessage(playerid, COLOR_GREEN,"_______________________________________");
  144. }
  145. else SendClientMessage(playerid, COLOR_GRAD2, "You're not authorised to use this command.");
  146. return 1;
  147. }
  148. forward DisplayStaffBan(iPlayer, iBanned);
  149. public DisplayStaffBan(iPlayer, iBanned)
  150. {
  151. new szReason[128], iIssuedBy, iCreated, iExpire;
  152. new rows;
  153. cache_get_row_count(rows);
  154. if(rows > 0)
  155. {
  156. for(new row = 0; row < rows; row++)
  157. {
  158. cache_get_value_name(row, "details", szReason, 128);
  159. cache_get_value_name_int(row, "issuer", iIssuedBy);
  160. cache_get_value_name_int(row, "created", iCreated);
  161. cache_get_value_name_int(row, "expiredate", iExpire);
  162. }
  163. mysql_format(MainPipeline, szMiscArray, sizeof szMiscArray, "SELECT `Username` FROM `accounts` WHERE `id`=%d", iIssuedBy);
  164. mysql_tquery(MainPipeline, szMiscArray, "FetchIssuer", "ddsddd", iPlayer, iBanned, szReason, iIssuedBy, iCreated, iExpire);
  165. }
  166. return 1;
  167. }
  168. forward FetchIssuer(iPlayer, iBanned, szReason[], iIssuedBy, iCreated, iExpire);
  169. public FetchIssuer(iPlayer, iBanned, szReason[], iIssuedBy, iCreated, iExpire)
  170. {
  171. new rows;
  172. cache_get_row_count(rows);
  173. if(rows > 0)
  174. {
  175. new szUsername[MAX_PLAYER_NAME];
  176. for(new row = 0; row < rows; row++)
  177. {
  178. cache_get_value_name(row, "Username", szUsername, MAX_PLAYER_NAME);
  179. }
  180. format(szMiscArray, sizeof szMiscArray, "%s (ID: %d) banned by %s, reason: %s - expire date: %s", GetPlayerNameEx(iBanned), iBanned, szUsername, szReason, date(iExpire, 1));
  181. SendClientMessage(iPlayer, COLOR_GRAD1, szMiscArray);
  182. }
  183. return 1;
  184. }
  185. forward OfflineRemoveStaffBan(iIssuer, szTarget[]);
  186. public OfflineRemoveStaffBan(iIssuer, szTarget[])
  187. {
  188. if(!cache_affected_rows()) return SendClientMessage(iIssuer, COLOR_GRAD2, "There was an error removing the staff ban from that account.");
  189. mysql_format(MainPipeline, szMiscArray, sizeof szMiscArray, "SELECT `Username`, `id` FROM `accounts` WHERE `Username`='%s'", szTarget);
  190. mysql_tquery(MainPipeline, szMiscArray, "RetrieveTargetIDUnban", "ds", iIssuer, szTarget);
  191. return 1;
  192. }
  193. forward RetrieveTargetIDUnban(iIssuer, szTarget[]);
  194. public RetrieveTargetIDUnban(iIssuer, szTarget[])
  195. {
  196. new szUsername[MAX_PLAYER_NAME], iSQLID;
  197. new rows;
  198. cache_get_row_count(rows);
  199. if(rows > 0)
  200. {
  201. for(new row = 0; row < rows; row++)
  202. {
  203. cache_get_value_name(row, "Username", szUsername, MAX_PLAYER_NAME);
  204. cache_get_value_name_int(row, "id", iSQLID);
  205. }
  206. mysql_format(MainPipeline, szMiscArray, sizeof szMiscArray, "UPDATE `staffbans` SET `status`=2 WHERE `playerid`=%d AND `status`=1", iSQLID);
  207. mysql_tquery(MainPipeline, szMiscArray, "ProcessOfflineUnStaffBan", "dsd", iIssuer, szTarget, iSQLID);
  208. }
  209. else // Because we don't have their SQL ID we shouldn't log it, because we can't track who the staff ban belongs to.
  210. {
  211. format(szMiscArray, sizeof szMiscArray, "%s's staff ban was removed but the row in `staffbans` could not be removed.", szTarget);
  212. Log("logs/staffban.log", szMiscArray);
  213. }
  214. return 1;
  215. }
  216. forward ProcessOfflineUnStaffBan(iIssuer, szTarget[], iSQLID);
  217. public ProcessOfflineUnStaffBan(iIssuer, szTarget[], iSQLID)
  218. {
  219. if(!cache_affected_rows())
  220. {
  221. format(szMiscArray, sizeof szMiscArray, "%s was un-staff banned but the row could not be deleted from `staffbans`.", szTarget);
  222. Log("logs/staffban.log", szMiscArray);
  223. return 1;
  224. }
  225. // Inform the issuer.
  226. format(szMiscArray, sizeof szMiscArray, "You have successfully removed %s's staff ban.", szTarget);
  227. SendClientMessage(iIssuer, COLOR_GRAD1, szMiscArray);
  228. // Inform the admins.
  229. format(szMiscArray, sizeof szMiscArray, "{AA3333}AdmWarning{FFFF00}: %s has had their staff ban removed by %s (offline).", szTarget, GetPlayerNameEx(iIssuer));
  230. ABroadCast(COLOR_YELLOW, szMiscArray, 4);
  231. // Log it.
  232. format(szMiscArray, sizeof szMiscArray, "%s (%d) had their staff ban removed (offline) by %s (%d)", szTarget, iSQLID, GetPlayerNameEx(iIssuer), GetPlayerSQLId(iIssuer));
  233. Log("logs/staffban.log", szMiscArray);
  234. return 1;
  235. }
  236. forward OfflineStaffBan(iIssuer, szTarget[], szReason[], iDays);
  237. public OfflineStaffBan(iIssuer, szTarget[], szReason[], iDays)
  238. {
  239. if(!cache_affected_rows()) return SendClientMessage(iIssuer, COLOR_GRAD2, "There was an error offline staff banning that account.");
  240. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "SELECT `Username`, `id` FROM `accounts` WHERE `Username`='%s'", szTarget);
  241. mysql_tquery(MainPipeline, szMiscArray, "RetrieveTargetID", "dssd", iIssuer, szTarget, szReason, iDays);
  242. return 1;
  243. }
  244. forward RetrieveTargetID(iIssuer, szTarget[], szReason[], iDays);
  245. public RetrieveTargetID(iIssuer, szTarget[], szReason[], iDays)
  246. {
  247. new szUsername[MAX_PLAYER_NAME], iSQLID;
  248. new rows;
  249. cache_get_row_count(rows);
  250. if(rows > 0)
  251. {
  252. for(new row = 0; row < rows; row++)
  253. {
  254. cache_get_value_name(row, "Username", szUsername, MAX_PLAYER_NAME);
  255. cache_get_value_name_int(row, "id", iSQLID);
  256. }
  257. // Now we have their SQL ID we can insert into the table.
  258. new iCreationDate = gettime();
  259. new iExpireDate = gettime() + (iDays * 86400);
  260. if(iDays == 0) iExpireDate = 2147483640;
  261. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "INSERT INTO `staffbans` (`details`, `issuer`, `playerid`, `expiredate`, `created`) VALUES('%e', %d, %d, %d, %d)",
  262. szReason, GetPlayerSQLId(iIssuer), iSQLID, iExpireDate, iCreationDate);
  263. mysql_tquery(MainPipeline, szMiscArray, "ProcessOfflineStaffBan", "dssdd", iIssuer, szTarget, szReason, iDays, iSQLID);
  264. }
  265. else // Because we don't have their SQL ID we shouldn't log it, because we can't track who the staff ban belongs to.
  266. {
  267. format(szMiscArray, sizeof szMiscArray, "%s was staff banned but a row could not be added to `staffbans`.", szTarget);
  268. Log("logs/staffban.log", szMiscArray);
  269. }
  270. return 1;
  271. }
  272. forward ProcessOfflineStaffBan(iIssuer, szTarget[], szReason[], iDays, iSQLID);
  273. public ProcessOfflineStaffBan(iIssuer, szTarget[], szReason[], iDays, iSQLID)
  274. {
  275. if(!cache_affected_rows())
  276. {
  277. format(szMiscArray, sizeof szMiscArray, "%s was staff banned but a row could not be added to `staffbans`.", szTarget);
  278. Log("logs/staffban.log", szMiscArray);
  279. return 1;
  280. }
  281. if(iDays != 0)
  282. {
  283. // Inform the issuer.
  284. format(szMiscArray, sizeof szMiscArray, "You have successfully staff banned %s, reason: %s.", szTarget, szReason);
  285. SendClientMessage(iIssuer, COLOR_GRAD1, szMiscArray);
  286. // If the server is lagging then this may be off by about a second. Given the display isn't what is stored, it is not exactly important.
  287. format(szMiscArray, sizeof szMiscArray, "Unban Date: %s", date(gettime() + (iDays * 86400), 1));
  288. SendClientMessage(iIssuer, COLOR_GRAD1, szMiscArray);
  289. // Inform the admins.
  290. format(szMiscArray, sizeof szMiscArray, "{AA3333}AdmWarning{FFFF00}: %s has been offline staff banned by %s, reason: %s.", szTarget, GetPlayerNameEx(iIssuer), szReason);
  291. ABroadCast(COLOR_YELLOW, szMiscArray, 4);
  292. // Log it.
  293. format(szMiscArray, sizeof szMiscArray, "%s (%d) was offline staff banned by %s (%d), reason: %s | Duration: %d days | Unban Date: %s", szTarget, iSQLID, GetPlayerNameEx(iIssuer), GetPlayerSQLId(iIssuer),
  294. szReason, iDays, date(gettime() + (iDays * 86400), 1));
  295. Log("logs/staffban.log", szMiscArray);
  296. }
  297. else
  298. {
  299. // Inform the issuer.
  300. format(szMiscArray, sizeof szMiscArray, "You have successfully staff banned %s indefinitely, reason: %s. ", szTarget, szReason);
  301. SendClientMessage(iIssuer, COLOR_GRAD1, szMiscArray);
  302. // Inform the admins.
  303. format(szMiscArray, sizeof szMiscArray, "{AA3333}AdmWarning{FFFF00}: %s has been staff banned by %s, reason: %s.", szTarget, GetPlayerNameEx(iIssuer), szReason);
  304. ABroadCast(COLOR_YELLOW, szMiscArray, 4);
  305. // Log it.
  306. format(szMiscArray, sizeof szMiscArray, "%s (%d) was staff banned by %s (%d), reason: %s | Duration: indefinite", szTarget, iSQLID, GetPlayerNameEx(iIssuer), GetPlayerSQLId(iIssuer), szReason);
  307. Log("logs/staffban.log", szMiscArray);
  308. }
  309. return 1;
  310. }
  311. forward RemoveStaffBan(iIssuer, iTarget, szReason[]);
  312. public RemoveStaffBan(iIssuer, iTarget, szReason[])
  313. {
  314. if(!cache_affected_rows()) return SendClientMessage(iIssuer, COLOR_GRAD2, "There was an error removing the staff ban from that account.");
  315. PlayerInfo[iTarget][pStaffBanned] = 0;
  316. // Inform the issuer.
  317. format(szMiscArray, sizeof szMiscArray, "You have successfully removed %s's staff ban, reason: %s.", GetPlayerNameEx(iTarget), szReason);
  318. SendClientMessage(iIssuer, COLOR_GRAD1, szMiscArray);
  319. // Inform the player.
  320. format(szMiscArray, sizeof szMiscArray, "Your staff ban was removed by %s, reason: %s.", GetPlayerNameEx(iIssuer), szReason);
  321. SendClientMessage(iTarget, COLOR_LIGHTRED, szMiscArray);
  322. // Inform the admins.
  323. format(szMiscArray, sizeof szMiscArray, "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has had their staff ban removed by %s, reason: %s.", GetPlayerNameEx(iTarget), iTarget, GetPlayerNameEx(iIssuer), szReason);
  324. ABroadCast(COLOR_YELLOW, szMiscArray, 4);
  325. // Log it.
  326. format(szMiscArray, sizeof szMiscArray, "%s's (%d) staff ban was removed by %s (%d), reason: %s", GetPlayerNameEx(iTarget), GetPlayerSQLId(iTarget), GetPlayerNameEx(iIssuer), GetPlayerSQLId(iIssuer), szReason);
  327. Log("logs/staffban.log", szMiscArray);
  328. g_mysql_SaveAccount(iTarget);
  329. return 1;
  330. }
  331. forward OnlineStaffBan(iIssuer, iTarget, szReason[], iCreationDate, iDays);
  332. public OnlineStaffBan(iIssuer, iTarget, szReason[], iCreationDate, iDays)
  333. {
  334. if(!cache_affected_rows()) return SendClientMessage(iIssuer, COLOR_GRAD2, "There was an error staff banning that account.");
  335. // Main staff variables.
  336. PlayerInfo[iTarget][pAdmin] = 0;
  337. PlayerInfo[iTarget][pSMod] = 0;
  338. PlayerInfo[iTarget][pVIPMod] = 0;
  339. PlayerInfo[iTarget][pHelper] = 0;
  340. // Secondary tasks.
  341. PlayerInfo[iTarget][pFactionModerator] = 0;
  342. PlayerInfo[iTarget][pGangModerator] = 0;
  343. PlayerInfo[iTarget][pUndercover] = 0;
  344. PlayerInfo[iTarget][pBanAppealer] = 0;
  345. PlayerInfo[iTarget][pShopTech] = 0;
  346. PlayerInfo[iTarget][pPR] = 0;
  347. PlayerInfo[iTarget][pHR] = 0;
  348. PlayerInfo[iTarget][pSecurity] = 0;
  349. PlayerInfo[iTarget][pBM] = 0;
  350. PlayerInfo[iTarget][pASM] = 0;
  351. PlayerInfo[iTarget][pStaffBanned] = 1;
  352. if(iDays != 0)
  353. {
  354. // Inform the issuer.
  355. format(szMiscArray, sizeof szMiscArray, "You have successfully staff banned %s, reason: %s.", GetPlayerNameEx(iTarget), szReason);
  356. SendClientMessage(iIssuer, COLOR_GRAD1, szMiscArray);
  357. format(szMiscArray, sizeof szMiscArray, "Unban Date: %s", date(iCreationDate + (iDays * 86400), 1));
  358. SendClientMessage(iIssuer, COLOR_GRAD1, szMiscArray);
  359. // Inform the player.
  360. format(szMiscArray, sizeof szMiscArray, "You have been staff banned by %s, reason: %s.", GetPlayerNameEx(iIssuer), szReason);
  361. SendClientMessage(iTarget, COLOR_LIGHTRED, szMiscArray);
  362. format(szMiscArray, sizeof szMiscArray, "Your unban date is %s.", date(iCreationDate + (iDays * 86400), 1));
  363. SendClientMessage(iTarget, COLOR_LIGHTRED, szMiscArray);
  364. // Inform the admins.
  365. format(szMiscArray, sizeof szMiscArray, "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has been staff banned by %s, reason: %s.", GetPlayerNameEx(iTarget), iTarget, GetPlayerNameEx(iIssuer), szReason);
  366. ABroadCast(COLOR_YELLOW, szMiscArray, 4);
  367. // Log it.
  368. format(szMiscArray, sizeof szMiscArray, "%s (%d) was staff banned by %s (%d), reason: %s | Duration: %d days | Unban Date: %s", GetPlayerNameEx(iTarget), GetPlayerSQLId(iTarget), GetPlayerNameEx(iIssuer), GetPlayerSQLId(iIssuer),
  369. szReason, iDays, date(iCreationDate + (iDays * 86400), 1));
  370. Log("logs/staffban.log", szMiscArray);
  371. }
  372. else
  373. {
  374. // Inform the issuer.
  375. format(szMiscArray, sizeof szMiscArray, "You have successfully staff banned %s indefinitely, reason: %s. ", GetPlayerNameEx(iTarget), szReason);
  376. SendClientMessage(iIssuer, COLOR_GRAD1, szMiscArray);
  377. // Inform the player.
  378. format(szMiscArray, sizeof szMiscArray, "You have been staff banned indefinitely by %s, reason: %s.", GetPlayerNameEx(iIssuer), szReason);
  379. SendClientMessage(iTarget, COLOR_LIGHTRED, szMiscArray);
  380. // Inform the admins.
  381. format(szMiscArray, sizeof szMiscArray, "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has been staff banned by %s, reason: %s.", GetPlayerNameEx(iTarget), iTarget, GetPlayerNameEx(iIssuer), szReason);
  382. ABroadCast(COLOR_YELLOW, szMiscArray, 4);
  383. // Log it.
  384. format(szMiscArray, sizeof szMiscArray, "%s (%d) was staff banned by %s (%d), reason: %s | Duration: indefinite", GetPlayerNameEx(iTarget), GetPlayerSQLId(iTarget), GetPlayerNameEx(iIssuer), GetPlayerSQLId(iIssuer), szReason);
  385. Log("logs/staffban.log", szMiscArray);
  386. }
  387. g_mysql_SaveAccount(iTarget);
  388. return 1;
  389. }