AnticheatFS.pwn 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*
  2. Anticheat
  3. - Anticheat Script written by CalgonX / FreddoX.
  4. This filterscript will detect weapon hacking.
  5. */
  6. #include <a_samp>
  7. #include <foreach>
  8. #define LIGHTRED 0xFF8080FF
  9. #define WEAPON_HACKER_WARNINGS 3
  10. forward AntiWeaponSpawnTimer();
  11. forward GivePlayerValidWeapon( playerid, WeaponID, Ammo );
  12. forward ExecuteHackerAction( playerid );
  13. enum TimersEnum
  14. {
  15. WeaponCheck,
  16. }
  17. new Timers[ TimersEnum ];
  18. public OnFilterScriptInit()
  19. {
  20. print( "Anticheat loaded." );
  21. Timers[ WeaponCheck ] = SetTimer( "AntiWeaponSpawnTimer", true, 1000 );
  22. return 1;
  23. }
  24. public OnFilterScriptExit()
  25. {
  26. KillTimer( Timers[ WeaponCheck ] );
  27. print( "Anticheat unloaded." );
  28. return 1;
  29. }
  30. public GivePlayerValidWeapon( playerid, WeaponID, Ammo )
  31. {
  32. switch( WeaponID )
  33. {
  34. case 0, 1:
  35. {
  36. SetPVarInt( playerid, "WeaponSlot0", WeaponID );
  37. GivePlayerWeapon( playerid, WeaponID, Ammo );
  38. }
  39. case 2, 3, 4, 5, 6, 7, 8, 9:
  40. {
  41. SetPVarInt( playerid, "WeaponSlot1", WeaponID );
  42. GivePlayerWeapon( playerid, WeaponID, Ammo );
  43. }
  44. case 22, 23, 24:
  45. {
  46. SetPVarInt( playerid, "WeaponSlot2", WeaponID );
  47. GivePlayerWeapon( playerid, WeaponID, Ammo );
  48. }
  49. case 25, 26, 27:
  50. {
  51. SetPVarInt( playerid, "WeaponSlot3", WeaponID );
  52. GivePlayerWeapon( playerid, WeaponID, Ammo );
  53. }
  54. case 28, 29, 32:
  55. {
  56. SetPVarInt( playerid, "WeaponSlot4", WeaponID );
  57. GivePlayerWeapon( playerid, WeaponID, Ammo );
  58. }
  59. case 30, 31:
  60. {
  61. SetPVarInt( playerid, "WeaponSlot5", WeaponID );
  62. GivePlayerWeapon( playerid, WeaponID, Ammo );
  63. }
  64. case 33, 34:
  65. {
  66. SetPVarInt( playerid, "WeaponSlot6", WeaponID );
  67. GivePlayerWeapon( playerid, WeaponID, Ammo );
  68. }
  69. case 35, 36, 37, 38:
  70. {
  71. SetPVarInt( playerid, "WeaponSlot7", WeaponID );
  72. GivePlayerWeapon( playerid, WeaponID, Ammo );
  73. }
  74. case 16, 17, 18, 39:
  75. {
  76. SetPVarInt( playerid, "WeaponSlot8", WeaponID );
  77. GivePlayerWeapon( playerid, WeaponID, Ammo );
  78. }
  79. case 41, 42, 43:
  80. {
  81. SetPVarInt( playerid, "WeaponSlot9", WeaponID );
  82. GivePlayerWeapon( playerid, WeaponID, Ammo );
  83. }
  84. case 10, 11, 12, 13, 14, 15:
  85. {
  86. SetPVarInt( playerid, "WeaponSlot10", WeaponID );
  87. GivePlayerWeapon( playerid, WeaponID, Ammo );
  88. }
  89. case 44, 45, 46:
  90. {
  91. SetPVarInt( playerid, "WeaponSlot11", WeaponID );
  92. GivePlayerWeapon( playerid, WeaponID, Ammo );
  93. }
  94. }
  95. return 1;
  96. }
  97. public ExecuteHackerAction( playerid )
  98. {
  99. new HackWarnings = GetPVarInt( playerid, "HackWarnings" ), NameStr[ MAX_PLAYER_NAME ], String[ 128 ], WeaponName[ 128 ];
  100. SetPVarInt( playerid, "HackWarnings", HackWarnings+1 );
  101. GetWeaponName( GetPlayerWeapon( playerid ), WeaponName, sizeof( WeaponName ) );
  102. GetPlayerName( playerid, NameStr, sizeof( NameStr ) );
  103. format( String, sizeof( String ), "WARNING: %s may possibly be weapon-hacking (%s) [%d].", NameStr, WeaponName, HackWarnings-WEAPON_HACKER_WARNINGS );
  104. CallRemoteFunction( "SendAdminMessage", "ds", LIGHTRED, String );
  105. if( HackWarnings >= WEAPON_HACKER_WARNINGS )
  106. {
  107. format( String, sizeof( String ), "AdmCmd: %s has been banned, reason: Weapon Hacking (%s).", NameStr, WeaponName );
  108. SendClientMessageToAll( LIGHTRED, String );
  109. Ban( playerid );
  110. }
  111. return 1;
  112. }
  113. public AntiWeaponSpawnTimer()
  114. {
  115. new PlayerWeapon;
  116. foreach(Player, i)
  117. {
  118. PlayerWeapon = GetPlayerWeapon( i );
  119. if( PlayerWeapon >= 1)
  120. {
  121. switch( PlayerWeapon )
  122. {
  123. case 0, 1:
  124. {
  125. if( GetPVarInt( i, "WeaponSlot0" ) != PlayerWeapon )
  126. {
  127. ExecuteHackerAction( i );
  128. }
  129. }
  130. case 2, 3, 4, 5, 6, 7, 8, 9:
  131. {
  132. if( GetPVarInt( i, "WeaponSlot1" ) != PlayerWeapon )
  133. {
  134. ExecuteHackerAction( i );
  135. }
  136. }
  137. case 22, 23, 24:
  138. {
  139. if( GetPVarInt( i, "WeaponSlot2" ) != PlayerWeapon )
  140. {
  141. ExecuteHackerAction( i );
  142. }
  143. }
  144. case 25, 26, 27:
  145. {
  146. if( GetPVarInt( i, "WeaponSlot3" ) != PlayerWeapon )
  147. {
  148. ExecuteHackerAction( i );
  149. }
  150. }
  151. case 28, 29, 32:
  152. {
  153. if( GetPVarInt( i, "WeaponSlot4" ) != PlayerWeapon )
  154. {
  155. ExecuteHackerAction( i );
  156. }
  157. }
  158. case 30, 31:
  159. {
  160. if( GetPVarInt( i, "WeaponSlot5" ) != PlayerWeapon )
  161. {
  162. ExecuteHackerAction( i );
  163. }
  164. }
  165. case 33, 34:
  166. {
  167. if( GetPVarInt( i, "WeaponSlot6" ) != PlayerWeapon )
  168. {
  169. ExecuteHackerAction( i );
  170. }
  171. }
  172. case 35, 36, 37, 38:
  173. {
  174. if( GetPVarInt( i, "WeaponSlot7" ) != PlayerWeapon )
  175. {
  176. ExecuteHackerAction( i );
  177. }
  178. }
  179. case 16, 17, 18, 39:
  180. {
  181. if( GetPVarInt( i, "WeaponSlot8" ) != PlayerWeapon )
  182. {
  183. ExecuteHackerAction( i );
  184. }
  185. }
  186. case 41, 42, 43:
  187. {
  188. if( GetPVarInt( i, "WeaponSlot9" ) != PlayerWeapon )
  189. {
  190. ExecuteHackerAction( i );
  191. }
  192. }
  193. case 10, 11, 12, 13, 14, 15:
  194. {
  195. if( GetPVarInt( i, "WeaponSlot10" ) != PlayerWeapon )
  196. {
  197. ExecuteHackerAction( i );
  198. }
  199. }
  200. case 44, 45, 46:
  201. {
  202. if( GetPVarInt( i, "WeaponSlot11" ) != PlayerWeapon )
  203. {
  204. ExecuteHackerAction( i );
  205. }
  206. }
  207. }
  208. }
  209. }
  210. return 1;
  211. }