Guest User

Anti-Ammospam

a guest
Feb 14th, 2015
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.77 KB | None | 0 0
  1. /*
  2. ==================================================
  3.                    Anti-Ammospam
  4.             v1.0
  5.                 By HuiCheng Gaming
  6. ==================================================
  7.              W W W . H C Y X . O R G
  8. ==================================================
  9.  Notice: If you find any bugs, report it by
  10.  adding me 'hcyxsq' on skype.
  11.  This filterscript required SA-MP 0.3z+ and the lagcomp is on
  12. ==================================================
  13. */
  14. #include <a_samp>
  15. new TimesIn1Second[MAX_PLAYERS];
  16. new Timer[MAX_PLAYERS] = -1;
  17. public OnPlayerConnect(playerid)
  18. {
  19.     TimesIn1Second[playerid] = 0;
  20.     Timer[playerid] = SetTimerEx("CleanTimes",1000,true,"i",playerid);
  21.     return 1;
  22. }
  23.  
  24. public OnPlayerDisconnect(playerid, reason)
  25. {
  26.     TimesIn1Second[playerid] = 0;
  27.     KillTimer(Timer[playerid]);
  28.     Timer[playerid] = -1;
  29.     return 1;
  30. }
  31.  
  32. forward OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  33. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  34. {
  35.     if (weaponid != 38) TimesIn1Second[playerid] += 1;
  36.     return 1;
  37. }
  38.  
  39. forward CleanTimes(playerid);
  40. public CleanTimes(playerid)
  41. {
  42.     if (TimesIn1Second[playerid] != 0)
  43.     {
  44.         if (TimesIn1Second[playerid] >= 60)
  45.         {
  46.             new msg[256];
  47.             format(msg,sizeof(msg),"[Anti-Cheat]: [%d]%s has been kicked. Reason: Ammo-spam[%d/s]",playerid, GetPlayerNameEx(playerid), TimesIn1Second[playerid]);
  48.             SendClientMessageToAll(0xFF0000,msg);
  49.             print(msg);
  50.             SetTimerEx("KickEx",100,false,"i",playerid);
  51.         }
  52.         TimesIn1Second[playerid] = 0;
  53.     }
  54. }
  55.  
  56. forward KickEx(playerid);
  57. public KickEx(playerid)
  58. {
  59.     Kick(playerid);
  60.     return 1;
  61. }
  62. stock GetPlayerNameEx(playerid)
  63. {
  64.     new name[256];
  65.     GetPlayerName(playerid,name,sizeof(name));
  66.     return name;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment