From 283d19c04aeb5f306b1ce8b0efe918ba27436244 Mon Sep 17 00:00:00 2001 From: christian Date: Fri, 6 Aug 2021 19:16:01 +0200 Subject: [PATCH] should allow bots to rtv --- AutismBotIngame/scripting/autism_bot_info.sp | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/AutismBotIngame/scripting/autism_bot_info.sp b/AutismBotIngame/scripting/autism_bot_info.sp index 62b34c1b..e30a3409 100644 --- a/AutismBotIngame/scripting/autism_bot_info.sp +++ b/AutismBotIngame/scripting/autism_bot_info.sp @@ -28,6 +28,7 @@ bool chat_cooldown = false; //admins & vips bool admins[MAXPLAYERS + 1]; bool vips[MAXPLAYERS + 1]; +bool rtv; //socket for bot input Handle global_socket; @@ -43,6 +44,7 @@ public Plugin myinfo = public void OnPluginStart() { + rtv = false; for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i)) { @@ -52,6 +54,7 @@ public void OnPluginStart() } //talking RegConsoleCmd("sm_autism", cmd_talk, "talking to the bot through java application"); + RegConsoleCmd("sm_rtv", cmd_botrtv, "making bots rtv"); //hooks HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy); @@ -182,6 +185,27 @@ public bool is_autism_bot4(int client) return StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false); } +public Action cmd_botrtv(int client, int args) +{ + if ((vips[client] || admins[client]) && !rtv) + { + bool bot_found = false; + for (int i = 1; i <= MaxClients; i++) + { + if (IsValidClient(i) && !IsFakeClient(i) && is_bot_player(i)) + { + FakeClientCommand(i, "sm_say rtv"); + bot_found = true; + } + } + if (bot_found) + { + rtv = true; + } + } + return Plugin_Handled; +} + public Action cmd_talk(int client, int args) { char info[generic_length]; @@ -191,6 +215,10 @@ 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)) + { + return Plugin_Handled; + } if (chat_cooldown) { PrintToChat(client, "spamming bot too much, applying cooldown"); @@ -245,10 +273,12 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast public void OnMapStart() { + rtv = true; //0.2 too spammmy, 1.5 too slow chat_cooldown = false; CreateTimer(0.30, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(15.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + CreateTimer(600.0, bot_allow_rtv); } public void send_socket_msg(char[] query_msg, int len, int port) @@ -258,6 +288,12 @@ public void send_socket_msg(char[] query_msg, int len, int port) SocketSendTo(global_socket, query_msg, len, "127.0.0.1", port); //udp } +public Action bot_allow_rtv(Handle timer, any data) +{ + rtv = false; + return Plugin_Continue; +} + public Action bot_check_connect(Handle timer, any data) { int client_count = GetClientCount(false);