sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

Fix multiple commands execution in adminmenu_custom.txt

Open musosoft opened this issue 10 months ago • 5 comments

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:" }
		        }
		}
	}
}

musosoft avatar Mar 21 '25 19:03 musosoft

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:"
			}
		}
	}
}

ambaca avatar Apr 03 '25 03:04 ambaca

"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

musosoft avatar Apr 03 '25 05:04 musosoft

...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

ambaca avatar Apr 03 '25 14:04 ambaca

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. 🙏

musosoft avatar Apr 04 '25 16:04 musosoft

I love the simplicity of your solution, it's suitable for me, however quoting adds another layer of safety, which would be broken by this.

musosoft avatar May 27 '25 09:05 musosoft