replaced reading string with just checking boolean

This commit is contained in:
jenz 2023-01-04 16:36:05 +01:00
parent 0ba82cf400
commit bcd918a83f

View File

@ -37,6 +37,9 @@ Handle g_hTimer_bot_connect = null;
//cmdrun handle for gamedata txt
Handle g_hGetRunCmdPre;
//is botplayer
bool is_bot_player[MAXPLAYERS + 1];
public Plugin myinfo =
{
@ -82,7 +85,7 @@ public void OnPluginStart()
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && is_bot_player(i))
if (IsValidClient(i) && is_bot_player[i])
{
if (g_hGetRunCmdPre != INVALID_HANDLE)
DHookEntity(g_hGetRunCmdPre, false, i);
@ -111,7 +114,7 @@ public MRESReturn OnGetRunCmdPre(int entity, Handle hReturn)
//check here if fell off edge, if did change some boolean around tell it to OnPlayerRunCmd when still on ground there
if (IsValidClient(entity) && IsPlayerAlive(entity) && !(GetEntityFlags(entity) & FL_ONGROUND) && !has_to_jump_bots[entity]
&& is_bot_player(entity))
&& is_bot_player[entity])
{
has_to_jump_bots[entity] = 1;
}
@ -123,7 +126,7 @@ public MRESReturn OnGetRunCmdPre(int entity, Handle hReturn)
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2])
{
//we use info we just got from OnPlayerRunCmdPre to determine if to jump
if (!IsValidClient(client) || !IsPlayerAlive(client) || !is_bot_player(client)) return Plugin_Continue;
if (!IsValidClient(client) || !IsPlayerAlive(client) || !is_bot_player[client]) return Plugin_Continue;
if ((GetEntityMoveType(client) & MOVETYPE_LADDER))
{
GetEntPropVector(client, Prop_Send, "m_vecOrigin", coords_run_cmd[client]);
@ -177,7 +180,7 @@ public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
{
if (IsValidClient(i))
{
if (is_bot_player(i))
if (is_bot_player[i])
{
has_to_jump_bots[i] = 3;
}
@ -191,7 +194,7 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
{
if (IsValidClient(i))
{
if (is_bot_player(i))
if (is_bot_player[i])
{
target_friend[i] = -1;
target_enemy[i] = -1;
@ -228,30 +231,50 @@ public void cmd_talk_help(int port, int client, char[] info)
public bool is_autism_bot1(int client)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false);
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
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)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false);
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
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)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false);
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
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)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false);
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
{
is_bot_player[client] = true;
return true;
}
return false;
}
public Action cmd_botrtv(int client, int args)
@ -296,7 +319,7 @@ public Action cmd_talk(int client, int args)
PrintToChat(client, "Add a message to the command if autism bot is ingame and running on discord");
return Plugin_Handled;
}
if (is_bot_player(client))
if (is_bot_player[client])
{
return Plugin_Handled;
}
@ -423,11 +446,6 @@ public Action bot_check_connect(Handle timer, any data)
public bool is_bot_player(int client)
{
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client);
}
public Action recursive_pressing(Handle timer, any data)
{
bool found_valid_ct = false;
@ -439,7 +457,7 @@ public Action recursive_pressing(Handle timer, any data)
{
found_enemy = true;
}
if (!is_bot_player(client) && GetClientTeam(client) > 1)
if (!is_bot_player[client] && GetClientTeam(client) > 1)
{
found_valid_ct = true;
}
@ -447,13 +465,13 @@ public Action recursive_pressing(Handle timer, any data)
for (int client = 1; client <= MaxClients; client++)
{
if (!IsValidClient(client)) continue;
if (!found_valid_ct && is_bot_player(client))
if (!found_valid_ct && is_bot_player[client])
{
if (GetClientTeam(client) != 0)
ChangeClientTeam(client, 0);
continue;
}
if (is_bot_player(client))
if (is_bot_player[client])
{
if (GetClientTeam(client) == 1 || GetClientTeam(client) == 0)
{
@ -631,7 +649,7 @@ public Action recursive_pressing(Handle timer, any data)
for (int client = 1; client <= MaxClients; client++)
{
if (!IsValidClient(client)) continue;
if (!is_bot_player(client) && GetClientTeam(client) == 3 && IsPlayerAlive(client))
if (!is_bot_player[client] && GetClientTeam(client) == 3 && IsPlayerAlive(client))
{
found_valid_ct = true;
break;
@ -642,7 +660,7 @@ public Action recursive_pressing(Handle timer, any data)
for (int client = 1; client <= MaxClients; client++)
{
if (!IsValidClient(client)) continue;
if (is_bot_player(client) && GetClientTeam(client) == 3)
if (is_bot_player[client] && GetClientTeam(client) == 3)
{
ForcePlayerSuicide(client);
}
@ -917,7 +935,7 @@ public int GetClosestClient_option1(bool finding_friend, int client, int enemy)
dist_target = 8000000.0;
}
}
if (is_bot_player(i))
if (is_bot_player[i])
{
//just making sure bots have lowest priority
dist_target = 9000000.0;
@ -940,14 +958,21 @@ public float get_power_distance(int target_player, float [3]pos)
public void OnClientPostAdminCheck(int client)
{
is_bot_player[client] = false;
is_autism_bot1(client);
is_autism_bot2(client);
is_autism_bot3(client);
is_autism_bot4(client);
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && is_bot_player(i) && i != client)
if (!IsValidClient(i)) continue;
if (is_bot_player[i] && i != client)
{
target_friend_afk_counter[i][client] = 0;
}
}
if (is_bot_player(client))
if (is_bot_player[client])
{
if (g_hGetRunCmdPre != INVALID_HANDLE)
DHookEntity(g_hGetRunCmdPre, false, client);
@ -1037,11 +1062,12 @@ public void OnClientDisconnect(int client)
has_to_jump_bots[client] = 0;
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && is_bot_player(i) && i != client)
if (IsValidClient(i) && is_bot_player[i] && i != client)
{
target_friend_afk_counter[i][client] = 0;
}
}
is_bot_player[client] = false;
}
//Socket callback