added rtv command for bots

This commit is contained in:
christian 2021-10-17 17:17:34 +02:00
parent 4e6a638641
commit a0c4c2aa6b
2 changed files with 27 additions and 20 deletions

View File

@ -183,10 +183,14 @@ if __name__ == '__main__':
writeCfgInput(response_msg)
if ip != ovh_ip:
continue
#print("data: ", data)
if data == "autismo connected":
print('Bot connected!')
connection_issue_counter = 0
joinTeam()
elif data == "rtv":
response_msg = "say rtv"
writeCfgInput(response_msg)
elif data == "bot kicked server full":
print('bot kicked server full: ', datetime.datetime.now().time())
elif "connected to" in data:
@ -248,3 +252,4 @@ if [[ $DISPLAY ]]; then
fi
"""

View File

@ -30,7 +30,6 @@ bool chat_cooldown = false;
//admins & vips
bool admins[MAXPLAYERS + 1];
bool vips[MAXPLAYERS + 1];
bool rtv;
//socket for bot input
Handle global_socket;
@ -46,17 +45,17 @@ public Plugin myinfo =
public void OnPluginStart()
{
rtv = false;
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i))
{
targethuman[i] = 0;
target_enemy[i] = 0;
reset_target_human_tp_coord(i);
OnClientPostAdminCheck(i);
}
//talking
RegConsoleCmd("sm_autism", cmd_talk, "talking to the bot through java application");
RegConsoleCmd("sm_rtv", cmd_botrtv, "making bots rtv");
RegConsoleCmd("sm_botrtv", cmd_botrtv, "making bots rtv");
//hooks
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
@ -189,21 +188,32 @@ public bool is_autism_bot4(int client)
public Action cmd_botrtv(int client, int args)
{
if ((vips[client] || admins[client]) && !rtv)
if (vips[client] || admins[client])
{
bool bot_found = false;
char msg[generic_length];
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && !IsFakeClient(i) && is_bot_player(i))
if (IsValidClient(i) && !IsFakeClient(i))
{
FakeClientCommand(i, "sm_say rtv");
bot_found = true;
Format(msg, sizeof(msg), "rtv");
if (is_autism_bot1(i))
{
send_socket_msg(msg, strlen(msg), ports[0]);
}
else if (is_autism_bot2(i))
{
send_socket_msg(msg, strlen(msg), ports[1]);
}
else if (is_autism_bot3(i))
{
send_socket_msg(msg, strlen(msg), ports[2]);
}
else if(is_autism_bot4(i))
{
send_socket_msg(msg, strlen(msg), ports[3]);
}
}
}
if (bot_found)
{
rtv = true;
}
}
return Plugin_Handled;
}
@ -275,12 +285,10 @@ 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)
@ -290,12 +298,6 @@ 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);