Skip to content

Fix multiple commands execution in adminmenu_custom.txt #2301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

musosoft
Copy link

@musosoft musosoft commented Mar 21, 2025

This PR fixes the semicolon parsing issue for adminmenu_custom.txt - player type cmd execution.

Below is an example adminmenu_custom.txt to reproduce the semicolon ";" not working before this fix - multiple commands delimited with ";" will not work.

"Commands"
{
	"PlayerCommands"
	{
		"Punishments"
		{
		        "admin"	"sm_ban"
        
		        "[BURN] TeamKill"
		        {
			        "cmd"	"sm_burn #1; sm_psay #1 No TeamKill!"
			        "execute"	"player"
			        "1" { "type" "player" "method" "name" "title" "Player:" }
		        }
		}
	}
}

This PR fixes the semicolon parsing issue for adminmenu_custom.txt - player type cmd execution.

Below is an example ```adminmenu_custom.txt``` to reproduce the semicolon ";" not working before this fix - multiple commands delimited with ";" will not work.

```
"Commands"
{
	"ServerCommands"
	{
		"AntiCheat"
		{
			"admin"	"sm_ban"

			"Enable KACR"
			{
				"cmd"	"sm plugins load disabled/kigen-ac_redux; sm_chat KACR is enabled"
				"execute"	"server"
			}
		}
	}
}
```
@ambaca
Copy link
Contributor

ambaca commented Apr 3, 2025

This PR fixes the semicolon parsing issue for adminmenu_custom.txt - player type cmd execution.

Below is an example adminmenu_custom.txt to reproduce the semicolon ";" not working before this fix - multiple commands delimited with ";" will not work.

"Commands"
{
	"PlayerCommands"
	{
		"Punishments"
		{
		        "admin"	"sm_ban"
        
		        "[BURN] TeamKill"
		        {
			        "cmd"	"sm_burn #1; sm_psay #1 No TeamKill!"
			        "execute"	"player"
			        "1" { "type" "player" "method" "name" "title" "Player:" }
		        }
		}
	}
}

I saw you have one too many sub-menu ( "[BURN] TeamKill") what usually breaks adminmenu_custom.
This is working one

"Commands"
{
	"PlayerCommands"
	{
		"Punishments"
		{
			"admin"	"sm_ban"
	
			"cmd"	"say sm_burn #1; say sm_psay #1 No TeamKill!"
			"execute"	"player"
			"1"
			{
				"type" "player"
				"method" "name"
				"title" "Player:"
			}
		}
	}
}

@musosoft
Copy link
Author

musosoft commented Apr 3, 2025

"Commands"
{
	"PlayerCommands"
	{
		"Punishments"
		{
			"admin"	"sm_ban"
	
			"cmd"	"say sm_burn #1; say sm_psay #1 No TeamKill!"
			"execute"	"player"
			"1"
			{
				"type" "player"
				"method" "name"
				"title" "Player:"
			}
		}
	}
}
  1. If the above config is used it prints both commands in one message - without my fix, it's not delimited:
    de_dust20000

  2. If it's an "execute server" type of menu, it doesn't need my proposed fix. It will delimit properly, e.g. this works:

"Commands"
{
	"PlayerCommands"
	{
		"Punishments"
		{
			"admin"	"sm_ban"
	
			"cmd"	"say sm_burn; say sm_psay No TeamKill!"
			"execute"	"server"
		}
	}
}
  1. I made a bad example. You are right - having a third level sub-menu or deeper breaks it (sub-menu won't open). That needs to be fixed, too. Thanks for pointing it out. Perhaps it's this error:
L 04/03/2025 - 12:10:58: [SM] Exception reported: Invalid Handle 0 (error: 4)
L 04/03/2025 - 12:10:58: [SM] Blaming: adminmenu.smx
L 04/03/2025 - 12:10:58: [SM] Call stack trace:
L 04/03/2025 - 12:10:58: [SM]   [0] ArrayList.GetArray
L 04/03/2025 - 12:10:58: [SM]   [1] Line 455, C:\Users\muso\Documents\srcds\lama-srcds\addons\sourcemod\scripting\adminmenu\dynamicmenu.sp::ParamCheck
L 04/03/2025 - 12:10:58: [SM]   [2] Line 431, C:\Users\muso\Documents\srcds\lama-srcds\addons\sourcemod\scripting\adminmenu\dynamicmenu.sp::DynamicMenuItemHandler

@ambaca
Copy link
Contributor

ambaca commented Apr 3, 2025

...adminmenu_custom originally have not support more than one sub-menus.

You can trick 2nd sub menu by creating list of commands and rename them.
Here is bot commands:
https://forums.alliedmods.net/showpost.php?p=1628970&postcount=3

@musosoft
Copy link
Author

musosoft commented Apr 4, 2025

The depth of menus is another issue that's not covered by this fix. One children sub-menu limitation is not a big deal.

I would like my current approach reviewed as it fixes multiple player commands already. If it needs proper fix - suggestions are more than welcome. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants