This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Help with a plugin please.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
P0k3sm0t
New Member
Join Date: May 2024
Old 05-09-2024 , 12:16   Help with a plugin please.
Reply With Quote #1

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.
Attached Files
File Type: sp Get Plugin or Get Source (BotQuota.sp - 6 views - 4.9 KB)
P0k3sm0t is offline
little_froy
Senior Member
Join Date: May 2021
Old 05-09-2024 , 12:46   Re: Help with a plugin please.
Reply With Quote #2

don't try to generate sourcemod mode by ai
little_froy is offline
P0k3sm0t
New Member
Join Date: May 2024
Old 05-09-2024 , 12:55   Re: Help with a plugin please.
Reply With Quote #3

Quote:
Originally Posted by little_froy View Post
don't try to generate sourcemod mode by ai
My apologies. Is there a rule against it? or just doesn't work?
P0k3sm0t is offline
DNA.styx
Member
Join Date: Dec 2023
Old 05-09-2024 , 13:49   Re: Help with a plugin please.
Reply With Quote #4

If you want to write a sourcemod plugin for this to challenge yourself and have a go at coding, I'll leave it to others to help you...but if you want a quick win, what you are trying to do seems similar to what I wanted. While there are multiple options, I used custom votes deluxe to create a menu that can be called by anyone on the server and 'vote' for a server change. When there is just one person on the server the vote passes straight away. While it suited my use case (and my bots) to call a .cfg for each type of vote, you could just add commands.

Here's a bit of the .cfg I created.

Code:
	"Bot Settings"
	{
		"type"			"list"
		"vote"			"1"
		"ratio"			"0.6"
		"minimum"		"0"
		"command"		"sm_execcfg {OPTION_RESULT}"
		"options"
		{
			"Remove All Bots"			"sourcemod/vote_rcbot_kick_all.cfg"
			"Some Bots"			"sourcemod/vote_rcbot_some_bots.cfg"
			"Default Bots"			"sourcemod/vote_dod_equip_default.cfg"
		}
		"start_notify"	"[SM] {VOTER_NAME} ({VOTER_STEAMID}) started a vote to {OPTION_NAME}."
		"call_notify"	"[SM] Vote cast for {yes|no}."
		"pass_notify"	"[SM] Vote passed to {OPTION_NAME}."
		"fail_notify"	"[SM] Vote failed. Received: {VOTE_AMOUNT} Required: {VOTE_REQUIRED}"
		"chattrigger"	"votebot"
	}
Quote:
Originally Posted by P0k3sm0t View Post
Not sure why it put smillyfaces in there lol.
The trick is to format your test using [c o d e]stuff here[/c o d e] ...just remove the spaces from between the word code
__________________
DNA.styx is offline
P0k3sm0t
New Member
Join Date: May 2024
Old 05-09-2024 , 14:11   Re: Help with a plugin please.
Reply With Quote #5

Quote:
Originally Posted by DNA.styx View Post
If you want to write a sourcemod plugin for this to challenge yourself and have a go at coding, I'll leave it to others to help you...but if you want a quick win, what you are trying to do seems similar to what I wanted. While there are multiple options, I used custom votes deluxe to create a menu that can be called by anyone on the server and 'vote' for a server change. When there is just one person on the server the vote passes straight away. While it suited my use case (and my bots) to call a .cfg for each type of vote, you could just add commands.

Here's a bit of the .cfg I created.

Code:
	"Bot Settings"
	{
		"type"			"list"
		"vote"			"1"
		"ratio"			"0.6"
		"minimum"		"0"
		"command"		"sm_execcfg {OPTION_RESULT}"
		"options"
		{
			"Remove All Bots"			"sourcemod/vote_rcbot_kick_all.cfg"
			"Some Bots"			"sourcemod/vote_rcbot_some_bots.cfg"
			"Default Bots"			"sourcemod/vote_dod_equip_default.cfg"
		}
		"start_notify"	"[SM] {VOTER_NAME} ({VOTER_STEAMID}) started a vote to {OPTION_NAME}."
		"call_notify"	"[SM] Vote cast for {yes|no}."
		"pass_notify"	"[SM] Vote passed to {OPTION_NAME}."
		"fail_notify"	"[SM] Vote failed. Received: {VOTE_AMOUNT} Required: {VOTE_REQUIRED}"
		"chattrigger"	"votebot"
	}


The trick is to format your test using [c o d e]stuff here[/c o d e] ...just remove the spaces from between the word code
Thats a great solution! That would actually work well. Now for each .cfg would I put all the CVARS plus the ones for this, or will just adding the new CVARS only for the plugin will trigger those changes only? Thank you.
Would still like to implement a plugin to control the three commands that get used the most.
Unfortunately bot manager no longer works properly. otherwise I'd just use that.

Edited: Just tried to download the plugin and it no longer compiles/downloads sad. to see everything is so old and out dated for this game.
Scratch that. clicked on Get Plugin instead of the .smx under it. But still funny it dosn't compile.

The server is showing a lot of :
KeyValues Error: RecursiveLoadFromBuffer: got empty keyname in file addons/sourcemod/configs/customvotes.cfg
Custom Votes, (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
KeyValues Error: LoadFromBuffer: missing { in file addons/sourcemod/configs/customvotes.cfg
(*Custom Votes*), (*Change the map*), (*{*), (*options*),
L 05/09/2024 - 11:48:10: [customvotes.smx] Configuration file addons/sourcemod/configs/customvotes.cfg loaded.
You get these errors?

Edited: I found the problem, But it doesn't actually bring up the vote. It'll bring up the menu but then won't do anything afterwords. It appears to be doing it to alot of people.

Last edited by P0k3sm0t; 05-09-2024 at 15:56.
P0k3sm0t is offline
P0k3sm0t
New Member
Join Date: May 2024
Old 05-09-2024 , 16:19   Re: Help with a plugin please.
Reply With Quote #6

Ok I think I worked most my issues out or work arounds. Thank you. You can close this.
P0k3sm0t is offline
Earendil
Senior Member
Join Date: Jan 2020
Location: Spain
Old Today , 04:59   Re: Help with a plugin please.
Reply With Quote #7

Quote:
Originally Posted by P0k3sm0t View Post
My apologies. Is there a rule against it? or just doesn't work?
AI can help you making little algorythms or small pieces of code, that require deep testing. But right now is unable to build functional code that works.

Even if you use AI to help you generate the code, first review it and check if has some sense before even try to put inside your plugin. Use AI to get hints never to work for you.
__________________
>>My plugins<<
>>GitHub<<
Earendil is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode