Advertisement
Guest User

AntiFlood

a guest
May 28th, 2011
1,192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. #include <a_samp>
  2. #include <utils>
  3. #include "../include/gl_common"
  4.  
  5. #define ColorFlood 0x24B1DBAA
  6. #define TimerFlood 1500
  7. #define AlertFlood 4
  8.  
  9. new FloodAlert[MAX_PLAYERS],
  10. FloodTimer[MAX_PLAYERS];
  11.  
  12. public OnFilterScriptInit()
  13. {
  14. print(", [ON] .");
  15. print("| Sistema Anti Flood |");
  16. print("` By: Dr_Pawno ´");
  17. return 1;
  18. }
  19.  
  20. public OnFilterScriptExit()
  21. {
  22. print(", [OFF] .");
  23. print("| Sistema Anti Flood |");
  24. print("` By: Dr_Pawno ´");
  25. return 1;
  26. }
  27.  
  28. public OnPlayerConnect(playerid)
  29. {
  30. FloodAlert[playerid] = 0; FloodTimer[playerid] = 0;
  31. SendClientMessage(playerid, ColorFlood, "[Anti-Flood] Este server tem o Anti-Flood do {FFFF00}Dr_Pawno{24B1DB}!");
  32. return 1;
  33. }
  34.  
  35. public OnPlayerText(playerid, text[])
  36. {
  37. new string[126];
  38.  
  39. if(GetTickCount() > FloodTimer[playerid])
  40. {
  41. FloodAlert[playerid] = 0;
  42. }
  43.  
  44. FloodTimer[playerid] = GetTickCount() + TimerFlood;
  45. FloodAlert[playerid] ++;
  46.  
  47. if(FloodAlert[playerid] > 1 && FloodAlert[playerid] < AlertFlood-1)
  48. {
  49. format(string, sizeof(string), "[Anti-Flood] Você tem {FFFF00}%d/%d{24B1DB} avisos.", FloodAlert[playerid], AlertFlood);
  50. SendClientMessage(playerid, ColorFlood, string);
  51. }
  52. else if(FloodAlert[playerid] == AlertFlood-1)
  53. {
  54. format(string, sizeof(string), "[Anti-Flood] Você tem {FFFF00}%d/%d{24B1DB} avisos. Mais um e você será Kickado.", FloodAlert[playerid], AlertFlood);
  55. SendClientMessage(playerid, ColorFlood, string);
  56. }
  57. else if(FloodAlert[playerid] == AlertFlood)
  58. {
  59. format(string, sizeof(string), "[Anti-Flood] Você tem {FFFF00}%d/%d{24B1DB} avisos. Você foi Kickado.", FloodAlert[playerid], AlertFlood);
  60. SendClientMessage(playerid, ColorFlood, string);
  61. Kick(playerid);
  62. new pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, sizeof(pname));
  63. format(string, sizeof(string), "[Anti-Flood] {FFFF00}%s{24B1DB} foi kickado por Flood.", pname);
  64. SendClientMessageToAll(ColorFlood, string);
  65. return 0;
  66. }
  67. return 1;
  68. }
  69.  
  70. public OnPlayerCommandText(playerid, cmdtext[])
  71. {
  72. // New
  73. new comando[126],
  74. string[256],
  75. index,
  76. pname[MAX_PLAYER_NAME];
  77.  
  78. // Comando
  79. comando = strtok(cmdtext, index);
  80. if(!strcmp("/resetarflood", comando, true))
  81. {
  82. // Não é Admin Rcon
  83. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, ColorFlood, "[Anti-Flood] Você não é Admin RCON.");
  84.  
  85. // New (Resposta)
  86. new resposta[MAX_PLAYER_NAME];
  87. resposta = strtok(cmdtext, index);
  88.  
  89. // Sem Resposta
  90. if(!strlen(resposta)) return SendClientMessage(playerid, ColorFlood, "[Anti-Flood] /ResetarFlood [PlayerID/NOME]");
  91.  
  92. // Definir Resposta Como Jogador
  93. new player = ReturnUser(resposta);
  94.  
  95. // sizeof Não Conectado
  96. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, ColorFlood, "[Anti-Flood] Jogador Não Conectado.");
  97.  
  98. // Funções Do Player
  99. GetPlayerName(playerid, pname, sizeof(pname));
  100. format(string, sizeof(string), "[Anti-Flood] {FFFF00}%s{24B1DB} resetou o seu Flood.", pname);
  101. SendClientMessage(player, ColorFlood, string);
  102. FloodAlert[player] = 0;
  103.  
  104. // Funções Do PlayerID
  105. GetPlayerName(player, pname, sizeof(pname));
  106. format(string, sizeof(string), "[Anti-Flood] Você resetou o Flood de {FFFF00}%s{24B1DB}.", pname);
  107. SendClientMessage(playerid, ColorFlood, string);
  108. return 1;
  109. }
  110. return 0;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement