Advertisement
ObtiMus

Warnings

Aug 4th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.01 KB | None | 0 0
  1. /*
  2.  
  3. * AdminWarnings Plugin.
  4. * This Plugin Built By koko.
  5. * Please DO NOT Change The Credit.
  6.  
  7. */
  8.  
  9. #include <amxmodx>
  10. #include <amxmisc>
  11. #include <fvault>
  12.  
  13. #define GIVEACCESS ADMIN_IMMUNITY
  14. #define CommunityName "koko"
  15.  
  16. new warnings[33];
  17.  
  18. new const szVaultName[] = "Warnings_Vault";
  19.  
  20. public plugin_init() {
  21. register_plugin("Admin Warnings", "1.0", "koko")
  22.  
  23. register_clcmd("say", "AddNTakeWarnings");
  24. register_clcmd("say", "ShowWarnings");
  25. register_clcmd("say /mywarnings", "MyWarnings");
  26. }
  27.  
  28. public client_connect(id)
  29. {
  30. Load(id);
  31. }
  32.  
  33. public client_disconnect(id)
  34. {
  35. Save(id);
  36. }
  37.  
  38. public AddNTakeWarnings(id)
  39. {
  40. new Message[192], Cmd[33], Amount[33], HisName[33];
  41. read_args(Message, 191);
  42. remove_quotes(Message);
  43.  
  44. parse(Message, Cmd, 32, HisName, 32, Amount, 32);
  45.  
  46. // Add Warnings
  47.  
  48. if(equali(Cmd, "/addwarning") || equali(Cmd, "/addwarnings") || equali(Cmd, "/givewarnings") || equali(Cmd, "/givewarning"))
  49. {
  50. new AddPlayer = cmd_target(AddPlayer, HisName, 8);
  51.  
  52. if(equali(HisName, ""))
  53. {
  54. ColorChat(id, "^4Sytax: ^1<admin name> <amount>");
  55.  
  56. return 1;
  57. }
  58.  
  59. if(!AddPlayer)
  60. {
  61. ColorChat(id, "^1This player ^4was not ^1found.");
  62.  
  63. return 1;
  64. }
  65.  
  66. if(AddPlayer == id)
  67. {
  68. ColorChat(id, "^1You ^4cannot ^1add warnings to yourself.");
  69.  
  70. return 1;
  71. }
  72.  
  73. if(!(get_user_flags(AddPlayer) & ADMIN_CHAT))
  74. {
  75. ColorChat(id, "^1This player ^4is not ^1a admin.");
  76.  
  77. return 1;
  78. }
  79.  
  80. new ChatAmount = str_to_num(Amount)
  81.  
  82. if(ChatAmount > 5)
  83. {
  84. ColorChat(id, "^1max warnings ^4is^1 5.");
  85.  
  86. return 1;
  87. }
  88.  
  89. if(AddPlayer && ChatAmount)
  90. {
  91. ColorChat(0, "^1%s ^4just added ^1to %s^4 %i warnings.", GetName(id), GetName(AddPlayer), ChatAmount);
  92.  
  93. warnings[AddPlayer] += ChatAmount;
  94.  
  95. if(warnings[AddPlayer] > 5)
  96. warnings[AddPlayer] = 5;
  97.  
  98. if(warnings[AddPlayer] == 5)
  99. {
  100. ColorChat(0, "^4%s ^1just got his^4 5 warnings^1, and now he ^4dont have ^1admin anymore.", GetName(AddPlayer));
  101.  
  102. new Flags = get_user_flags(AddPlayer)
  103. remove_user_flags(AddPlayer, Flags)
  104.  
  105. warnings[AddPlayer] = 0;
  106.  
  107. return 1;
  108. }
  109.  
  110. Save(AddPlayer);
  111.  
  112. return 1;
  113. }
  114.  
  115. else if(AddPlayer)
  116. {
  117. ColorChat(id, "^1You ^4must ^1type amount.");
  118.  
  119. return 1;
  120. }
  121. }
  122.  
  123. // Remove Warnings
  124.  
  125. if(equali(Cmd, "/removewarning") || equali(Cmd, "/removewarnings") || equali(Cmd, "/takewarnings") || equali(Cmd, "/takewarnings"))
  126. {
  127. new TakePlayer = cmd_target(TakePlayer, HisName, 8);
  128.  
  129. if(equali(HisName, ""))
  130. {
  131. ColorChat(id, "^4Sytax: ^1<admin name> <amount>");
  132.  
  133. return 1;
  134. }
  135.  
  136. if(!TakePlayer)
  137. {
  138. ColorChat(id, "^1This player ^4was not ^1found.");
  139.  
  140. return 1;
  141. }
  142.  
  143. if(TakePlayer == id)
  144. {
  145. ColorChat(id, "^1You ^4cannot ^1remove warnings to yourself.");
  146.  
  147. return 1;
  148. }
  149.  
  150. if(!(get_user_flags(TakePlayer) & ADMIN_CHAT))
  151. {
  152. ColorChat(id, "^1This player ^4is not ^1a admin.");
  153.  
  154. return 1;
  155. }
  156.  
  157. new ChatAmount = str_to_num(Amount)
  158.  
  159. if(ChatAmount > 5)
  160. {
  161. ColorChat(id, "^1You must remove ^4at least^1 5 warnings.");
  162.  
  163. return 1;
  164. }
  165.  
  166. if(warnings[id] == 0)
  167. {
  168. ColorChat(id, "^1This player ^4dont have ^1warnings.");
  169.  
  170. return 1;
  171. }
  172.  
  173. if(TakePlayer && ChatAmount)
  174. {
  175. ColorChat(0, "^1%s ^4just removed ^1to %s^4 %i warnings.", GetName(id), GetName(TakePlayer), ChatAmount);
  176.  
  177. warnings[TakePlayer] -= ChatAmount;
  178.  
  179. if(warnings[TakePlayer] < 0)
  180. warnings[TakePlayer] = 0;
  181.  
  182. Save(TakePlayer);
  183.  
  184. return 1;
  185. }
  186.  
  187. else if(TakePlayer)
  188. {
  189. ColorChat(id, "^1You ^4must ^1type amount.");
  190.  
  191. return 1;
  192. }
  193. }
  194. return 0;
  195. }
  196.  
  197. public ShowWarnings(id)
  198. {
  199. new Message[192], Cmd[33], HisName[33];
  200. read_args(Message, 191);
  201. remove_quotes(Message);
  202.  
  203. parse(Message, Cmd, 32, HisName, 32);
  204.  
  205. // Add Warnings
  206.  
  207. if(equali(Cmd, "/warning") || equali(Cmd, "/warnings"))
  208. {
  209. new ThePlayer = cmd_target(ThePlayer, HisName, 8);
  210.  
  211. if(equali(HisName, ""))
  212. {
  213. ColorChat(id, "^4Sytax: ^1<admin name>");
  214.  
  215. return 1;
  216. }
  217.  
  218. if(!ThePlayer)
  219. {
  220. ColorChat(id, "^1This player ^4was not ^1found.");
  221.  
  222. return 1;
  223. }
  224.  
  225. if(ThePlayer == id)
  226. {
  227. ColorChat(id, "^1type ^4/mywarnings^1.");
  228.  
  229. return 1;
  230. }
  231.  
  232. if(!(get_user_flags(ThePlayer) & ADMIN_CHAT))
  233. {
  234. ColorChat(id, "^1This player ^4is not ^1a admin.");
  235.  
  236. return 1;
  237. }
  238.  
  239. if(ThePlayer)
  240. {
  241. ColorChat(id, "^1%s have^4 %i ^1warnings.", GetName(ThePlayer), warnings[ThePlayer])
  242.  
  243. return 1;
  244. }
  245. }
  246. return 0;
  247. }
  248.  
  249. public MyWarnings(id)
  250. {
  251. if(!(get_user_flags(id) & ADMIN_CHAT))
  252. return 1;
  253. ColorChat(id, "^1You have^4 %i ^1warnings.", warnings[id]);
  254.  
  255. return 1;
  256. }
  257.  
  258. public Save(id)
  259. {
  260. new Steam[35], IP[22], bool:SteamUser, szData[32];
  261. get_user_authid(id, Steam, 35);
  262.  
  263. if(equal(Steam, "STEAM_ID_LAN"))
  264. {
  265. SteamUser = true;
  266. get_user_ip(id, IP, 21);
  267. }
  268.  
  269. formatex(szData, 31, "%i", warnings[id]);
  270. fvault_set_data(szVaultName, SteamUser ? IP : Steam, szData);
  271. }
  272.  
  273. public Load(id)
  274. {
  275. new Steam[35], IP[22], bool:SteamUser, szData[32];
  276. get_user_authid(id, Steam, 35);
  277.  
  278. if(equal(Steam, "STEAM_ID_LAN"))
  279. {
  280. SteamUser = true;
  281. get_user_ip(id, IP, 21);
  282. }
  283.  
  284. new szwarnings[16];
  285.  
  286. if(fvault_get_data(szVaultName, SteamUser ? IP : Steam, szData, 31))
  287. {
  288. parse(szData, szwarnings, 15);
  289.  
  290. warnings[id] = str_to_num(szwarnings);
  291. }
  292. else
  293. {
  294. warnings[id] = 0;
  295. }
  296. }
  297.  
  298. stock GetName(id)
  299. {
  300. static szName[33];
  301. get_user_name(id, szName, charsmax(szName));
  302. return szName;
  303. }
  304.  
  305. stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...) {
  306. new msg[191], players[32], count = 1
  307.  
  308. new Community[30];
  309. formatex(Community, charsmax(Community), "^3[%s] ", CommunityName);
  310.  
  311. static len
  312. len = formatex(msg, charsmax(msg), Community)
  313. vformat(msg[len], charsmax(msg) - len, string, 3)
  314.  
  315. if(id) players[0] = id
  316. else get_players(players,count,"ch")
  317.  
  318. for (new i = 0; i < count; i++)
  319. {
  320. if(is_user_connected(players[i]))
  321. {
  322. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
  323. write_byte(players[i])
  324. write_string(msg)
  325. message_end()
  326. }
  327. }
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement