further updates so people dont get taken over by force

This commit is contained in:
christian 2021-04-09 21:17:30 +02:00
parent cd2025cffd
commit 6eedaec56f
2 changed files with 41 additions and 45 deletions

View File

@ -11,7 +11,8 @@ import codecs
import datetime import datetime
import time import time
looptestPath = '/home/gameservers/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/cfg/looptest.cfg' who_am_i = subprocess.getoutput(["whoami"])
looptestPath = f"""/home/{who_am_i}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/cfg/looptest.cfg"""
chatmsg = "" chatmsg = ""
def colored(r, g, b, text): def colored(r, g, b, text):
@ -95,12 +96,15 @@ def strinput_append(strInput, nth):
def kill_css_process(): def kill_css_process():
css_pid = subprocess.getoutput(["pidof hl2_linux"]) css_pid = subprocess.getoutput(["pidof hl2_linux"])
if css_pid: if css_pid:
print('css_pid: ', css_pid, 'shutting the bots game down....') for pid in css_pid.split(" "):
css_pid = int(css_pid.strip()) username = subprocess.getoutput([f"""ps -o user= -p {pid}"""])
os.kill(css_pid, signal.SIGTERM) if username == who_am_i:
time.sleep(15) print('pid: ', pid, 'shutting the bots game down....')
pid = int(pid.strip())
os.kill(pid, signal.SIGTERM)
time.sleep(15)
print('preparing to launch game....') print('preparing to launch game....')
os.chdir('/home/gameservers/.steam/debian-installation/') os.chdir(f"""/home/{who_am_i}/.steam/debian-installation/""")
subprocess.check_call("./steam.sh %s" % ("-applaunch 240 -textmode -textmessagedebug -novid -nosound -noipx -nojoy -noshaderapi"), shell=True) subprocess.check_call("./steam.sh %s" % ("-applaunch 240 -textmode -textmessagedebug -novid -nosound -noipx -nojoy -noshaderapi"), shell=True)
print('finished starting game') print('finished starting game')
@ -142,6 +146,7 @@ if __name__ == '__main__':
ip = addr[0] ip = addr[0]
port = addr[1] port = addr[1]
#print('port: ', port, " ip: ", ip) #print('port: ', port, " ip: ", ip)
#print(data)
if not data: if not data:
continue continue
if ip not in [local_ip, udp_external_ip]: if ip not in [local_ip, udp_external_ip]:
@ -162,7 +167,7 @@ if __name__ == '__main__':
elif data == "bot kicked server full": elif data == "bot kicked server full":
print('bot kicked server full: ', datetime.datetime.now().time()) print('bot kicked server full: ', datetime.datetime.now().time())
elif data == "connect to ze": elif data == "connect to ze":
if connection_issue_counter == 5: if connection_issue_counter == 5 or connection_issue_counter > 50:
kill_css_process() kill_css_process()
connection_issue_counter += 1 connection_issue_counter += 1
print('connection_issue_counter: ', connection_issue_counter) print('connection_issue_counter: ', connection_issue_counter)
@ -207,4 +212,3 @@ if __name__ == '__main__':
#before steam login: export SDL_VIDEO_X11_VISUALID=0x074 #before steam login: export SDL_VIDEO_X11_VISUALID=0x074
#to find correct SDL_VIDEO_X11_VISUALID use glxinfo in X2GO #to find correct SDL_VIDEO_X11_VISUALID use glxinfo in X2GO

View File

@ -13,13 +13,11 @@
#include <socket> #include <socket>
//#pragma newdecls required //#pragma newdecls required
int present[MAXPLAYERS + 1];
int targethuman[MAXPLAYERS + 1]; int targethuman[MAXPLAYERS + 1];
int target_enemy[MAXPLAYERS + 1]; int target_enemy[MAXPLAYERS + 1];
int buttons_old[MAXPLAYERS + 1]; int buttons_old[MAXPLAYERS + 1];
int flags_old[MAXPLAYERS + 1]; int flags_old[MAXPLAYERS + 1];
bool surf_cooldown = false; bool surf_cooldown = false;
bool connected_cooldown = false;
float client_old_coords[MAXPLAYERS + 1][3]; float client_old_coords[MAXPLAYERS + 1][3];
float targethuman_teleported[MAXPLAYERS + 1][3]; float targethuman_teleported[MAXPLAYERS + 1][3];
bool chat_cooldown = false; bool chat_cooldown = false;
@ -82,7 +80,7 @@ public void trigger_teleport(const char[] output, int entity_index, int client,
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]); GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
CreateTimer(6.0, reset_target_tp, client); CreateTimer(6.0, reset_target_tp, client);
} }
else if (client == present[0] || client == present[1]) else if (is_bot_player(i) && i == client)
CreateTimer(0.1, reset_target_tp, client); CreateTimer(0.1, reset_target_tp, client);
} }
} }
@ -99,7 +97,7 @@ public void Trigger_Multiple(const char[] output, int entity_index, int client,
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]); GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
CreateTimer(6.0, reset_target_tp, client); CreateTimer(6.0, reset_target_tp, client);
} }
else if (client == present[0] || client == present[1]) else if (is_bot_player(i) && i == client)
CreateTimer(0.1, reset_target_tp, client); CreateTimer(0.1, reset_target_tp, client);
} }
} }
@ -282,7 +280,7 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
int cmdnum, int tickcount, int seed, const int mouse[2]) int cmdnum, int tickcount, int seed, const int mouse[2])
{ {
if (!IsClientInGame(client)) return; if (!IsClientInGame(client)) return;
if (client == present[0] || client == present[1]) if (is_bot_player(client))
{ {
int flags = GetEntityFlags(client); int flags = GetEntityFlags(client);
if (!(flags & FL_ONGROUND) && (flags_old[client] & FL_ONGROUND) && !(buttons_old[client] & IN_JUMP) && !(buttons & IN_JUMP) && (GetEntityMoveType(client) != MOVETYPE_LADDER)) if (!(flags & FL_ONGROUND) && (flags_old[client] & FL_ONGROUND) && !(buttons_old[client] & IN_JUMP) && !(buttons & IN_JUMP) && (GetEntityMoveType(client) != MOVETYPE_LADDER))
@ -347,12 +345,27 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
} }
} }
public bool is_bot_player(int client)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
{
return true;
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
{
return true;
}
return false;
}
public Action recursive_pressing(Handle timer, any data) public Action recursive_pressing(Handle timer, any data)
{ {
for (int client = 1; client <= MaxClients; client++) for (int client = 1; client <= MaxClients; client++)
{ {
if (!IsValidClient(client)) continue; if (!IsValidClient(client)) continue;
if (client == present[0] || client == present[1]) if (is_bot_player(client))
{ {
if (GetClientTeam(client) == 1 || GetClientTeam(client) == 0) if (GetClientTeam(client) == 1 || GetClientTeam(client) == 0)
{ {
@ -581,14 +594,14 @@ public void check_bot_surfing()
float vPos[3]; float vPos[3];
float vMins[3]; float vMins[3];
float vMaxs[3]; float vMaxs[3];
GetEntPropVector(present[client], Prop_Data, "m_vecOrigin", vPos); GetEntPropVector(, Prop_Data, "m_vecOrigin", vPos);
GetEntPropVector(present[client], Prop_Send, "m_vecMins", vMins); GetEntPropVector(, Prop_Send, "m_vecMins", vMins);
GetEntPropVector(present[client], Prop_Send, "m_vecMaxs", vMaxs); GetEntPropVector(, Prop_Send, "m_vecMaxs", vMaxs);
float vEndPos[3]; float vEndPos[3];
vEndPos[0] = vPos[0]; vEndPos[0] = vPos[0];
vEndPos[1] = vPos[1]; vEndPos[1] = vPos[1];
vEndPos[2] = vPos[2] - FindConVar("sv_maxvelocity").FloatValue; vEndPos[2] = vPos[2] - FindConVar("sv_maxvelocity").FloatValue;
TR_TraceHullFilter(vPos, vEndPos, vMins, vMaxs, MASK_ALL, TraceRayDontHitSelf, present[client]); TR_TraceHullFilter(vPos, vEndPos, vMins, vMaxs, MASK_ALL, TraceRayDontHitSelf, );
if (TR_DidHit()) if (TR_DidHit())
{ {
//< 0.7 = surf ramp //< 0.7 = surf ramp
@ -605,7 +618,7 @@ public void check_bot_surfing()
if (!surf_cooldown) if (!surf_cooldown)
{ {
surf_cooldown = true; surf_cooldown = true;
TeleportEntity(present[client], NULL_VECTOR, vPlane, NULL_VECTOR); TeleportEntity(, NULL_VECTOR, vPlane, NULL_VECTOR);
Format(keyinput, sizeof(keyinput), "surfing: %f %f %f", vPlane[0], vPlane[1], vPlane[2]); Format(keyinput, sizeof(keyinput), "surfing: %f %f %f", vPlane[0], vPlane[1], vPlane[2]);
char auth[50]; char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
@ -730,16 +743,16 @@ public void OnClientPostAdminCheck(int client)
//[U:1:120378081] //[U:1:120378081]
//[U:1:69566635] //[U:1:69566635]
char auth[50]; char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
char msg[generic_length];
Format(msg, sizeof(msg), "autismo connected");
if (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))
{ {
present[0] = client; send_socket_msg(msg, strlen(msg));
bot_send_connected_msg(0);
} }
if (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))
{ {
present[1] = client; send_socket_msg1(msg, strlen(msg));
bot_send_connected_msg(1);
} }
if (CheckCommandAccess(client, "sm_kick", ADMFLAG_KICK)) if (CheckCommandAccess(client, "sm_kick", ADMFLAG_KICK))
admins[client] = true; admins[client] = true;
@ -778,27 +791,6 @@ public void OnClientDisconnect(int client)
client_old_coords[client][2] = 0.0; client_old_coords[client][2] = 0.0;
} }
public void bot_send_connected_msg(int bot_specified)
{
char msg[generic_length];
Format(msg, sizeof(msg), "autismo connected");
if (!connected_cooldown)
{
connected_cooldown = true;
if (!bot_specified)
send_socket_msg(msg, strlen(msg));
else
send_socket_msg1(msg, strlen(msg));
CreateTimer(5.0, connect_cooldown);
}
}
public Action connect_cooldown(Handle timer, any data)
{
connected_cooldown = false;
return Plugin_Continue;
}
//Socket callback //Socket callback
public OnSocketConnected(Handle socket, any arg) public OnSocketConnected(Handle socket, any arg)
{ {