update to checking when to block velocity

This commit is contained in:
Christian 2020-10-24 23:08:56 +02:00
parent b90fa47d7f
commit d6c563a717

View File

@ -20,7 +20,7 @@ public Plugin myinfo =
}; };
bool bhop_restricted_nosteamer[MAXPLAYERS + 1]; bool bhop_restricted_nosteamer[MAXPLAYERS + 1];
int client_check_count[MAXPLAYERS + 1]; int buttons_old[MAXPLAYERS + 1];
public void OnPluginStart() public void OnPluginStart()
{ {
@ -41,7 +41,7 @@ stock bool IsValidClient(int client)
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
bhop_restricted_nosteamer[client] = false; bhop_restricted_nosteamer[client] = false;
client_check_count[client] = 0; buttons_old[client] = 0;
} }
public void OnClientPostAdminCheck(int client) public void OnClientPostAdminCheck(int client)
@ -49,7 +49,7 @@ public void OnClientPostAdminCheck(int client)
if (!IsFakeClient(client) && !IsClientSourceTV(client) && !PM_IsPlayerSteam(client)) if (!IsFakeClient(client) && !IsClientSourceTV(client) && !PM_IsPlayerSteam(client))
{ {
bhop_restricted_nosteamer[client] = true; bhop_restricted_nosteamer[client] = true;
client_check_count[client] = 0; buttons_old[0] = 0;
} }
} }
@ -57,20 +57,27 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
int cmdnum, int tickcount, int seed, const int mouse[2]) int cmdnum, int tickcount, int seed, const int mouse[2])
{ {
if (!IsValidClient(client) || !IsPlayerAlive(client) || !bhop_restricted_nosteamer[client]) return; if (!IsValidClient(client) || !IsPlayerAlive(client) || !bhop_restricted_nosteamer[client]) return;
client_check_count[client]++; if (!(buttons_old[client] & IN_JUMP) && (!(buttons & IN_JUMP)))
int generic_cap = 50; return;
if (client_check_count[client] > generic_cap) if (buttons_old[client] & IN_JUMP)
{ {
client_check_count[client] = 0; if (!(buttons & IN_JUMP))
float vVel[3]; if (GetEntityFlags(client) & FL_ONGROUND)
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel); buttons_old[client] = buttons;
float fVelocity = SquareRoot(Pow(vVel[0], 2.0) + Pow(vVel[1], 2.0)); return;
float velocity_block[3];
velocity_block[0] = 0.0;
velocity_block[1] = 0.0;
velocity_block[2] = 0.0;
if (fVelocity > 320.0)
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, velocity_block);
} }
float vVel[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel);
float fVelocity = SquareRoot(Pow(vVel[0], 2.0) + Pow(vVel[1], 2.0));
float velocity_block[3];
velocity_block[0] = vel[0];
velocity_block[1] = vel[1];
velocity_block[2] = vel[2];
velocity_block[1] = 0.0;
if (fVelocity > 320.0)
{
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, velocity_block);
}
buttons_old[client] = buttons;
} }