Advertisement
eyal282

Anti Tank Bug ( /buy fheal servers only )

May 29th, 2017
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.67 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. public Plugin:myinfo =
  5. {
  6.     name = "Anti Tank Bug",
  7.     author = "Eyal282 ( FuckTheSchool )",
  8.     description = "Prevents Tank incapacitated bug that prevents tank from dying if he was healed some how ( this plugin probably only valid for servers with !buy )",
  9.     version = "1.0",
  10.     url = "<- URL ->"
  11. }
  12. public OnPluginStart()
  13. {
  14.     // The cvar to enable the plugin. 0 = Disabled. 1 = Enabled and kill the tank when he has 0 HP. Other values = Enabled and revive the tank that got 0 HP ( Best one because if the bug occurs, the tank did !buy heal and failed to go back but lost his points ).
  15.     CreateConVar("l4d2_anti_tank_bug", "2");
  16.    
  17.     // Hook the event for when a player gets incapacitated ( called for tank start of death as well )
  18.     HookEvent("player_incapacitated", Event_Incap, EventHookMode_Post);
  19. }
  20. public Action: Event_Incap(Handle hEvent, const char[] name, bool dontBroadcast)
  21. {
  22.     // Is the cvar enabled?
  23.     if(GetConVarInt(FindConVar("l4d2_anti_tank_bug")) == 0)
  24.         return Plugin_Continue;
  25.        
  26.     // Get the client ID of the incapacitated player.
  27.     new Tank = GetClientOfUserId(GetEventInt(hEvent, "userid"));
  28.    
  29.     // Is it a human player?
  30.     if(IsFakeClient(Tank))
  31.         return Plugin_Continue;
  32.    
  33.     // Is he an infected? Because the event only calls on tanks and survivors, we can already assume it's a tank.
  34.     if(GetClientTeam(Tank) != 3)
  35.         return Plugin_Continue;
  36.    
  37.     // 7.0 seconds are enough to determine if the tank is bugged or died properly.
  38.     CreateTimer(7.0, Check_Bug, GetClientUserId(Tank));
  39.    
  40.     return Plugin_Continue;
  41. }
  42.  
  43. public Action:Check_Bug(Handle Timer, int UserId)
  44. {
  45.     new Tank = GetClientOfUserId(UserId);
  46.    
  47.     // Is he connected?
  48.     if(!IsClientInGame(Tank))
  49.         return Plugin_Continue;
  50.    
  51.     // Is he alive or the bug never occured?
  52.     else if(!IsPlayerAlive(Tank))
  53.         return Plugin_Continue;
  54.    
  55.     // Is he an infected?
  56.     else if(GetClientTeam(Tank) != 3)
  57.         return Plugin_Continue;
  58.    
  59.     // Is he a tank? He had 0.5 seconds to do !buy hunter or something.
  60.     else if(GetEntProp(Tank, Prop_Send, "m_zombieClass") != 8)
  61.         return Plugin_Continue;
  62.    
  63.     // The console variable is set to 1. Killing the Tank.
  64.     if(GetConVarInt(FindConVar("l4d2_anti_tank_bug")) == 1)
  65.     {
  66.         // Kill the tank
  67.         ForcePlayerSuicide(Tank);
  68.        
  69.         // Tell the Tank that he died because he was bugged.
  70.         PrintToChat(Tank, "You were killed due to Tank bug immortality.");
  71.     }
  72.    
  73.     // The console variable is above 1 ( already checked if 0 ). Reviving the Tank.
  74.     else
  75.     {
  76.         new Float:AbsOrigin[3];
  77.         new Float:EyeAngles[3];
  78.        
  79.        
  80.         // Get the Tank's current location.
  81.         GetClientAbsOrigin(Tank, AbsOrigin);
  82.        
  83.         // Get the location the tank was looking at.
  84.         GetClientEyeAngles(Tank, EyeAngles);
  85.        
  86.         // Kill the tank
  87.         ForcePlayerSuicide(Tank);
  88.        
  89.        
  90.         // Check the current flags of the command z_spawn_old
  91.         new flags = GetCommandFlags("z_spawn_old");
  92.    
  93.         // Make the game think z_spawn_old is not a cheat command. The flags earlier are to maintain all current flags.
  94.         SetCommandFlags("z_spawn_old", flags & ~FCVAR_CHEAT);
  95.    
  96.         // Force the Tank to write z_spawn_old Tank which revives him as a tank.
  97.         FakeClientCommand(Tank, "z_spawn_old Tank");
  98.        
  99.         // Give the flags back to the command z_spawn_old ( if not done then everybody can do z_spawn_old which is bad ).
  100.         SetCommandFlags("z_spawn_old", flags);
  101.        
  102.         // Teleport the Tank to his old position with the same way he looked at.
  103.         TeleportEntity(Tank, AbsOrigin, EyeAngles, NULL_VECTOR);
  104.        
  105.         // Tell the Tank that he was "revived" to continue punching the survivors since he probably did !buy heal on himself.
  106.         PrintToChat(Tank, "You were revived due to Tank bug immortality.");
  107.     }
  108.        
  109.     return Plugin_Continue;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement