Hello i am working on a small plugin for my kids server.
All I'm trying to do is.
Implement into the sm_admin menu for easy use.
the I'm trying to be able to change the tf_bot_quota x, and add bots x, and kick bot individually or all.
I keep getting these compiling issues:
(23) : error 001: expected token: ";", but found "-identifier-"
(34) : error 002: only a single statement (or expression) can follow each "case"
(34) : error 036: empty statement
(35) : warning 217: inconsistent indentation (did you mix tabs and spaces?)
(35) : error 014: invalid statement; not in switch
(35) : error 001: expected token: ";", but found ":"
(35) : error 029: invalid expression, assumed zero
Thank you for your help.
This is my code:
#include <sourcemod>
#include <tf2>
public Plugin myPlugin = {
name = "TF2BotControl",
author = "P0k3sm0t",
description = "TF2 Bot Control Plugin",
version = "1.0",
};
public void OnPluginStart() {
RegisterPlugin(myPlugin);
}
public Action OnAdminMenuToggled(int client, bool open) {
if (open) {
DisplayBotControlMenu(client);
}
return Plugin_Continue;
}
public void DisplayBotControlMenu(int client) {
new Handle menuHandle = CreateMenu("Bot Control", 0, MenuCallback);
AddMenuItem(menuHandle, "BotQuota", "Set the bot quota", "menu_quota");
AddMenuItem(menuHandle, "AddBot", "Add bots to the server", "menu_addbot");
AddMenuItem(menuHandle, "KickBot", "Kick bots from the server", "menu_kickbot");
ShowMenu(client, menuHandle);
}
public Action MenuCallback(Handle menu, int client, int item, int action) {
switch (action) {
case 1: // BotQuota
ShowBotQuotaMenu(client);
break;
case 2: // AddBot
ShowAddBotMenu(client);
break;
case 3: // KickBot
ShowKickBotMenu(client);
break;
default:
break;
}
return Plugin_Continue;
}
public void ShowBotQuotaMenu(int client) {
new Handle menuHandle = CreateMenu("Bot Quota", 0, QuotaMenuCallback);
AddMenuItem(menuHandle, "BotQuota 8", "", "quota_8");
AddMenuItem(menuHandle, "BotQuota 10", "", "quota_10");
AddMenuItem(menuHandle, "BotQuota 12", "", "quota_12");
AddMenuItem(menuHandle, "BotQuota 14", "", "quota_14");
AddMenuItem(menuHandle, "BotQuota 16", "", "quota_16");
AddMenuItem(menuHandle, "BotQuota 18", "", "quota_18");
AddMenuItem(menuHandle, "BotQuota 20", "", "quota_20");
AddMenuItem(menuHandle, "Back", "", "back");
ShowMenu(client, menuHandle);
}
public Action QuotaMenuCallback(Handle menu, int client, int item, int action) {
switch (action) {
case 1: // BotQuota 8
SetBotQuota(
;
break;
case 2: // BotQuota 10
SetBotQuota(10);
break;
case 3: // BotQuota 12
SetBotQuota(12);
break;
case 4: // BotQuota 14
SetBotQuota(14);
break;
case 5: // BotQuota 16
SetBotQuota(16);
break;
case 6: // BotQuota 18
SetBotQuota(1
;
break;
case 7: // BotQuota 20
SetBotQuota(20);
break;
case 8: // Back
DisplayBotControlMenu(client);
break;
default: // Handle unexpected actions
break;
}
return Plugin_Continue;
}
public void SetBotQuota(int quota) {
// Set the bot quota using tf_bot_quota cvar
SetConVarInt("tf_bot_quota", quota);
}
public void ShowAddBotMenu(int client) {
new Handle menuHandle = CreateMenu("Add Bot", 0, AddBotMenuCallback);
for (int i = 1; i <= 10; i++) {
char buffer[10];
format(buffer, sizeof(buffer), "AddBot %d", i);
AddMenuItem(menuHandle, buffer, "", "addbot_" + i);
}
AddMenuItem(menuHandle, "Back", "", "back");
ShowMenu(client, menuHandle);
}
public Action AddBotMenuCallback(Handle menu, int client, int item, int action) {
if (action >= 1 && action <= 10) {
int numBots = action;
for (int i = 0; i < numBots; i++) {
// Execute tf_bot_add command to add a bot
ServerCommand("tf_bot_add");
}
} else if (action == 11) { // Back
DisplayBotControlMenu(client);
}
return Plugin_Continue;
}
public void ShowKickBotMenu(int client) {
new Handle menuHandle = CreateMenu("Kick Bot", 0, KickBotMenuCallback);
// Get list of bots on the server and add options to kick them individually
// For example:
foreach(int botIndex; 1 <= MaxClients; botIndex++) {
if (IsClientInGame(botIndex) && IsClientBot(botIndex)) {
char botName[32];
GetClientName(botIndex, botName, sizeof(botName));
AddMenuItem(menuHandle, botName, "", "kickbot_" + botIndex);
}
}
// Add option to kick all bots
AddMenuItem(menuHandle, "Kick all Bots", "", "kick_all_bots");
AddMenuItem(menuHandle, "Back", "", "back");
ShowMenu(client, menuHandle);
}
public Action KickBotMenuCallback(Handle menu, int client, int item, int action) {
if (action > 0 && action <= MaxClients) {
// Kick individual bot
int botIndex = action;
char command[32];
format(command, sizeof(command), "tf_bot_kick %d", botIndex);
ServerCommand(command);
} else if (action == (MaxClients + 1)) {
// Kick all bots
ServerCommand("tf_bot_kick all");
} else if (action == (MaxClients + 2)) { // Back
DisplayBotControlMenu(client);
}
return Plugin_Continue;
}
Not sure why it put smillyfaces in there lol.