updated config and should allow the bots to join gg and zr when ze is full now
This commit is contained in:
parent
075f6f28b5
commit
65db51602f
@ -2,5 +2,8 @@
|
||||
"udp_port": 48470,
|
||||
"chat_external_port": 48475,
|
||||
"steam_port": 29074,
|
||||
"server_ip_port": "135.125.188.157:27015"
|
||||
"server_ip_port_ze": "135.125.188.157:27015",
|
||||
"server_ip_port_gg": "135.125.188.157:27021",
|
||||
"server_ip_port_zr": "135.125.188.157:27016"
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ def restart_sdl_and_steam():
|
||||
|
||||
subprocess.getoutput([f"screen -d -m -S XTERM x2goruncommand {x2go_session_display} {x2go_session_pid} {x2go_session_id} {x2go_session_command}"])
|
||||
print('reached .bashrc executing steam and variables')
|
||||
time.sleep(360)
|
||||
time.sleep(60)
|
||||
#we sleep here to wait for .bashrc to launch steam. It takes some minutes
|
||||
|
||||
def launch_css_process():
|
||||
@ -120,10 +120,16 @@ def launch_css_process():
|
||||
subprocess.getoutput([f"/home/{whoami}/.steam/debian-installation/steam.sh -applaunch 240 -textmode -novid -nosound -noipx -nojoy -noshaderapi -port {data_ports['steam_port']}"])
|
||||
print('finished starting game')
|
||||
|
||||
def bot_connect_ze():
|
||||
def bot_connect(server, connected_to_other):
|
||||
#use whatever ip you want here to connect with
|
||||
strdev = "connect 135.125.188.157:27019/test132;"
|
||||
str1 = f"connect {data_ports['server_ip_port']}"
|
||||
str1 = ""
|
||||
if "ze" in server:
|
||||
str1 = f"connect {data_ports['server_ip_port_ze']}"
|
||||
connected_to_other = False
|
||||
elif "gg" in server and not connected_to_other:
|
||||
str1 = f"connect {data_ports['server_ip_port_gg']}"
|
||||
elif not connected_to_other:
|
||||
str1 = f"connect {data_ports['server_ip_port_zr']}"
|
||||
writeCfgInput(str1)
|
||||
print('not yet connected')
|
||||
|
||||
@ -148,6 +154,7 @@ if __name__ == '__main__':
|
||||
restart_sdl_and_steam()
|
||||
else:
|
||||
kill_owned_process("pidof hl2_linux")
|
||||
connected_to_other = False
|
||||
launch_css_process()
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
@ -182,17 +189,21 @@ if __name__ == '__main__':
|
||||
joinTeam()
|
||||
elif data == "bot kicked server full":
|
||||
print('bot kicked server full: ', datetime.datetime.now().time())
|
||||
elif data == "connect to ze":
|
||||
elif "connected to" in data:
|
||||
connected_to_other = True
|
||||
elif "connect to" in data:
|
||||
if connection_issue_counter == 20:
|
||||
kill_owned_process("pidof hl2_linux")
|
||||
launch_css_process()
|
||||
connected_to_other = False
|
||||
elif connection_issue_counter == 50:
|
||||
restart_sdl_and_steam()
|
||||
launch_css_process()
|
||||
connected_to_other = False
|
||||
connection_issue_counter = -10
|
||||
connection_issue_counter += 1
|
||||
print('connection_issue_counter: ', connection_issue_counter)
|
||||
bot_connect_ze()
|
||||
bot_connect(data, connected_to_other)
|
||||
elif "clientmessage:" in data:
|
||||
messager_name = data.split("clientmessage:", 1)[1].split(" 72DqZ84")[0]
|
||||
databyte_send_message = messager_name + data.split("72DqZ84")[1]
|
||||
@ -235,3 +246,4 @@ if [[ $DISPLAY ]]; then
|
||||
steam
|
||||
fi
|
||||
"""
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <sdktools>
|
||||
#include <sdkhooks>
|
||||
#include <outputinfo>
|
||||
#include <cstrike>
|
||||
#include <socket>
|
||||
|
||||
//#pragma newdecls required
|
||||
@ -18,7 +19,8 @@ int targethuman[MAXPLAYERS + 1];
|
||||
int target_enemy[MAXPLAYERS + 1];
|
||||
int buttons_old[MAXPLAYERS + 1];
|
||||
int flags_old[MAXPLAYERS + 1];
|
||||
int ports[5] = {48470, 48471, 48472, 48473, 48474}; //last index is port its sending udp from
|
||||
int ports[7] = {48470, 48471, 48472, 48473, 48474, 48479, 48480}; //last three indexes are ports its sending udp from in plugin
|
||||
int server_ports[3] = {27015, 27021, 27016}; //server ports: ze, gg, zr
|
||||
bool surf_cooldown = false;
|
||||
int bot_avoid_edge[MAXPLAYERS + 1];
|
||||
float client_old_coords[MAXPLAYERS + 1][3];
|
||||
@ -298,8 +300,12 @@ public Action bot_check_connect(Handle timer, any data)
|
||||
{
|
||||
int client_count = GetClientCount(false);
|
||||
char msg[generic_length];
|
||||
//PrintToChatAll("sending UDP message...");
|
||||
Format(msg, sizeof(msg), "connect to ze");
|
||||
int i_port = GetConVarInt(FindConVar("hostport"));
|
||||
bool is_host_ze = false;
|
||||
if (i_port == server_ports[0])
|
||||
{
|
||||
is_host_ze = true;
|
||||
}
|
||||
bool found_bot1 = false;
|
||||
bool found_bot2 = false;
|
||||
bool found_bot3 = false;
|
||||
@ -307,38 +313,81 @@ public Action bot_check_connect(Handle timer, any data)
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
if (IsValidClient(i) && !IsFakeClient(i))
|
||||
{
|
||||
if (client_count > 50)
|
||||
if (client_count > 60)
|
||||
{
|
||||
found_bot1 = true;
|
||||
found_bot2 = true;
|
||||
found_bot3 = true;
|
||||
found_bot4 = true;
|
||||
if (client_count > 60)
|
||||
found_bot2 = true;
|
||||
found_bot3 = true;
|
||||
found_bot4 = true;
|
||||
if (is_bot_player(i))
|
||||
{
|
||||
if (is_bot_player(i))
|
||||
KickClient(i, "server full you need to leave");
|
||||
}
|
||||
}
|
||||
if (is_host_ze)
|
||||
{
|
||||
if (client_count < 50)
|
||||
{
|
||||
Format(msg, sizeof(msg), "connect to ze");
|
||||
if (is_autism_bot1(i))
|
||||
{
|
||||
KickClient(i, "server full you need to leave");
|
||||
found_bot1 = true;
|
||||
}
|
||||
if (is_autism_bot2(i))
|
||||
{
|
||||
found_bot2 = true;
|
||||
}
|
||||
if (is_autism_bot3(i))
|
||||
{
|
||||
found_bot3 = true;
|
||||
}
|
||||
if (is_autism_bot4(i))
|
||||
{
|
||||
found_bot4 = true;
|
||||
}
|
||||
}
|
||||
else if (client_count > 55)
|
||||
{
|
||||
found_bot1 = true;
|
||||
found_bot2 = true;
|
||||
found_bot3 = true;
|
||||
found_bot4 = true;
|
||||
Format(msg, sizeof(msg), "connect to gg");
|
||||
send_socket_msg(msg, strlen(msg), ports[0]);
|
||||
Format(msg, sizeof(msg), "connect to zr");
|
||||
send_socket_msg(msg, strlen(msg), ports[1]);
|
||||
send_socket_msg(msg, strlen(msg), ports[2]);
|
||||
send_socket_msg(msg, strlen(msg), ports[3]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
found_bot1 = true;
|
||||
found_bot2 = true;
|
||||
found_bot3 = true;
|
||||
found_bot4 = true;
|
||||
if (is_autism_bot1(i))
|
||||
{
|
||||
found_bot1 = true;
|
||||
Format(msg, sizeof(msg), "connected to gg");
|
||||
send_socket_msg(msg, strlen(msg), ports[0]);
|
||||
}
|
||||
if (is_autism_bot2(i))
|
||||
{
|
||||
found_bot2 = true;
|
||||
}
|
||||
if (is_autism_bot3(i))
|
||||
{
|
||||
found_bot3 = true;
|
||||
}
|
||||
if (is_autism_bot4(i))
|
||||
else if (is_bot_player(i))
|
||||
{
|
||||
found_bot4 = true;
|
||||
Format(msg, sizeof(msg), "connected to zr");
|
||||
}
|
||||
if (is_autism_bot2(i))
|
||||
{
|
||||
send_socket_msg(msg, strlen(msg), ports[1]);
|
||||
}
|
||||
if (is_autism_bot3(i))
|
||||
{
|
||||
send_socket_msg(msg, strlen(msg), ports[2]);
|
||||
}
|
||||
if (is_autism_bot4(i))
|
||||
{
|
||||
send_socket_msg(msg, strlen(msg), ports[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found_bot1)
|
||||
@ -820,6 +869,14 @@ public float get_power_distance(int target_player, float [3]pos)
|
||||
return GetVectorDistance(vec, pos);
|
||||
}
|
||||
|
||||
public Action respawn_bot(Handle timer, int client)
|
||||
{
|
||||
if (IsValidClient(client) && is_bot_player(client) && !IsPlayerAlive(client) && GetClientTeam(client) > 1)
|
||||
{
|
||||
CS_RespawnPlayer(client);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClientPostAdminCheck(int client)
|
||||
{
|
||||
target_human_afk_counter[client] = 0;
|
||||
@ -831,18 +888,22 @@ public void OnClientPostAdminCheck(int client)
|
||||
if (is_autism_bot1(client))
|
||||
{
|
||||
send_socket_msg(msg, strlen(msg), ports[0]);
|
||||
CreateTimer(10.0, respawn_bot, client);
|
||||
}
|
||||
if (is_autism_bot2(client))
|
||||
{
|
||||
send_socket_msg(msg, strlen(msg), ports[1]);
|
||||
CreateTimer(10.0, respawn_bot, client);
|
||||
}
|
||||
if (is_autism_bot3(client))
|
||||
{
|
||||
send_socket_msg(msg, strlen(msg), ports[2]);
|
||||
CreateTimer(10.0, respawn_bot, client);
|
||||
}
|
||||
if (is_autism_bot4(client))
|
||||
{
|
||||
send_socket_msg(msg, strlen(msg), ports[3]);
|
||||
CreateTimer(10.0, respawn_bot, client);
|
||||
}
|
||||
if (CheckCommandAccess(client, "sm_kick", ADMFLAG_KICK))
|
||||
admins[client] = true;
|
||||
@ -864,11 +925,23 @@ stock void connect_socket()
|
||||
{
|
||||
if (global_socket == INVALID_HANDLE || !SocketIsConnected(global_socket))
|
||||
{
|
||||
int i_port = GetConVarInt(FindConVar("hostport"));
|
||||
int target_port = ports[4]; //default ze
|
||||
if (i_port == server_ports[1])
|
||||
{
|
||||
//gg
|
||||
target_port = ports[5];
|
||||
}
|
||||
else if (i_port == server_ports[2])
|
||||
{
|
||||
//zr
|
||||
target_port = ports[6];
|
||||
}
|
||||
//socket otherwise declare in public OnConfigsExecuted(){}
|
||||
global_socket = SocketCreate(SOCKET_UDP, OnSocketError);
|
||||
SocketSetOption(global_socket, SocketReuseAddr, 1);
|
||||
SocketBind(global_socket, "127.0.0.0", ports[4]);
|
||||
SocketConnect(global_socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, "127.0.0.1", ports[4]); //48474
|
||||
SocketBind(global_socket, "127.0.0.0", target_port);
|
||||
SocketConnect(global_socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, "127.0.0.1", target_port); //48474 on ze
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user