flags.pwn 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Flag System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. CMD:viewflags(playerid, params[])
  34. {
  35. if(PlayerInfo[playerid][pAdmin] >= 2)
  36. {
  37. new string[128];
  38. SendClientMessageEx(playerid, COLOR_YELLOW, "Player Flag Count List (/viewflag [player] to view):");
  39. new fCounter;
  40. foreach(new i: Player)
  41. {
  42. if(PlayerInfo[i][pFlagged] > 0)
  43. {
  44. format(string, sizeof(string), "%s(%d) Flag Count: %d.",GetPlayerNameEx(i),i,PlayerInfo[i][pFlagged]);
  45. SendClientMessageEx(playerid, COLOR_GRAD1, string);
  46. fCounter += 1;
  47. }
  48. }
  49. if(fCounter <= 0)
  50. {
  51. SendClientMessageEx(playerid, COLOR_GRAD1, "None.");
  52. }
  53. }
  54. else
  55. {
  56. SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  57. }
  58. return 1;
  59. }
  60. CMD:viewflag(playerid, params[])
  61. {
  62. if(PlayerInfo[playerid][pAdmin] >= 2)
  63. {
  64. new giveplayerid;
  65. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /viewflag [player]");
  66. if(IsPlayerConnected(giveplayerid))
  67. {
  68. DisplayFlags(playerid, giveplayerid);
  69. }
  70. }
  71. else
  72. {
  73. SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  74. }
  75. return 1;
  76. }
  77. CMD:oflag(playerid, params[])
  78. {
  79. if (PlayerInfo[playerid][pAdmin] >= 2)
  80. {
  81. new string[128], query[256], name[MAX_PLAYER_NAME], reason[64], month, day, year;
  82. if(sscanf(params, "s[24]s[64]", name, reason)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /oflag [player name] [reason]");
  83. getdate(year,month,day);
  84. new giveplayerid = ReturnUser(name);
  85. if(IsPlayerConnected(giveplayerid))
  86. {
  87. AddFlag(giveplayerid, playerid, reason);
  88. SendClientMessage(playerid, COLOR_WHITE, "The person is online and has been flagged!");
  89. format(string, sizeof(string), "AdmCmd: %s was flagged by %s, reason: %s.", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
  90. ABroadCast(COLOR_LIGHTRED, string, 2);
  91. format(string, sizeof(string), "%s was flagged by %s (%s).", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
  92. Log("logs/flags.log", string);
  93. }
  94. else
  95. {
  96. new tmpReason[64], tmpName[24];
  97. mysql_escape_string(reason, tmpReason);
  98. mysql_escape_string(name, tmpName);
  99. SetPVarString(playerid, "OnAddFlag", tmpName);
  100. SetPVarString(playerid, "OnAddFlagReason", tmpReason);
  101. mysql_format(MainPipeline, query, sizeof(query), "SELECT id FROM `accounts` WHERE `Username`='%s'", tmpName);
  102. mysql_tquery(MainPipeline, query, "FlagQueryFinish", "iii", playerid, INVALID_PLAYER_ID, Flag_Query_Offline);
  103. format(string, sizeof(string), "Attempting to append %s's flag...", tmpName);
  104. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  105. }
  106. return 1;
  107. }
  108. return 1;
  109. }
  110. CMD:flag(playerid, params[])
  111. {
  112. if (PlayerInfo[playerid][pAdmin] >= 2)
  113. {
  114. new string[128], giveplayerid, reason[64];
  115. if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /flag [player] [reason]");
  116. if(IsPlayerConnected(giveplayerid))
  117. {
  118. AddFlag(giveplayerid, playerid, reason);
  119. format(string, sizeof(string), "AdmCmd: %s was flagged by %s, reason: %s.", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
  120. ABroadCast(COLOR_LIGHTRED, string, 2);
  121. format(string, sizeof(string), "%s was flagged by %s (%s).", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
  122. Log("logs/flags.log", string);
  123. return 1;
  124. }
  125. }
  126. else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
  127. return 1;
  128. }
  129. CMD:transferflag(playerid, params[])
  130. {
  131. if(PlayerInfo[playerid][pAdmin] < 2) return 1;
  132. new to, from, flagid;
  133. if(sscanf(params, "iuu", flagid, to, from)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /transferflag [flag] [to] [from]");
  134. if(!IsPlayerConnected(to)) return SendClientMessageEx(playerid, COLOR_GRAD2, "ERROR: That player is not connected (to)");
  135. if(!IsPlayerConnected(from)) return SendClientMessageEx(playerid, COLOR_GRAD2, "ERROR: That player is not connected (from)");
  136. if(to == from) return SendClientMessageEx(playerid, COLOR_GRAD2, "ERROR: You cannot transfer to the same person");
  137. new query[128];
  138. mysql_format(MainPipeline, query, sizeof(query), "SELECT id, flag, issuer, time, type FROM `flags` WHERE `fid` = %i", flagid);
  139. mysql_tquery(MainPipeline, query, "OnRequestTransferFlag", "iiii", playerid, flagid, to, from);
  140. return 1;
  141. }
  142. CMD:aviewflag(playerid, params[])
  143. {
  144. if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  145. new giveplayerid;
  146. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /aviewflag [player]");
  147. if(!IsPlayerConnected(giveplayerid)) return SendClientMessageEx(playerid, COLOR_GRAD1, "Error: Player is not connected!");
  148. return DisplayFlags(playerid, giveplayerid, 2);
  149. }
  150. CMD:aflag(playerid, params[])
  151. {
  152. if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  153. new giveplayerid, reason[64];
  154. if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /aflag [player] [reason]");
  155. if(!IsPlayerConnected(giveplayerid)) return SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
  156. AddFlag(giveplayerid, playerid, reason, 2);
  157. new string[128];
  158. format(string, sizeof(string), "AdmCmd: %s was admin flagged by %s, reason: %s.", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
  159. ABroadCast(COLOR_LIGHTRED, string, 2);
  160. format(string, sizeof(string), "[AFLAG] %s was admin flagged by %s (%s).", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
  161. Log("logs/flags.log", string);
  162. return 1;
  163. }
  164. CMD:deleteflag(playerid, params[])
  165. {
  166. if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  167. return ShowPlayerDialogEx(playerid, FLAG_DELETE, DIALOG_STYLE_INPUT, "FLAG DELETION", "Which flag would you like to delete?", "Delete Flag", "Close");
  168. }