|
Senior Member
Join Date: Dec 2017
Location: Thy old times.
|
01-15-2020
, 22:35
Re: [L4D2] Charger Idle Bug Fix Request!
|
#9
|
Quote:
Originally Posted by dustinandband
Use khan's version, which also blocks some additional exploits done by idl'ing.
The other stuff is self explanatory, but preventing idle while reloading prevents the grenade launcher glitch (where survivors can insta incap someone by going idle immediately after firing a grenade).
Spoiler
PHP Code:
#include <sourcemod>
#include <sdktools>
public Plugin:myinfo =
{
name = "Prevent IDLE glitch",
author = "khan",
description = "Stop players from using idle to cheat",
version = "1.0"
};
#define IS_VALID_CLIENT(%1) (%1 > 0 && %1 <= MaxClients)
#define IS_INFECTED(%1) (GetClientTeam(%1) == 3)
#define IS_VALID_INGAME(%1) (IS_VALID_CLIENT(%1) && IsClientInGame(%1))
#define IS_VALID_INFECTED(%1) (IS_VALID_INGAME(%1) && IS_INFECTED(%1))
#define ZC_TANK 8
enum ISSUE
{
TankHit,
Defib
};
new iNextValidIDLE[MAXPLAYERS]; // Next game instant to allow player to go idle
new ISSUE:iReason[MAXPLAYERS]; // Reason for not allow idle
public OnPluginStart()
{
HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre);
HookEvent("defibrillator_used", Event_DefibUsed, EventHookMode_Pre);
AddCommandListener(GoAwayFromKeyboard, "go_away_from_keyboard");
}
public Action:GoAwayFromKeyboard(client, const String:command[], argc)
{
if (!AllowIDLE(client))
{
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action:Event_DefibUsed(Handle:hEvent, const String:name[], bool:dontBroadcast)
{
new subject = GetClientOfUserId(GetEventInt(hEvent, "subject"));
iNextValidIDLE[subject] = GetTime() + 5; // Disable IDLE for 5 seconds when defibbed
iReason[subject] = ISSUE:Defib;
}
public Action:Event_PlayerHurt(Handle:hEvent, const String:name[], bool:dontBroadcast)
{
new player = GetClientOfUserId(GetEventInt(hEvent, "userid"));
new attacker = GetClientOfUserId(GetEventInt(hEvent, "attacker"));
if (!IS_VALID_INFECTED(attacker)) return Plugin_Continue;
new zClass = GetEntProp(attacker, Prop_Send, "m_zombieClass");
switch (zClass)
{
case ZC_TANK:
{
iNextValidIDLE[player] = GetTime() + 3; // Disable idle for 3 seconds if hit by tank
iReason[player] = ISSUE:TankHit;
}
}
return Plugin_Continue;
}
bool:AllowIDLE(client)
{
// Are they boomed? Don't allow player to go idle for 13 seconds after boomed - about the time when they can see clearly again
new Float:vomitStart = GetEntPropFloat(client, Prop_Send, "m_vomitStart")
if ( (vomitStart + 13) > GetGameTime())
{
PrintToChat(client, "\x05Not allowed to go idle when boomed");
return false;
}
// Are they reloading?
new weapon = GetPlayerWeaponSlot(client, 0);
if (weapon != -1)
{
if( GetEntProp(weapon, Prop_Data, "m_bInReload") )
{
PrintToChat(client, "\x05Not allowed to go idle when reloading");
return false;
}
}
// Are they being charged?
new m_pummelAttacker = GetEntPropEnt(client, Prop_Send, "m_pummelAttacker");
if (m_pummelAttacker != -1)
{
PrintToChat(client, "\x05Not allowed to go idle when being charged");
return false;
}
// Are they stumbling?
new Float:vec[3];
GetEntPropVector(client, Prop_Send, "m_staggerStart", vec);
if (vec[0] != 0.000000 || vec[1] != 0.000000 || vec[2] != 0.000000)
{
PrintToChat(client, "\x05Not allowed to go idle when stumbled");
return false;
}
// Verify that they didn't just get hit by a tank or defibbed
if (iNextValidIDLE[client] > GetTime())
{
if (iReason[client] == ISSUE:TankHit)
{
PrintToChat(client, "\x05Not allowed to go idle after tank hit");
}
else if (iReason[client] == ISSUE:Defib)
{
PrintToChat(client, "\x05Not allowed to go idle after being defibbed");
}
else
{
PrintToChat(client, "\x05Not allowed to go idle");
}
return false;
}
// Allow idle
return true;
}
|
This doesn't cover going idle after throwing a molly at a witch (so she loses the attacker-target and burns to death), right?
|
|
|
|