should be able to whitelist nosteamers through DB simply
This commit is contained in:
parent
15c63febe2
commit
aebf588588
@ -10,6 +10,7 @@
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "nosteam bhop blocker",
|
||||
@ -22,14 +23,42 @@ public Plugin myinfo =
|
||||
bool bhop_restricted_nosteamer[MAXPLAYERS + 1];
|
||||
int buttons_old[MAXPLAYERS + 1];
|
||||
int flags_old[MAXPLAYERS + 1];
|
||||
Database g_dDatabase;
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
for (int i = 1; i <= MAXPLAYERS; i++)
|
||||
{
|
||||
if (IsValidClient(i))
|
||||
OnClientPostAdminCheck(i);
|
||||
}
|
||||
SQL_StartConnection();
|
||||
for (int i = 1; i <= MAXPLAYERS; i++)
|
||||
{
|
||||
if (IsValidClient(i))
|
||||
OnClientPostAdminCheck(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
SQL_StartConnection();
|
||||
}
|
||||
|
||||
public void SQL_StartConnection()
|
||||
{
|
||||
char error[512];
|
||||
if (SQL_CheckConfig("bhopnosteam"))
|
||||
g_dDatabase = SQL_Connect("bhopnosteam", true, error, sizeof(error));
|
||||
if (g_dDatabase == null)
|
||||
{
|
||||
PrintToChatAll("{green}[UNLOZE] {white}Error! Could not connect to MYSQL-DB!");
|
||||
}
|
||||
//create table
|
||||
char sQuery[512];
|
||||
Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS bhop_whitelist (`steam_auth` VARCHAR(254) NOT NULL, `name` VARCHAR(254) NOT NULL, PRIMARY KEY (`steam_auth`))");
|
||||
SQL_TQuery(g_dDatabase, DummyCallbackSimple, sQuery);
|
||||
}
|
||||
|
||||
public void DummyCallbackSimple(Handle hOwner, Handle hChild, const char[] err, DataPack pack1)
|
||||
{
|
||||
if (hOwner == null || hChild == null)
|
||||
LogError("Query error. (%s)", err);
|
||||
}
|
||||
|
||||
stock bool IsValidClient(int client)
|
||||
@ -48,44 +77,61 @@ public void OnClientDisconnect(int client)
|
||||
|
||||
public void OnClientPostAdminCheck(int client)
|
||||
{
|
||||
if (!IsFakeClient(client) && !IsClientSourceTV(client) && !PM_IsPlayerSteam(client))
|
||||
{
|
||||
bhop_restricted_nosteamer[client] = true;
|
||||
buttons_old[client] = 0;
|
||||
flags_old[client] = 0;
|
||||
}
|
||||
if (!IsFakeClient(client) && !IsClientSourceTV(client) && !PM_IsPlayerSteam(client))
|
||||
{
|
||||
bhop_restricted_nosteamer[client] = true;
|
||||
buttons_old[client] = 0;
|
||||
flags_old[client] = 0;
|
||||
if (g_dDatabase)
|
||||
{
|
||||
DBResultSet rs;
|
||||
char steam_auth[512];
|
||||
GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth));
|
||||
strcopy(steam_auth, sizeof(steam_auth), steam_auth[8]);
|
||||
char sQuery[512];
|
||||
Format(sQuery, sizeof(sQuery), "SELECT * FROM bhop_whitelist WHERE steam_auth = '%s'", steam_auth);
|
||||
if ((rs = SQL_Query(g_dDatabase, sQuery)) != null)
|
||||
{
|
||||
rs.FetchRow();
|
||||
if (rs.RowCount > 0)
|
||||
{
|
||||
bhop_restricted_nosteamer[client] = false;
|
||||
PrintToChat(client, "bhop unrestricted!");
|
||||
}
|
||||
}
|
||||
delete rs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype,
|
||||
int cmdnum, int tickcount, int seed, const int mouse[2])
|
||||
{
|
||||
if (!IsValidClient(client) || !IsPlayerAlive(client) || !bhop_restricted_nosteamer[client]) return;
|
||||
if (!(buttons_old[client] & IN_JUMP) && (!(buttons & IN_JUMP)))
|
||||
{
|
||||
flags_old[client] = GetEntityFlags(client);
|
||||
return;
|
||||
}
|
||||
if (buttons_old[client] & IN_JUMP)
|
||||
{
|
||||
if (!(buttons & IN_JUMP))
|
||||
if (GetEntityFlags(client) & FL_ONGROUND)
|
||||
buttons_old[client] = buttons;
|
||||
return;
|
||||
}
|
||||
if (!(flags_old[client] & FL_ONGROUND))
|
||||
return;
|
||||
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;
|
||||
if (!IsValidClient(client) || !IsPlayerAlive(client) || !bhop_restricted_nosteamer[client]) return;
|
||||
if (!(buttons_old[client] & IN_JUMP) && (!(buttons & IN_JUMP)))
|
||||
{
|
||||
flags_old[client] = GetEntityFlags(client);
|
||||
return;
|
||||
}
|
||||
if (buttons_old[client] & IN_JUMP)
|
||||
{
|
||||
if (!(buttons & IN_JUMP))
|
||||
if (GetEntityFlags(client) & FL_ONGROUND)
|
||||
buttons_old[client] = buttons;
|
||||
return;
|
||||
}
|
||||
if (!(flags_old[client] & FL_ONGROUND))
|
||||
return;
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user