Advertisement
Hanger

Anticheat: Spawn Protection - No Timers

Jul 26th, 2014
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.30 KB | None | 0 0
  1.  /*
  2.  --*                                *
  3.  --*   @Author:      Hanger         *
  4.  --*   @Version:     1.2            *
  5.  --*                                *
  6.  */
  7.  
  8.  #if defined _asp_included
  9.     #endinput
  10. #endif 
  11. #define _asp_included
  12.  
  13. new
  14.     bool:   PLAYER_SPAWNED  [MAX_PLAYERS],
  15.             SPAWN_TIME      [MAX_PLAYERS];
  16.  
  17. /* Spawn protection time in seconds */
  18. #define     ANTI_SPAWN_KILL_TIME    10
  19.  
  20. /* Maximum serverside health - in case you have 99.9 anticheat */
  21. #define     MAX_HEALTH              100.00
  22.  
  23. /* Health to set when player spawns if falling from a high place, player will be killed regardless of this amount */
  24. #define     SPAWN_HEALTH            999.99
  25.    
  26. public OnPlayerSpawn(playerid)
  27. {
  28.     PLAYER_SPAWNED  [playerid]  =   true;
  29.     SPAWN_TIME      [playerid]  =   gettime();
  30.    
  31.     #if defined asp_OnPlayerSpawn
  32.         return asp_OnPlayerSpawn(playerid);
  33.     #else
  34.         return 1;
  35.     #endif
  36. }
  37. #if defined _ALS_OnPlayerSpawn
  38.     #undef OnPlayerSpawn
  39. #else
  40.     #define _ALS_OnPlayerSpawn
  41. #endif
  42. #define OnPlayerSpawn asp_OnPlayerSpawn
  43. #if defined asp_OnPlayerSpawn
  44.     forward asp_OnPlayerSpawn(playerid);
  45. #endif
  46.  
  47.  
  48. public OnPlayerDeath(playerid, killerid, reason)
  49. {
  50.     PLAYER_SPAWNED  [playerid]  =   false;
  51.     SPAWN_TIME      [playerid]  =   0;
  52.    
  53.     SetPlayerHealth(playerid, SPAWN_HEALTH);
  54.  
  55.     #if defined asp_OnPlayerDeath
  56.         return asp_OnPlayerDeath(playerid, killerid, reason);
  57.     #else
  58.         return 1;
  59.     #endif
  60. }
  61. #if defined _ALS_OnPlayerDeath
  62.     #undef OnPlayerDeath
  63. #else
  64.     #define _ALS_OnPlayerDeath
  65. #endif
  66. #define OnPlayerDeath asp_OnPlayerDeath
  67. #if defined asp_OnPlayerDeath
  68.     forward asp_OnPlayerDeath(playerid, killerid, reason);
  69. #endif
  70.  
  71. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  72. {
  73.     if(PLAYER_SPAWNED[playerid])
  74.     {
  75.         new
  76.             currenttime = gettime();
  77.         currenttime = (currenttime - SPAWN_TIME[playerid]);
  78.         if(currenttime < ANTI_SPAWN_KILL_TIME)
  79.         {
  80.             SetPlayerHealth(playerid, SPAWN_HEALTH);
  81.         }
  82.         else
  83.         {
  84.             new
  85.                 Float:  Health;
  86.             GetPlayerHealth(playerid, Health);
  87.             if(Health > MAX_HEALTH)
  88.             {
  89.                 SetPlayerHealth(playerid, floatsub(MAX_HEALTH, amount));
  90.             }
  91.         }
  92.     }
  93.    
  94.     #if defined asp_OnPlayerTakeDamage
  95.         return asp_OnPlayerTakeDamage(playerid, issuerid, amount, weaponid, bodypart);
  96.     #else
  97.         return 1;
  98.     #endif
  99. }
  100. #if defined _ALS_OnPlayerTakeDamage
  101.     #undef OnPlayerTakeDamage
  102. #else
  103.     #define _ALS_OnPlayerTakeDamage
  104. #endif
  105. #define OnPlayerTakeDamage asp_OnPlayerTakeDamage
  106. #if defined asp_OnPlayerTakeDamage
  107.     forward asp_OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart);
  108. #endif
  109.  
  110. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  111. {
  112.     if(hittype == BULLET_HIT_TYPE_PLAYER)
  113.     {
  114.         if(PLAYER_SPAWNED[hitid])
  115.         {
  116.             new
  117.                 currenttime = gettime();
  118.                
  119.             currenttime = (currenttime - SPAWN_TIME[hitid]);
  120.             if(currenttime < ANTI_SPAWN_KILL_TIME)
  121.             {
  122.                 return 0;
  123.             }
  124.         }
  125.     }
  126.  
  127.     #if defined asp_OnPlayerWeaponShot
  128.         return asp_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, fX, fY, fZ);
  129.     #else
  130.         return 1;
  131.     #endif
  132. }
  133. #if defined _ALS_OnPlayerWeaponShot
  134.     #undef OnPlayerWeaponShot
  135. #else
  136.     #define _ALS_OnPlayerWeaponShot
  137. #endif
  138. #define OnPlayerWeaponShot asp_OnPlayerWeaponShot
  139. #if defined asp_OnPlayerWeaponShot
  140.     forward asp_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  141. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement