Matteo987

sAwh V1.3

Feb 24th, 2018
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.44 KB | None | 0 0
  1. /*
  2. * Anti Weapons Hack
  3. * By Sunehildeep
  4. * V1.3
  5. */
  6.  
  7. #if defined ACWEAPS_Included
  8. #endinput
  9. #endif
  10.  
  11. #define ACWEAPS_Included
  12. #include <a_samp>
  13.  
  14. #if !defined FILTERSCRIPT
  15. /*
  16. Only one function:
  17. - OnPlayerWeaponsHack(playerid, weaponid, ammo, type)
  18.  
  19. Types:
  20.  
  21. 1 - Weapons Hack
  22. 2 - Ammo Hack
  23. 3 - Desynced
  24. 4 - Ammo freeze aka no reload aka infinite ammo
  25. */
  26.  
  27. #define AWH_IsPlayerPaused(%1) GetTickCount() > (AWH_WeaponsInfo[%1][AWH_Tick]+2000)
  28.  
  29. enum awhInfo
  30. {
  31. AWH_Weapons[53],
  32. AWH_Slot[13],
  33. AWH_Ammo[53],
  34. bool:AWH_Immune,
  35. AWH_Tick,
  36. AWH_AmmoTick,
  37. AWH_LastAmmo[53],
  38. AWH_LastWeapon,
  39. bool:AWH_Spawned,
  40. AWH_Timer
  41. };
  42.  
  43. static AWH_WeaponsInfo[MAX_PLAYERS][awhInfo];
  44.  
  45. #if defined OnPlayerConnectWeapons
  46. forward OnPlayerConnectWeapons(playerid);
  47. #endif
  48.  
  49. #if defined OnPlayerDeathWeapons
  50. forward OnPlayerDeathWeapons(playerid, killerid, reason);
  51. #endif
  52.  
  53. #if defined OnPlayerDisconnectWeapons
  54. forward OnPlayerDisconnectWeapons(playerid, reason);
  55. #endif
  56.  
  57. #if defined OnPlayerWeaponsHack
  58. forward OnPlayerWeaponsHack(playerid, weaponid, ammo, type);
  59. #endif
  60.  
  61. #if defined OnPlayerUpdateWeapons
  62. forward OnPlayerUpdateWeapons(playerid);
  63. #endif
  64.  
  65. #if defined OnPlayerSpawnWeapons
  66. forward OnPlayerSpawnWeapons(playerid);
  67. #endif
  68.  
  69. #if defined OnPlayerWeaponShotWeapons
  70. forward OnPlayerWeaponShotWeapons(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  71. #endif
  72.  
  73. #if defined OnPlayerEnterVehicleWeapons
  74. forward OnPlayerEnterVehicleWeapons(playerid, vehicleid, ispassenger);
  75. #endif
  76.  
  77. #if defined OnPlayerExitVehicleWeapons
  78. forward OnPlayerExitVehicleWeapons(playerid, vehicleid);
  79. #endif
  80.  
  81. forward AWH_ResetImmune(playerid);
  82. public AWH_ResetImmune(playerid)
  83. {
  84. AWH_WeaponsInfo[playerid][AWH_Immune] = false;
  85. return 1;
  86. }
  87.  
  88. forward CheckWeapons(playerid);
  89. public CheckWeapons(playerid)
  90. {
  91. if(AWH_IsPlayerPaused(playerid) || !AWH_WeaponsInfo[playerid][AWH_Spawned] || GetPlayerState(playerid) != 1) return 1;
  92. if(!AWH_WeaponsInfo[playerid][AWH_Immune])
  93. {
  94. new awh_id = GetPlayerWeapon(playerid);
  95. switch(awh_id)
  96. {
  97. case 46, 40, 0: return 0;
  98. }
  99.  
  100. new awh_slot = GetWeaponSlot(awh_id);
  101. new awh_ammo = GetPlayerAmmo(playerid);
  102.  
  103. if(AWH_WeaponsInfo[playerid][AWH_Weapons][awh_id] == 0)
  104. {
  105. #if defined OnPlayerWeaponsHack
  106. OnPlayerWeaponsHack(playerid, awh_id, awh_ammo, 1);
  107. #endif
  108. }
  109. else if((AWH_WeaponsInfo[playerid][AWH_Ammo][awh_id]-awh_ammo) > 50)
  110. {
  111. #if defined OnPlayerWeaponsHack
  112. OnPlayerWeaponsHack(playerid, awh_id, awh_ammo, 2);
  113. #endif
  114. }
  115. else if((AWH_WeaponsInfo[playerid][AWH_Ammo][awh_id]-awh_ammo) < 50)
  116. {
  117. AWH_WeaponsInfo[playerid][AWH_Ammo][awh_id] = awh_ammo;
  118. }
  119. else if(AWH_WeaponsInfo[playerid][AWH_Slot][awh_slot] != awh_id)
  120. {
  121. #if defined OnPlayerWeaponsHack
  122. OnPlayerWeaponsHack(playerid, awh_id, awh_ammo, 3);
  123. #endif
  124. }
  125. }
  126. return 1;
  127. }
  128.  
  129. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  130. {
  131. if(AWH_WeaponsInfo[playerid][AWH_AmmoTick] < gettime())
  132. {
  133. AWH_WeaponsInfo[playerid][AWH_AmmoTick] = gettime()+5;
  134.  
  135. if(AWH_WeaponsInfo[playerid][AWH_LastWeapon] == weaponid && AWH_WeaponsInfo[playerid][AWH_LastAmmo][weaponid] != 0 && AWH_WeaponsInfo[playerid][AWH_LastAmmo][weaponid] == GetPlayerAmmo(playerid))
  136. {
  137. #if defined OnPlayerWeaponsHack
  138. OnPlayerWeaponsHack(playerid, weaponid, GetPlayerAmmo(playerid), 4);
  139. #endif
  140. }
  141. AWH_WeaponsInfo[playerid][AWH_LastWeapon] = weaponid;
  142. AWH_WeaponsInfo[playerid][AWH_LastAmmo][weaponid] = GetPlayerAmmo(playerid);
  143. }
  144. if(AWH_WeaponsInfo[playerid][AWH_Ammo][weaponid] <= 0)
  145. {
  146. AWH_WeaponsInfo[playerid][AWH_Ammo][weaponid] = 0;
  147. AWH_WeaponsInfo[playerid][AWH_Slot][GetWeaponSlot(weaponid)] = 0;
  148. AWH_WeaponsInfo[playerid][AWH_Weapons][weaponid] = 0;
  149. }
  150. else AWH_WeaponsInfo[playerid][AWH_Ammo][weaponid]--;
  151. #if defined OnPlayerWeaponShotWeapons
  152. return OnPlayerWeaponShotWeapons(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  153. #else
  154. return 1;
  155. #endif
  156. }
  157.  
  158. public OnPlayerDisconnect(playerid, reason)
  159. {
  160. KillTimer(AWH_WeaponsInfo[playerid][AWH_Timer]);
  161. #if defined OnPlayerDisconnectWeapons
  162. return OnPlayerDisconnectWeapons(playerid, reason);
  163. #else
  164. return 1;
  165. #endif
  166. }
  167.  
  168. public OnPlayerUpdate(playerid)
  169. {
  170. AWH_WeaponsInfo[playerid][AWH_Tick] = GetTickCount();
  171. #if defined OnPlayerUpdateWeapons
  172. return OnPlayerUpdateWeapons(playerid);
  173. #else
  174. return 1;
  175. #endif
  176. }
  177.  
  178. public OnPlayerDeath(playerid, killerid, reason)
  179. {
  180. AWH_ResetVariables(playerid);
  181. #if defined OnPlayerDeathWeapons
  182. return OnPlayerDeathWeapons(playerid, killerid, reason);
  183. #else
  184. return 1;
  185. #endif
  186. }
  187.  
  188. public OnPlayerConnect(playerid)
  189. {
  190. AWH_ResetVariables(playerid);
  191. AWH_WeaponsInfo[playerid][AWH_Timer] = SetTimerEx("CheckWeapons", 1000, true, "i", playerid);
  192. #if defined OnPlayerConnectWeapons
  193. return OnPlayerConnectWeapons(playerid);
  194. #else
  195. return 1;
  196. #endif
  197. }
  198.  
  199. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  200. {
  201. if(!AWH_WeaponsInfo[playerid][AWH_Immune]) SetTimerEx("AWH_ResetImmune", 3000, false, "i", playerid);
  202. AWH_WeaponsInfo[playerid][AWH_Immune] = true;
  203. #if defined OnPlayerEnterVehicleWeapons
  204. return OnPlayerEnterVehicleWeapons(playerid, vehicleid, ispassenger);
  205. #else
  206. return 1;
  207. #endif
  208. }
  209.  
  210. public OnPlayerExitVehicle(playerid, vehicleid)
  211. {
  212. if(!AWH_WeaponsInfo[playerid][AWH_Immune]) SetTimerEx("AWH_ResetImmune", 3000, false, "i", playerid);
  213. AWH_WeaponsInfo[playerid][AWH_Immune] = true;
  214. #if defined OnPlayerExitVehicleWeapons
  215. return OnPlayerExitVehicleWeapons(playerid, vehicleid);
  216. #else
  217. return 1;
  218. #endif
  219. }
  220.  
  221. public OnPlayerSpawn(playerid)
  222. {
  223. AWH_WeaponsInfo[playerid][AWH_Spawned] = true;
  224. AWH_WeaponsInfo[playerid][AWH_AmmoTick] = GetTickCount();
  225. #if defined OnPlayerSpawnWeapons
  226. return OnPlayerSpawnWeapons(playerid);
  227. #else
  228. return 1;
  229. #endif
  230. }
  231.  
  232. static AWH_ResetVariables(playerid)
  233. {
  234. for(new i = 0; i < 13; i++) AWH_WeaponsInfo[playerid][AWH_Ammo][i] = AWH_WeaponsInfo[playerid][AWH_Slot][i] = AWH_WeaponsInfo[playerid][AWH_LastAmmo][i] = 0;
  235. for(new i = 0; i < 53; i++) AWH_WeaponsInfo[playerid][AWH_Weapons][i] = 0;
  236. AWH_WeaponsInfo[playerid][AWH_LastWeapon] = 0;
  237. AWH_WeaponsInfo[playerid][AWH_Immune] = AWH_WeaponsInfo[playerid][AWH_Spawned] = false;
  238. }
  239.  
  240. stock AWH_GivePlayerWeapon(playerid, weapon, ammo)
  241. {
  242. AWH_WeaponsInfo[playerid][AWH_Weapons][weapon] = 1;
  243. AWH_WeaponsInfo[playerid][AWH_Slot][GetWeaponSlot(weapon)] = weapon;
  244. AWH_WeaponsInfo[playerid][AWH_Ammo][weapon] = ammo;
  245. if(!AWH_WeaponsInfo[playerid][AWH_Immune]) SetTimerEx("AWH_ResetImmune", 3000, false, "i", playerid);
  246. AWH_WeaponsInfo[playerid][AWH_Immune] = true;
  247. AWH_WeaponsInfo[playerid][AWH_LastAmmo][weapon] = ammo;
  248. return GivePlayerWeapon(playerid, weapon, ammo);
  249. }
  250.  
  251. stock AWH_ResetPlayerWeapons(playerid)
  252. {
  253. for(new i = 0; i < 53; i++)
  254. {
  255. AWH_WeaponsInfo[playerid][AWH_Weapons][i] = AWH_WeaponsInfo[playerid][AWH_Ammo][i] = AWH_WeaponsInfo[playerid][AWH_LastAmmo][i] = 0;
  256. if( i < 13) AWH_WeaponsInfo[playerid][AWH_Slot][i] = 0;
  257. }
  258. if(!AWH_WeaponsInfo[playerid][AWH_Immune]) SetTimerEx("AWH_ResetImmune", 3000, false, "i", playerid);
  259. AWH_WeaponsInfo[playerid][AWH_Immune] = true;
  260.  
  261. return ResetPlayerWeapons(playerid);
  262. }
  263.  
  264. static GetWeaponSlot(weaponid)
  265. {
  266. switch(weaponid)
  267. {
  268. case 0..1: return 0;
  269. case 2..9: return 1;
  270. case 22..24: return 2;
  271. case 25..27: return 3;
  272. case 28..29: return 4;
  273. case 32: return 4;
  274. case 30..31: return 5;
  275. case 33..34: return 6;
  276. case 35..38: return 7;
  277. case 16..18: return 8;
  278. case 39: return 8;
  279. case 41..43: return 9;
  280. case 10..15: return 10;
  281. case 44..46: return 11;
  282. case 40: return 12;
  283. }
  284. return 0; //if its a wrong weapon still return 0 to avoid crashes (if wrong slot ids crash JUST in case).
  285. }
  286.  
  287. stock AWH_SetPlayerAmmo(playerid, weapon, ammo)
  288. {
  289. AWH_WeaponsInfo[playerid][AWH_Ammo][weapon] = ammo;
  290. if(!AWH_WeaponsInfo[playerid][AWH_Immune]) SetTimerEx("AWH_ResetImmune", 3000, false, "i", playerid);
  291. AWH_WeaponsInfo[playerid][AWH_Immune] = true;
  292. return SetPlayerAmmo(playerid, weapon, ammo);
  293. }
  294.  
  295. stock AWH_SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
  296. {
  297. AWH_WeaponsInfo[playerid][AWH_Weapons][weapon1] = 1;
  298. AWH_WeaponsInfo[playerid][AWH_Weapons][weapon2] = 1;
  299. AWH_WeaponsInfo[playerid][AWH_Weapons][weapon3] = 1;
  300.  
  301. AWH_WeaponsInfo[playerid][AWH_Slot][GetWeaponSlot(weapon1)] = weapon1;
  302. AWH_WeaponsInfo[playerid][AWH_Slot][GetWeaponSlot(weapon2)] = weapon2;
  303. AWH_WeaponsInfo[playerid][AWH_Slot][GetWeaponSlot(weapon3)] = weapon3;
  304.  
  305. AWH_WeaponsInfo[playerid][AWH_Ammo][weapon1] = weapon1_ammo;
  306. AWH_WeaponsInfo[playerid][AWH_Ammo][weapon2] = weapon2_ammo;
  307. AWH_WeaponsInfo[playerid][AWH_Ammo][weapon3] = weapon3_ammo;
  308.  
  309. return SetSpawnInfo(playerid, team, skin, x, y, z, rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
  310. }
  311.  
  312. #if defined _ALS_OnPlayerExitVehicle
  313. #undef OnPlayerExitVehicle
  314. #else
  315. #define _ALS_OnPlayerExitVehicle
  316. #endif
  317.  
  318. #define OnPlayerExitVehicle OnPlayerExitVehicleWeapons
  319.  
  320. #if defined _ALS_OnPlayerEnterVehicle
  321. #undef OnPlayerEnterVehicle
  322. #else
  323. #define _ALS_OnPlayerEnterVehicle
  324. #endif
  325.  
  326. #define OnPlayerEnterVehicle OnPlayerEnterVehicleWeapons
  327.  
  328. #if defined _ALS_OnPlayerWeaponShot
  329. #undef OnPlayerWeaponShot
  330. #else
  331. #define _ALS_OnPlayerWeaponShot
  332. #endif
  333.  
  334. #define OnPlayerWeaponShot OnPlayerWeaponShotWeapons
  335.  
  336. #if defined _ALS_OnPlayerSpawn
  337. #undef OnPlayerSpawn
  338. #else
  339. #define _ALS_OnPlayerSpawn
  340. #endif
  341.  
  342. #define OnPlayerSpawn OnPlayerSpawnWeapons
  343.  
  344. #if defined _ALS_OnPlayerUpdate
  345. #undef OnPlayerUpdate
  346. #else
  347. #define _ALS_OnPlayerUpdate
  348. #endif
  349.  
  350. #define OnPlayerUpdate OnPlayerUpdateWeapons
  351.  
  352. #if defined _ALS_SetPlayerAmmo
  353. #undef SetPlayerAmmo
  354. #else
  355. #define _ALS_SetPlayerAmmo
  356. #endif
  357.  
  358. #define SetPlayerAmmo AWH_SetPlayerAmmo
  359.  
  360. #if defined _ALS_ResetPlayerWeapons
  361. #undef ResetPlayerWeapons
  362. #else
  363. #define _ALS_ResetPlayerWeapons
  364. #endif
  365.  
  366. #define ResetPlayerWeapons AWH_ResetPlayerWeapons
  367.  
  368. #if defined _ALS_GivePlayerWeapon
  369. #undef GivePlayerWeapon
  370. #else
  371. #define _ALS_GivePlayerWeapon
  372. #endif
  373. #define GivePlayerWeapon AWH_GivePlayerWeapon
  374.  
  375. #if defined _ALS_OnPlayerConnect
  376. #undef OnPlayerConnect
  377. #else
  378. #define _ALS_OnPlayerConnect
  379. #endif
  380.  
  381. #define OnPlayerConnect OnPlayerConnectWeapons
  382.  
  383. #if defined _ALS_OnPlayerDeath
  384. #undef OnPlayerDeath
  385. #else
  386. #define _ALS_OnPlayerDeath
  387. #endif
  388.  
  389. #define OnPlayerDeath OnPlayerDeathWeapons
  390.  
  391. #if defined _ALS_OnPlayerDisconnect
  392. #undef OnPlayerDisconnect
  393. #else
  394. #define _ALS_OnPlayerDisconnect
  395. #endif
  396.  
  397. #define OnPlayerDisconnect OnPlayerDisconnectWeapons
  398.  
  399. #if defined _ALS_SetSpawnInfo
  400. #undef SetSpawnInfo
  401. #else
  402. #define _ALS_SetSpawnInfo
  403. #endif
  404. #define SetSpawnInfo AWH_SetSpawnInfo
  405.  
  406. #else
  407.  
  408. stock AWH_ResetPlayerWeaponsFS(playerid)
  409. return CallLocalFunction("AWH_ResetPlayerWeapons", "i", playerid);
  410.  
  411. stock AWH_GivePlayerWeaponFS(playerid, weapon, ammo)
  412. return CallLocalFunction("AWH_GivePlayerWeapon","iii", playerid, weapon, ammo);
  413.  
  414. stock AWH_SetPlayerAmmoFS(playerid, weapon, ammo)
  415. return CallLocalFunction("AWH_SetPlayerAmmo", "iii", playerid, weapon, ammo);
  416.  
  417. stock AWH_SetSpawnInfoFS(playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
  418. return CallLocalFunction("AWH_SetSpawnInfo", "iiiffffiiiiii", playerid, team, skin, x, y, z, rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
  419.  
  420. #if defined _ALS_SetPlayerAmmo
  421. #undef SetPlayerAmmo
  422. #else
  423. #define _ALS_SetPlayerAmmo
  424. #endif
  425.  
  426. #define SetPlayerAmmo AWH_SetPlayerAmmoFS
  427.  
  428. #if defined _ALS_ResetPlayerWeapons
  429. #undef ResetPlayerWeapons
  430. #else
  431. #define _ALS_ResetPlayerWeapons
  432. #endif
  433.  
  434. #define ResetPlayerWeapons AWH_ResetPlayerWeaponsFS
  435.  
  436. #if defined _ALS_GivePlayerWeapon
  437. #undef GivePlayerWeapon
  438. #else
  439. #define _ALS_GivePlayerWeapon
  440. #endif
  441. #define GivePlayerWeapon AWH_GivePlayerWeaponFS
  442.  
  443. #if defined _ALS_SetSpawnInfo
  444. #undef SetSpawnInfo
  445. #else
  446. #define _ALS_SetSpawnInfo
  447. #endif
  448. #define SetSpawnInfo AWH_SetSpawnInfoFS
  449.  
  450. #endif
Add Comment
Please, Sign In to add comment