eyal282 icon

Anti Tank Bug ( /buy fheal servers only )

eyal282 | PRO | 05/29/17 07:21:32 PM UTC | 0 ⭐ | 7714 👁️ | Never ⏰ | []
Pawn |

3.67 KB

|

None

|

0 👍

/

0 👎

#include <sourcemod>
#include <sdktools>
 
public Plugin:myinfo = 
{
    name = "Anti Tank Bug",
    author = "Eyal282 ( FuckTheSchool )",
    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 )",
    version = "1.0",
    url = "<- URL ->"
}
public OnPluginStart()
{
    // 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 ).
    CreateConVar("l4d2_anti_tank_bug", "2");
    
    // Hook the event for when a player gets incapacitated ( called for tank start of death as well )
    HookEvent("player_incapacitated", Event_Incap, EventHookMode_Post);
}
public Action: Event_Incap(Handle hEvent, const char[] name, bool dontBroadcast)
{
    // Is the cvar enabled?
    if(GetConVarInt(FindConVar("l4d2_anti_tank_bug")) == 0)
        return Plugin_Continue;
        
    // Get the client ID of the incapacitated player.
    new Tank = GetClientOfUserId(GetEventInt(hEvent, "userid"));
    
    // Is it a human player?
    if(IsFakeClient(Tank))
        return Plugin_Continue;
    
    // Is he an infected? Because the event only calls on tanks and survivors, we can already assume it's a tank.
    if(GetClientTeam(Tank) != 3)
        return Plugin_Continue;
    
    // 7.0 seconds are enough to determine if the tank is bugged or died properly.
    CreateTimer(7.0, Check_Bug, GetClientUserId(Tank));
    
    return Plugin_Continue;
}
 
public Action:Check_Bug(Handle Timer, int UserId)
{
    new Tank = GetClientOfUserId(UserId);
    
    // Is he connected?
    if(!IsClientInGame(Tank))
        return Plugin_Continue;
    
    // Is he alive or the bug never occured?
    else if(!IsPlayerAlive(Tank))
        return Plugin_Continue;
    
    // Is he an infected? 
    else if(GetClientTeam(Tank) != 3)
        return Plugin_Continue;
    
    // Is he a tank? He had 0.5 seconds to do !buy hunter or something.
    else if(GetEntProp(Tank, Prop_Send, "m_zombieClass") != 8)
        return Plugin_Continue; 
    
    // The console variable is set to 1. Killing the Tank.
    if(GetConVarInt(FindConVar("l4d2_anti_tank_bug")) == 1)
    {
        // Kill the tank
        ForcePlayerSuicide(Tank);
        
        // Tell the Tank that he died because he was bugged.
        PrintToChat(Tank, "You were killed due to Tank bug immortality.");
    }
    
    // The console variable is above 1 ( already checked if 0 ). Reviving the Tank.
    else
    {
        new Float:AbsOrigin[3];
        new Float:EyeAngles[3];
        
        
        // Get the Tank's current location.
        GetClientAbsOrigin(Tank, AbsOrigin);
        
        // Get the location the tank was looking at.
        GetClientEyeAngles(Tank, EyeAngles);
        
        // Kill the tank
        ForcePlayerSuicide(Tank);
        
        
        // Check the current flags of the command z_spawn_old
        new flags = GetCommandFlags("z_spawn_old");
    
        // Make the game think z_spawn_old is not a cheat command. The flags earlier are to maintain all current flags.
        SetCommandFlags("z_spawn_old", flags & ~FCVAR_CHEAT);
    
        // Force the Tank to write z_spawn_old Tank which revives him as a tank.
        FakeClientCommand(Tank, "z_spawn_old Tank");
        
        // Give the flags back to the command z_spawn_old ( if not done then everybody can do z_spawn_old which is bad ).
        SetCommandFlags("z_spawn_old", flags);
        
        // Teleport the Tank to his old position with the same way he looked at.
        TeleportEntity(Tank, AbsOrigin, EyeAngles, NULL_VECTOR);
        
        // Tell the Tank that he was "revived" to continue punching the survivors since he probably did !buy heal on himself.
        PrintToChat(Tank, "You were revived due to Tank bug immortality.");
    }
        
    return Plugin_Continue;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎