Guest User

CJ101

a guest
Mar 30th, 2010
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.12 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. /* ============================================================================
  4.                                 MetalAnticheat
  5.                                     by CJ101
  6. ==============================================================================*/
  7.  
  8. #define MAX_PING 1000
  9. #define COLOR_RED 0xFF0000AA
  10. #define BAD_NAMES_FILE "/metalac/badnames.txt" // The file where whe look for banned names.
  11.  
  12. new AC_Timer;
  13.  
  14. forward MetalAdminInit();
  15. public MetalAdminInit()
  16. {
  17.     AC_Timer = SetTimer("ACTimer",5000,1);
  18.     print("||=====|| MetalAnticheat by CJ101 Loaded ||=====||");
  19.     return 1;
  20. }
  21.  
  22. forward MetalAdminExit();
  23. public MetalAdminExit()
  24. {
  25.     KillTimer(AC_Timer);
  26.     print("||=====|| MetalAnticheat by CJ101 Unloaded ||=====||");
  27.     return 1;
  28. }
  29.  
  30. forward AddBadName(name[]);
  31. public AddBadName(name[])
  32. {
  33.     new str[100];
  34.     new File:file = fopen(BAD_NAMES_FILE,io_append);
  35.     format(str,100,"%s\r\n",name);
  36.     fwrite(file,str);
  37.     fclose(file);
  38.     return 1;
  39. }
  40.  
  41. public OnPlayerConnect(playerid)
  42. {
  43.     SendClientMessage(playerid,COLOR_RED,"This Server is running MetalAntiCheat. Cheat and you will be banned!");
  44.     new filestr[128];
  45.     new File:file = fopen(BAD_NAMES_FILE,io_read);
  46.     if (file)
  47.         {
  48.             while(fread(file,filestr,sizeof(filestr)))
  49.             {
  50.                 if (strfind(filestr,Name(playerid), true) != -1)
  51.                 {
  52.                     new string[128];
  53.                     format(string,sizeof string,"ANTICHEAT: %s was kicked as there name is blacklisted.",Name(playerid));
  54.                     SendClientMessageToAll(COLOR_RED,string);
  55.                     Kick(playerid);
  56.                     return 1;
  57.                 }
  58.             }
  59.         }
  60.     return 1;
  61. }
  62.  
  63. public OnPlayerDeath(playerid, killerid, reason)
  64. {
  65.     if(GetPlayerWeapon(killerid) == 38 || GetPlayerWeapon(killerid) == 36)
  66.     {
  67.         new string[128];
  68.         format(string,sizeof string,"ANTICHEAT: %s was auto-banned for killing with a banned weapon.",Name(killerid));
  69.         SendClientMessageToAll(COLOR_RED,string);
  70.         BanEx(killerid,"WeaponCheat");
  71.         AddBadName(Name(killerid));
  72.     }
  73.     return 1;
  74. }
  75.  
  76. public OnPlayerText(playerid, text[])
  77. {
  78.     if(GetPVarInt(playerid,"SpamMute") == 1) return 0;
  79.     SetPVarInt(playerid,"SpamMute",1);
  80.     SetTimerEx("Unmute",1500,false,"d",playerid);
  81.     return 1;
  82. }
  83.  
  84. forward SpamUnmute(playerid);
  85. public SpamUnmute(playerid)
  86. {
  87.     return SetPVarInt(playerid,"SpamMute",0);
  88. }
  89.  
  90.  
  91. forward ACTimer();
  92. public ACTimer()
  93. {
  94.     new wpn;
  95.     for(new i = 0; i < MAX_PLAYERS; i++)
  96.     {
  97.         if(IsPlayerConnected(i))
  98.         {
  99.             wpn = GetPlayerWeapon(i);
  100.             if(wpn == 38 || wpn == 36 || wpn == 44 || wpn == 45)
  101.             {
  102.                 new string[128];
  103.                 format(string,sizeof string,"ANTICHEAT: %s was banned for weapon cheating.",Name(i));
  104.                 SendClientMessageToAll(COLOR_RED,string);
  105.                 BanEx(i,"WeaponCheat");
  106.                 AddBadName(Name(i));
  107.             }
  108.            
  109.             if(GetPlayerMoney(i) - PlayerCash(i) > 55000)
  110.             {
  111.                 new string[128];
  112.                 format(string,sizeof string,"ANTICHEAT: %s was banned for money cheating.",Name(i));
  113.                 SendClientMessageToAll(COLOR_RED,string);
  114.                 BanEx(i,"Money");
  115.                 AddBadName(Name(i));
  116.             }
  117.            
  118.             if(GetPlayerSpecialAction(i) == 2)
  119.             {
  120.                 new string[128];
  121.                 format(string,sizeof string,"ANTICHEAT: %s was kicked for having a jetpack.",Name(i));
  122.                 SendClientMessageToAll(COLOR_RED,string);
  123.                 BanEx(i,"Jetpack");
  124.                 AddBadName(Name(i));
  125.             }
  126.            
  127.             if(GetPlayerPing(i) > MAX_PING)
  128.             {
  129.                 new string[128];
  130.                 format(string,sizeof string,"ANTICHEAT: %s was kicked for having high ping.",Name(i));
  131.                 SendClientMessageToAll(COLOR_RED,string);
  132.                 Kick(i);
  133.             }
  134.         }
  135.     }
  136. }
  137.  
  138. stock GivePlayerCash(playerid,amount)
  139. {
  140.     SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")+amount);
  141.     GivePlayerMoney(playerid,amount);
  142. }
  143.  
  144. stock PlayerCash(playerid)
  145. {
  146.     return GetPVarInt(playerid,"Money");
  147. }
  148.  
  149. stock TakePlayerCash(playerid,amount)
  150. {
  151.     SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")-amount);
  152.     GivePlayerMoney(playerid,-amount);
  153. }
  154.  
  155. stock ResetPlayerCash(playerid)
  156. {
  157.     SetPVarInt(playerid,"Money",0);
  158.     ResetPlayerMoney(playerid);
  159. }
  160.  
  161. stock Name(playerid)
  162. {
  163.     new name[24];
  164.     GetPlayerName(playerid,name,sizeof name);
  165.     return name;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment