Raised This Month: $ Target: $400
 0% 

Admin Menu Functions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Twin_Future
Junior Member
Join Date: Nov 2014
Old 11-25-2014 , 11:56   Admin Menu Functions
Reply With Quote #1

Hey all I am new to modding TF2 and decided to create some edits to a few plugins available from sourcemod.

One of the problems I am having is adding options to the admin menu.
When I select an action from the admin menu such as sm_explode I also want to modify the admin menu so that I can select @all @red and @blue as-well as a full list of players.

Inside
Code:
DisplayExplodeMenu(client)
I have added
Code:
AddMenuItem(menu, "@all", "All");
AddTargetsToMenu(menu, client, true, false);
This displays my extra option *All* above the player list but when selected says player no longer available

Under
Code:
public MenuHandler_Explode(Handle:menu, MenuAction:action, param1, param2)
There is this line, that needs adjusting to include my @all.

Code:
userid = StringToInt(info);
What can I do with the userid string to allow it to parse @all aswell as the player list?
Twin_Future is offline
Twin_Future
Junior Member
Join Date: Nov 2014
Old 11-25-2014 , 16:04   Re: Admin Menu Functions
Reply With Quote #2

I have worked out a solution myself to add these options to the menu and execute them.

Because the "userid" gets put into an int I made all the menu options numbers

Menu

Code:
AddMenuItem(menu, "99", "All");
	AddMenuItem(menu, "98", "Bots");
	AddMenuItem(menu, "97", "Humans");
	AddMenuItem(menu, "96", "Current Aim");
	AddMenuItem(menu, "95", "Me");
	AddMenuItem(menu, "94", "Everyone But Me");
	AddMenuItem(menu, "93", "Red Team");
	AddMenuItem(menu, "92", "Blue Team");
        AddTargetsToMenu(menu, client, true, false);
This is "userid" that gets put into an int under
Code:
else if (action == MenuAction_Select)
	{
		decl String:info[32];
		new userid, target;
		
		GetMenuItem(menu, param2, info, sizeof(info));
		userid = StringToInt(info);
After this I added a few if statements to check for the numbers I gave in the menu section and execute the command if number is found.

Code:
if (userid == 99)
		{
			ClientCommand(param1, "sm_explode @all");
		}
		else if (userid == 98)
		{
			ClientCommand(param1, "sm_explode @bots");
		}
		else if (userid == 97)
		{
			ClientCommand(param1, "sm_explode @humans");
		}
		else if (userid == 96)
		{
			ClientCommand(param1, "sm_explode @aim");
		}
		else if (userid == 95)
		{
			ClientCommand(param1, "sm_explode @me");
		}
		else if (userid == 94)
		{
			ClientCommand(param1, "sm_explode @!me");
		}
		else if (userid == 93)
		{
			ClientCommand(param1, "sm_explode @red");
		}
		else if (userid == 92)
		{
			ClientCommand(param1, "sm_explode @blue");
		}
This enabled me to add options to the menu like @all and @red aswell as the full list of players.

This is my first time editing these plugins so I am not sure if this is the correct way to solve this problem.

My solution works, but if there is a better way could anyone explain it?

Thanks.
Twin_Future is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-26-2014 , 16:46   Re: Admin Menu Functions
Reply With Quote #3

Dynamic Admin Menu Configuration
adminmenu_custom.txt


adminmenu_sorting.txt



adminmenu_grouping.txt




...and yes you can build whole different menu option also.

Userids by the way are uniq player numbers, it start from 1 and increase everytime when players connect to server. It's one way target players without using they names from console (#99)
Support for target patterns (@all, @blue, @me, etc. etc.) you need use ProcessTargetString and do more in code. I have to go sleep now
Bacardi 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 22:59.


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