AntiHH.pwn 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. #undef MAX_PLAYERS
  12. #define MAX_PLAYERS 600
  13. #define SetPlayerHealthEx(%0,%1) pHealth[%0] = (%1); SetPlayerHealth(%0,%1)
  14. #define SetPlayerArmourEx(%0,%1) pArmour[%0] = (%1); SetPlayerArmour(%0,%1)
  15. new Float:pHealth[MAX_PLAYERS];
  16. new Float:pArmour[MAX_PLAYERS];
  17. enum VendMachinesEnum
  18. {
  19. ModelID,
  20. Float:PosX,
  21. Float:PosY,
  22. Float:PosZ,
  23. Float:RotZ
  24. }
  25. new VendMachines[20][VendMachinesEnum] = {
  26. };
  27. public OnPlayerConnect(playerid)
  28. {
  29. RemoveBuildingForPlayer(playerid, 955, 0, 0, 0, 25000); // Remove all sprunk machines
  30. RemoveBuildingForPlayer(playerid, 956, 0, 0, 0, 25000); // Remove all vending machines
  31. }
  32. public OnPlayerSpawn(playerid)
  33. {
  34. SetPlayerTeam(playerid, 4);
  35. }
  36. public OnPlayerText(playerid, text[]) // THIS IS FOR DEBUGGING
  37. {
  38. SetPlayerHealthEx(playerid, 100);
  39. SetPlayerArmourEx(playerid, 100);
  40. return 1;
  41. }
  42. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
  43. {
  44. new count = GetTickCount();
  45. if(weaponid == 50)
  46. {
  47. SetPlayerArmourEx(playerid, pArmour[playerid]);
  48. SetPlayerHealthEx(playerid, pHealth[playerid]);
  49. return 1;
  50. }
  51. else if(weaponid == 54 || weaponid == 37 || weaponid == 51 || weaponid == 53)
  52. {
  53. SetPlayerArmourEx(playerid, pArmour[playerid]);
  54. SetPlayerHealthEx(playerid, pHealth[playerid]);
  55. }
  56. new Float:armour, Float:HP;
  57. new string[128]; // DEBUG STRING
  58. GetPlayerArmour(playerid, armour);
  59. GetPlayerHealth(playerid, HP);
  60. if(HP <= 0) return 1; // let them die if they are dead!
  61. if((pArmour[playerid] > 0) && (((pArmour[playerid] > armour) && ((pArmour[playerid]-armour) > 1)) || ((pArmour[playerid] < armour) && ((armour-pArmour[playerid]) > 1))))
  62. {
  63. //Kick(playerid); (automatic kick?)
  64. format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) is possibly armour hacking", GetPlayerNameEx(playerid), playerid);
  65. SendClientMessageToAll(0xFFFFFFAA, string);
  66. //ABroadCast( COLOR_YELLOW, string, 2 );
  67. format(string, sizeof(string), "{AA3333}Expected Armour: {AA3333}%f | {AA3333}Armour: {AA3333}%f]", pArmour[playerid], armour);
  68. SendClientMessageToAll(0xFFFFFFAA, string);
  69. //ABroadCast( COLOR_YELLOW, string, 2 );
  70. }
  71. if((pHealth[playerid] > 0) && (((pHealth[playerid] > HP) && ((pHealth[playerid]-HP) > 1)) || ((pHealth[playerid] < HP) && ((HP-pHealth[playerid]) > 1))))
  72. {
  73. //Kick(playerid); (automatic kick?)
  74. format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) is possibly health hacking", GetPlayerNameEx(playerid), playerid);
  75. SendClientMessageToAll(0xFFFFFFAA, string);
  76. //ABroadCast( COLOR_YELLOW, string, 2 );
  77. format(string, sizeof(string), "{AA3333}Expected HP: {AA3333}%f | {AA3333}HP: {AA3333}%f]", pHealth[playerid], HP);
  78. SendClientMessageToAll(0xFFFFFFAA, string);
  79. //ABroadCast( COLOR_YELLOW, string, 2 );
  80. }
  81. if(armour > 0)
  82. {
  83. if(armour >= amount)
  84. {
  85. //Don't set double damage for drowning, splat, fire
  86. if(weaponid == 54 || weaponid == 53 || weaponid == 37) pArmour[playerid] = (armour-amount);
  87. else SetPlayerArmourEx(playerid, armour-amount);
  88. }
  89. else
  90. {
  91. if(weaponid == 54 || weaponid == 53 || weaponid == 37)
  92. {
  93. pArmour[playerid] = 0;
  94. pHealth[playerid] = (HP-(amount-armour));
  95. }
  96. else
  97. {
  98. SetPlayerArmourEx(playerid, 0);
  99. SetPlayerHealthEx(playerid, HP-(amount-armour));
  100. }
  101. }
  102. }
  103. else
  104. {
  105. if(weaponid == 54 || weaponid == 53 || weaponid == 37) pHealth[playerid] = (HP-amount);
  106. else SetPlayerHealthEx(playerid, HP-amount);
  107. }
  108. format(string, sizeof(string), "%d shot by %d with %f damage using WEP %d | %d", playerid, issuerid, amount, weaponid, GetTickCount() - count); //DEBUG
  109. SendClientMessageToAll(0xFFFFFFAA, string); //DEBUG
  110. return 1;
  111. }
  112. stock GetPlayerNameEx(playerid) {
  113. new
  114. sz_playerName[MAX_PLAYER_NAME],
  115. i_pos;
  116. GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  117. while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
  118. return sz_playerName;
  119. }