Thanks ThatKidWhoGames! I generally avoid using OnPlayerRunCmd because of the resource drain but in this case I think it is probably the best option.
Thanks nosoop! As usual, great answer. I just tested the nb_stop command. I can confirm that it mostly works but I didn't like the results. When enabled the Bots still move until they reach a map barrier or wall. I was hoping for an immediate stop. I also noticed a Pyro continuing to use his flamethrower and a Demoman with shield continued to charge, even after hitting a wall. I previously tested FL_FROZEN and found that it worked as desired as far as the player not moving or firing. However, made the targets turn blue.
I developed and tested a solution using the recommendation from ThatKidWhoGames and it works well. The Bots stop moving immediately. They keep their weapons. They don't attack. Here's the working solution for anyone that is interested:
PHP Code:
#include <sourcemod>
#include <tf2_stocks>
#pragma semicolon 1
#pragma newdecls required
bool g_bBotsAreChill = false;
#define PLUGIN_VERSION "1.1"
public Plugin myinfo =
{
name = "Bots Chill/Attack",
author = "PC Gamer",
description = "Prevents Bots from moving or attacking",
version = PLUGIN_VERSION,
url = "https://www.alliedmods.net"
}
public void OnPluginStart()
{
RegAdminCmd("sm_botschill", Command_BotsChill, ADMFLAG_SLAY, "Make Bots Chill");
RegAdminCmd("sm_botsattack", Command_BotsAttack, ADMFLAG_SLAY, "Make Bots Attack");
}
public Action Command_BotsChill(int client, int args)
{
ReplyToCommand(client, "Bots are now Chill and won't move or attack.");
ReplyToCommand(client, "Use sm_botsattack to make them move/attack again");
PrintToChatAll("Bots have been forced to Chill. They no longer move or attack");
g_bBotsAreChill = true;
int i;
for (i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && IsFakeClient(i))
{
SetEntityMoveType(i, MOVETYPE_NONE);
}
}
return Plugin_Handled;
}
public Action Command_BotsAttack(int client, int args)
{
ReplyToCommand(client, "Bots are now moving and attacking.");
ReplyToCommand(client, "Use sm_botschill to make them stop attacking again");
PrintToChatAll("Bots are no longer Chill. They will now move and attack");
g_bBotsAreChill = false;
int i;
for (i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && IsFakeClient(i))
{
SetEntityMoveType(i, MOVETYPE_WALK);
TF2_RegeneratePlayer(i);
}
}
return Plugin_Handled;
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
if (g_bBotsAreChill == true && IsFakeClient(client))
{
if(buttons & IN_ATTACK || buttons & IN_ATTACK2 || buttons & IN_ATTACK3)
{
return Plugin_Handled;
}
}
return Plugin_Continue;
}