fixed lag when server full by moving the getauthid stuff to only happening on connects, also ensured bots should not run around with tmp's anymore after a surf

This commit is contained in:
jenz 2023-06-25 12:07:05 +02:00
parent cc96bb56a4
commit 3c9470d64c

View File

@ -1,4 +1,6 @@
#include <sourcemod> #include <sourcemod>
#include <cstrike>
#include <smlib>
#include <sdktools> #include <sdktools>
#include <sdkhooks> #include <sdkhooks>
#include <botmimic> #include <botmimic>
@ -12,6 +14,12 @@ public Plugin myinfo =
version = "1.1", version = "1.1",
url = "www.unloze.com" url = "www.unloze.com"
}; };
//is botplayer
bool is_bot_player[MAXPLAYERS + 1];
bool is_player_jenz[MAXPLAYERS + 1];
float bot_finished_surf_coords[MAXPLAYERS + 1][3]; float bot_finished_surf_coords[MAXPLAYERS + 1][3];
char map_coorindates[65][256]; char map_coorindates[65][256];
char map_recordname[65][256]; char map_recordname[65][256];
@ -81,11 +89,16 @@ stock bool IsValidClient(int client)
public void OnClientPostAdminCheck(int client) public void OnClientPostAdminCheck(int client)
{ {
is_bot_player[client] = false;
is_player_jenz[client] = false;
is_bot_player_call(client);
reset_bot_finished_surf(client); reset_bot_finished_surf(client);
} }
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
is_bot_player[client] = false;
is_player_jenz[client] = false;
reset_bot_finished_surf(client); reset_bot_finished_surf(client);
} }
@ -101,6 +114,10 @@ public void reset_client(int client)
if (BotMimic_IsPlayerMimicing(client)) if (BotMimic_IsPlayerMimicing(client))
{ {
BotMimic_StopPlayerMimic(client); BotMimic_StopPlayerMimic(client);
if (GetClientTeam(client) == CS_TEAM_T)
{
Client_switch_to_knife(client);
}
} }
} }
@ -128,13 +145,15 @@ public int BotMimic_OnPlayerMimicLoops(int client)
public Action update_mimic_coords(Handle timer, any data) public Action update_mimic_coords(Handle timer, any data)
{ {
for (int i = 1; i <= MaxClients; i++) for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i) && is_bot_player(i)) {
if (IsValidClient(i) && is_bot_player[i])
{ {
if (bot_finished_surf_coords[i][0] != 0.0) if (bot_finished_surf_coords[i][0] != 0.0)
{ {
GetEntPropVector(i, Prop_Send, "m_vecOrigin", bot_finished_surf_coords[i]); GetEntPropVector(i, Prop_Send, "m_vecOrigin", bot_finished_surf_coords[i]);
} }
} }
}
if (round_switch) if (round_switch)
{ {
return Plugin_Continue; return Plugin_Continue;
@ -153,7 +172,7 @@ public Action update_mimic_coords(Handle timer, any data)
coords[2] = StringToFloat(char_coord[2]); coords[2] = StringToFloat(char_coord[2]);
for (int j = 1; j <= MaxClients; j++) for (int j = 1; j <= MaxClients; j++)
{ {
if (IsValidClient(j) && bot_finished_surf_coords[j][0] == 0.0 && is_bot_player(j)) if (IsValidClient(j) && bot_finished_surf_coords[j][0] == 0.0 && is_bot_player[j])
{ {
float distance = get_power_distance(j, coords); float distance = get_power_distance(j, coords);
if (distance < 225.0) if (distance < 225.0)
@ -322,48 +341,85 @@ public void SQL_FinishedQuery_creating_tables(Database db, DBResultSet results,
} }
} }
public bool is_bot_player(int client) public void is_bot_player_call(int client)
{ {
bool debug_b = false; bool debug_b = false;
if (debug_b && is_jenz(client)) if (debug_b && is_jenz(client))
{ {
return true; is_player_jenz[client] = true;
} }
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client); //change to true for debugging on dev is_autism_bot1(client);
is_autism_bot2(client);
is_autism_bot3(client);
is_autism_bot4(client);
} }
public bool is_jenz(int client) public bool is_jenz(int client)
{ {
char auth[50]; char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:69566635]", auth, false) || StrEqual("STEAM_0:1:34783317", auth, false); if(StrEqual("[U:1:69566635]", auth, false) || StrEqual("STEAM_0:1:34783317", auth, false))
{
return true;
}
return false;
} }
public bool is_autism_bot1(int client) public bool is_autism_bot1(int client)
{ {
char auth[50]; char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false); if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
{
is_bot_player[client] = true;
return true;
}
return false;
} }
public bool is_autism_bot2(int client) public bool is_autism_bot2(int client)
{ {
char auth[50]; char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false); if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
{
is_bot_player[client] = true;
return true;
}
return false;
} }
public bool is_autism_bot3(int client) public bool is_autism_bot3(int client)
{ {
char auth[50]; char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false); if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
{
is_bot_player[client] = true;
return true;
}
return false;
} }
public bool is_autism_bot4(int client) public bool is_autism_bot4(int client)
{ {
char auth[50]; char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false); if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
{
is_bot_player[client] = true;
return true;
}
return false;
} }
stock Client_switch_to_knife(int client)
{
//2 is always knife
int weapon = GetPlayerWeaponSlot(client, 2);
if (Weapon_IsValid(weapon)) {
Client_SetActiveWeapon(client, weapon);
}
}