AntiHH.pwn 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. Server sided HP/Armour for 0.3d
  3. Created by Scott - scottreed36@gmail.com
  4. DO NOT DISTRIBUTE, LET'S KEEP UPPER HAND ON HACKERS BY KEEPING THIS METHOD SECRET
  5. Works because in 0.3d you can set everyone on server to same team, and they won't receive normal damage client side
  6. However, OnPlayerDamage is still called, so can use SetHP to create server sided armour/HP
  7. Another perk: Car parking and heliblading is now impossible, they just get stuck under car!
  8. */
  9. #include <a_samp>
  10. #include <streamer>
  11. #define SetPlayerHealthEx(%0,%1) (pHealth[%0]=(%1); & SetPlayerHealth(%0,%1))
  12. #define SetPlayerArmourEx(%0,%1) (pArmour[%0]=(%1); & SetPlayerArmour(%0,%1))
  13. new Float:pHealth[MAX_PLAYERS];
  14. new Float:pArmour[MAX_PLAYERS];
  15. /*
  16. enum VendMachinesEnum
  17. {
  18. Float:PosX,
  19. Float:PosY,
  20. Float:PosZ
  21. }
  22. new VendMachines[75][VendMachinesEnum] = {
  23. {-14.70,1175.36,18.95},
  24. {201.02,-107.62,0.90},
  25. {662.43,-552.16,15.71},
  26. {-76.03,1227.99,19.13},
  27. {1154.73,-1460.89,15.16},
  28. {1277.84,372.52,18.95},
  29. {1398.84,2222.61,10.42},
  30. {1520.15,1055.27,10.00},
  31. {1634.11,-2237.53,12.89},
  32. {1659.46,1722.86,10.22},
  33. {1729.79,-1943.05,12.95},
  34. {1789.21,-1369.27,15.16},
  35. {1928.73,-1772.45,12.95},
  36. {2060.12,-1897.64,12.93},
  37. {2085.77,2071.36,10.45},
  38. {2139.52,-1161.48,23.36},
  39. {2153.23,-1016.15,62.23},
  40. {2271.73,-76.46,25.96},
  41. {2319.99,2532.85,10.22},
  42. {2325.98,-1645.13,14.21},
  43. {2352.18,-1357.16,23.77},
  44. {2480.86,-1959.27,12.96},
  45. {2503.14,1243.70,10.22},
  46. {-253.74,2597.95,62.24},
  47. {-253.74,2599.76,62.24},
  48. {2647.70,1129.66,10.22},
  49. {2845.73,1295.05,10.79},
  50. {-862.83,1536.61,21.98},
  51. {-1350.12,492.29,10.59},
  52. {-1350.12,493.86,10.59},
  53. {-1455.12,2591.66,55.23},
  54. {-1980.79,142.66,27.07},
  55. {-2005.65,-490.05,34.73},
  56. {-2011.14,-398.34,34.73},
  57. {-2034.46,-490.05,34.73},
  58. {-2039.85,-398.34,34.73},
  59. {-2063.27,-490.05,34.73},
  60. {-2068.56,-398.34,34.73},
  61. {-2092.09,-490.05,34.73},
  62. {-2097.27,-398.34,34.73},
  63. {-2118.62,-422.41,34.73},
  64. {-2118.97,-423.65,34.73},
  65. {-2229.19,286.41,34.70},
  66. {-2420.18,985.95,44.30},
  67. {-2420.22,984.58,44.30},
  68. {2155.84,1607.88,1000.06},
  69. {2155.91,1606.77,1000.05},
  70. {2202.45,1617.01,1000.06},
  71. {2209.24,1621.21,1000.06},
  72. {2209.91,1607.20,1000.05},
  73. {2222.20,1606.77,1000.05},
  74. {2222.37,1602.64,1000.06},
  75. {2225.20,-1153.42,1025.91},
  76. {-15.10,-140.23,1003.63},
  77. {-16.12,-91.64,1003.63},
  78. {-16.53,-140.30,1003.63},
  79. {-17.55,-91.71,1003.63},
  80. {-19.04,-57.84,1003.63},
  81. {-32.45,-186.70,1003.63},
  82. {-33.88,-186.77,1003.63},
  83. {330.68,178.50,1020.07},
  84. {331.92,178.50,1020.07},
  85. {-35.73,-140.23,1003.63},
  86. {350.91,206.09,1008.48},
  87. {-36.15,-57.88,1003.63},
  88. {361.56,158.62,1008.48},
  89. {371.59,178.45,1020.07},
  90. {373.83,-178.14,1000.73},
  91. {374.89,188.98,1008.48},
  92. {379.04,-178.88,1000.73},
  93. {495.97,-24.32,1000.73},
  94. {500.56,-1.37,1000.73},
  95. {501.83,-1.43,1000.73},
  96. 2576.70,-1284.43,1061.09}
  97. };
  98. */
  99. public OnPlayerConnect(playerid)
  100. {
  101. RemoveBuildingForPlayer(playerid, 955, 0, 0, 0, 25000); // Remove all sprunk machines
  102. RemoveBuildingForPlayer(playerid, 956, 0, 0, 0, 25000); // Remove all vending machines
  103. }
  104. public OnPlayerSpawn(playerid)
  105. {
  106. SetPlayerTeam(playerid, 4);
  107. }
  108. public OnPlayerText(playerid, text[]) // THIS IS FOR DEBUGGING
  109. {
  110. SetPlayerHealthEx(playerid, 100);
  111. SetPlayerArmourEx(playerid, 100);
  112. return 1;
  113. }
  114. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
  115. {
  116. if(weaponid == 50)
  117. {
  118. SetPlayerArmourEx(playerid, pArmour[playerid]);
  119. SetPlayerHealthEx(playerid, pHealth[playerid]);
  120. return 1;
  121. }
  122. else if(weaponid == 54 || weaponid == 37 || weaponid == 51 || weaponid == 53)
  123. {
  124. SetPlayerArmourEx(playerid, pArmour[playerid]);
  125. SetPlayerHealthEx(playerid, pHealth[playerid]);
  126. }
  127. new Float:armour, Float:HP;
  128. new string[128];
  129. GetPlayerArmour(playerid, armour);
  130. GetPlayerHealth(playerid, HP);
  131. if(HP <= 0) return 1; // let them die if they are dead!
  132. if((pArmour[playerid] > 0) && (((pArmour[playerid] > armour) && ((pArmour[playerid]-armour) > 1)) || ((pArmour[playerid] < armour) && ((armour-pArmour[playerid]) > 1))))
  133. {
  134. format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) is possibly armour hacking", GetPlayerNameEx(playerid), playerid);
  135. // ABroadCast( COLOR_YELLOW, string, 2 );
  136. format(string, sizeof(string), "{AA3333}Expected Armour: {AA3333}%f | {AA3333}Armour: {AA3333}%f]", pArmour[playerid], armour);
  137. // ABroadCast( COLOR_YELLOW, string, 2 );
  138. }
  139. if((pHealth[playerid] > 0) && (((pHealth[playerid] > HP) && ((pHealth[playerid]-HP) > 1)) || ((pHealth[playerid] < HP) && ((HP-pHealth[playerid]) > 1))))
  140. {
  141. //Kick(playerid); (automatic kick?)
  142. format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) is possibly health hacking", GetPlayerNameEx(playerid), playerid);
  143. SendClientMessageToAll(0xFFFFFFAA, string);
  144. //ABroadCast( COLOR_YELLOW, string, 2 );
  145. format(string, sizeof(string), "{AA3333}Expected HP: {AA3333}%f | {AA3333}HP: {AA3333}%f]", pHealth[playerid], HP);
  146. SendClientMessageToAll(0xFFFFFFAA, string);
  147. //ABroadCast( COLOR_YELLOW, string, 2 );
  148. }
  149. if(armour > 0)
  150. {
  151. if(armour >= amount)
  152. {
  153. //Don't set double damage for drowning, splat, fire
  154. if(weaponid == 54 || weaponid == 53 || weaponid == 37) pArmour[playerid] = (armour-amount);
  155. else SetPlayerArmourEx(playerid, armour-amount);
  156. }
  157. else
  158. {
  159. if(weaponid == 54 || weaponid == 53 || weaponid == 37)
  160. {
  161. pArmour[playerid] = 0;
  162. pHealth[playerid] = (HP-(amount-armour));
  163. }
  164. else
  165. {
  166. SetPlayerArmourEx(playerid, 0);
  167. SetPlayerHealthEx(playerid, HP-(amount-armour));
  168. }
  169. }
  170. }
  171. else
  172. {
  173. if(weaponid == 54 || weaponid == 53 || weaponid == 37) pHealth[playerid] = (HP-amount);
  174. else SetPlayerHealthEx(playerid, HP-amount);
  175. }
  176. return 1;
  177. }
  178. stock GetPlayerNameEx(playerid) {
  179. new
  180. sz_playerName[MAX_PLAYER_NAME];
  181. GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  182. return sz_playerName;
  183. }