replacing reliance on alias for connecting with steam native connect command. downloading maps through sourcemod saying the nextmap. should assure that bots are connected much faster from now on in almost all cases.

This commit is contained in:
jenz
2026-07-08 16:34:41 +02:00
parent 540cad9612
commit ca95f5a961
5 changed files with 263 additions and 1642 deletions
File diff suppressed because it is too large Load Diff
@@ -40,6 +40,9 @@ Handle global_socket;
//timer handle
Handle g_hTimer_pressing = null;
Handle g_hTimer_bot_connect = null;
Handle g_hTimer_bot_connect2 = null;
Handle g_hTimer_bot_connect3 = null;
Handle g_hTimer_bot_connect4 = null;
int specific_bot_player[MAXPLAYERS + 1];
@@ -64,7 +67,11 @@ public void OnPluginStart()
connect_socket();
chat_cooldown = false;
g_hTimer_bot_connect = CreateTimer(90.0, bot_check_connect, _, TIMER_REPEAT);
g_hTimer_bot_connect = CreateTimer(60.0, bot_check_connect, _, TIMER_REPEAT);
CreateTimer(5.0, activate_timer2);
CreateTimer(10.0, activate_timer3);
CreateTimer(15.0, activate_timer4);
g_hTimer_pressing = CreateTimer(2.0, check_team, _, TIMER_REPEAT);
target_client[1] = -1;
@@ -81,6 +88,24 @@ public void OnPluginStart()
}
}
public Action activate_timer2(Handle timer, any data)
{
g_hTimer_bot_connect2 = CreateTimer(60.0, bot_check_connect2, _, TIMER_REPEAT);
return Plugin_Continue;
}
public Action activate_timer3(Handle timer, any data)
{
g_hTimer_bot_connect3 = CreateTimer(60.0, bot_check_connect3, _, TIMER_REPEAT);
return Plugin_Continue;
}
public Action activate_timer4(Handle timer, any data)
{
g_hTimer_bot_connect4 = CreateTimer(60.0, bot_check_connect4, _, TIMER_REPEAT);
return Plugin_Continue;
}
public void OnPluginEnd()
{
if (g_hTimer_pressing != null)
@@ -91,29 +116,17 @@ public void OnPluginEnd()
{
delete g_hTimer_bot_connect;
}
}
public void OnMapEnd()
{
int autism_bot_counter = 0;
for (int i = 1; i <= MaxClients; i++)
if (g_hTimer_bot_connect2 != null)
{
if (IsValidClient(i) && specific_bot_player[i] != -1)
{
autism_bot_counter++;
}
delete g_hTimer_bot_connect2;
}
for (int i = 1; i <= MaxClients; i++)
if (g_hTimer_bot_connect3 != null)
{
if (autism_bot_counter <= 1)
{
break;
}
if (IsValidClient(i) && specific_bot_player[i] != -1)
{
KickClient(i);
autism_bot_counter--;
}
delete g_hTimer_bot_connect3;
}
if (g_hTimer_bot_connect4 != null)
{
delete g_hTimer_bot_connect4;
}
}
@@ -298,23 +311,166 @@ public void send_socket_msg(char[] query_msg, int len, int port)
public Action bot_check_connect(Handle timer, any data)
{
char nextmap[64];
if (GetNextMap(nextmap, sizeof(nextmap)))
{
char msg[generic_length];
Format(msg, sizeof(msg), "download map:%s", nextmap);
send_socket_msg(msg, strlen(msg), ports[0]);
}
//this is designed for being ran from several css servers
int client_count = GetClientCount(false);
char msg[generic_length];
int i_port = GetConVarInt(FindConVar("hostport"));
bool bot1_connected = false;
bool bot2_connected = false;
bool bot3_connected = false;
bool bot4_connected = false;
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i) && !IsFakeClient(i))
{
if (specific_bot_player[i] == 1)
bot1_connected = true;
}
if (i_port == server_ports[0])
{
int max_allowed_players = 55;
char current_map[128];
GetCurrentMap(current_map, sizeof(current_map));
if (client_count > max_allowed_players)
{
Format(msg, sizeof(msg), "connect to ze2");
send_socket_msg(msg, strlen(msg), ports[0]);
}
else if (client_count < max_allowed_players - 5)
{
Format(msg, sizeof(msg), "connect to ze");
if (!bot1_connected)
send_socket_msg(msg, strlen(msg), ports[0]);
}
}
else
{
//in case the bot is not connected to ze2 anymore make sure that is_bot_connected_to_ze2 is set to false again
Format(msg, sizeof(msg), "not connected to ze2");
if (!bot1_connected)
send_socket_msg(msg, strlen(msg), ports[0]);
}
return Plugin_Continue;
}
public Action bot_check_connect2(Handle timer, any data)
{
char nextmap[64];
if (GetNextMap(nextmap, sizeof(nextmap)))
{
char msg[generic_length];
Format(msg, sizeof(msg), "download map:%s", nextmap);
send_socket_msg(msg, strlen(msg), ports[0]);
}
//this is designed for being ran from several css servers
int client_count = GetClientCount(false);
char msg[generic_length];
int i_port = GetConVarInt(FindConVar("hostport"));
bool bot2_connected = false;
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i) && !IsFakeClient(i))
{
if (specific_bot_player[i] == 2)
bot2_connected = true;
}
if (i_port == server_ports[0])
{
int max_allowed_players = 55;
char current_map[128];
GetCurrentMap(current_map, sizeof(current_map));
if (client_count > max_allowed_players)
{
Format(msg, sizeof(msg), "connect to ze2");
send_socket_msg(msg, strlen(msg), ports[1]);
}
else if (client_count < max_allowed_players - 5)
{
Format(msg, sizeof(msg), "connect to ze");
if (!bot2_connected)
send_socket_msg(msg, strlen(msg), ports[1]);
}
}
else
{
//in case the bot is not connected to ze2 anymore make sure that is_bot_connected_to_ze2 is set to false again
Format(msg, sizeof(msg), "not connected to ze2");
if (!bot2_connected)
send_socket_msg(msg, strlen(msg), ports[1]);
}
return Plugin_Continue;
}
public Action bot_check_connect3(Handle timer, any data)
{
char nextmap[64];
if (GetNextMap(nextmap, sizeof(nextmap)))
{
char msg[generic_length];
Format(msg, sizeof(msg), "download map:%s", nextmap);
send_socket_msg(msg, strlen(msg), ports[0]);
}
//this is designed for being ran from several css servers
int client_count = GetClientCount(false);
char msg[generic_length];
int i_port = GetConVarInt(FindConVar("hostport"));
bool bot3_connected = false;
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i) && !IsFakeClient(i))
{
if (specific_bot_player[i] == 3)
bot3_connected = true;
}
if (i_port == server_ports[0])
{
int max_allowed_players = 55;
char current_map[128];
GetCurrentMap(current_map, sizeof(current_map));
if (client_count > max_allowed_players)
{
Format(msg, sizeof(msg), "connect to ze2");
send_socket_msg(msg, strlen(msg), ports[2]);
}
else if (client_count < max_allowed_players - 5)
{
Format(msg, sizeof(msg), "connect to ze");
if (!bot3_connected)
send_socket_msg(msg, strlen(msg), ports[2]);
}
}
else
{
//in case the bot is not connected to ze2 anymore make sure that is_bot_connected_to_ze2 is set to false again
Format(msg, sizeof(msg), "not connected to ze2");
if (!bot3_connected)
send_socket_msg(msg, strlen(msg), ports[2]);
}
return Plugin_Continue;
}
public Action bot_check_connect4(Handle timer, any data)
{
char nextmap[64];
if (GetNextMap(nextmap, sizeof(nextmap)))
{
char msg[generic_length];
Format(msg, sizeof(msg), "download map:%s", nextmap);
send_socket_msg(msg, strlen(msg), ports[0]);
}
//this is designed for being ran from several css servers
int client_count = GetClientCount(false);
char msg[generic_length];
int i_port = GetConVarInt(FindConVar("hostport"));
bool bot4_connected = false;
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i) && !IsFakeClient(i))
{
if (specific_bot_player[i] == 4)
bot4_connected = true;
}
@@ -327,20 +483,11 @@ public Action bot_check_connect(Handle timer, any data)
if (client_count > max_allowed_players)
{
Format(msg, sizeof(msg), "connect to ze2");
send_socket_msg(msg, strlen(msg), ports[0]);
send_socket_msg(msg, strlen(msg), ports[1]);
send_socket_msg(msg, strlen(msg), ports[2]);
send_socket_msg(msg, strlen(msg), ports[3]);
}
else if (client_count < max_allowed_players - 5)
{
Format(msg, sizeof(msg), "connect to ze");
if (!bot1_connected)
send_socket_msg(msg, strlen(msg), ports[0]);
if (!bot2_connected)
send_socket_msg(msg, strlen(msg), ports[1]);
if (!bot3_connected)
send_socket_msg(msg, strlen(msg), ports[2]);
if (!bot4_connected)
send_socket_msg(msg, strlen(msg), ports[3]);
}
@@ -349,12 +496,6 @@ public Action bot_check_connect(Handle timer, any data)
{
//in case the bot is not connected to ze2 anymore make sure that is_bot_connected_to_ze2 is set to false again
Format(msg, sizeof(msg), "not connected to ze2");
if (!bot1_connected)
send_socket_msg(msg, strlen(msg), ports[0]);
if (!bot2_connected)
send_socket_msg(msg, strlen(msg), ports[1]);
if (!bot3_connected)
send_socket_msg(msg, strlen(msg), ports[2]);
if (!bot4_connected)
send_socket_msg(msg, strlen(msg), ports[3]);
}