Raised This Month: $32 Target: $400
 8% 

MenuSelect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 11-12-2015 , 17:37   MenuSelect
Reply With Quote #1

Hey0,

I'm looking to get a callback everytime someone selects something in a menu (every plugin + admin menu)
I've tried the commandlistener but it only gives me "menuselect xy" back.


The Callback should include the name of the selected menu object.


Is this Possible?
Is there a way to catch the MenuSelect globally?
Is there a forward for it?
Totenfluch is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 11-12-2015 , 23:37   Re: MenuSelect
Reply With Quote #2

Why do you want to do this?

(To answer your question: No, not to my knowledge, not unless in every plugin with a menu you add a function call in each menu's callback. Said function call would then tell one master plugin to fire a global forward or something.)
Potato Uno is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 11-13-2015 , 04:01   Re: MenuSelect
Reply With Quote #3

The original Idea was to log every Admin command. But then I realized the Admin menu doesn't send command -- atleast I can't get them. So I thought getting the pressed menu item in dem Admin menu would be enough to keep track of the admins action.


I really hope someone has a solution for my problem!
Totenfluch is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 11-13-2015 , 08:51   Re: MenuSelect
Reply With Quote #4

Under OnPlayerRunCmd check if the admin AND command have the ADMFLAG_GENERIC flag on them (using CheckCommandAccess), and if they do, log it to file (LogMessage)? I think that's cleaner.
Potato Uno is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 11-13-2015 , 09:03   Re: MenuSelect
Reply With Quote #5

I don't really understand how to get the command out of OnPlayerRunCmd :/

https://sm.alliedmods.net/new-api/sd...OnPlayerRunCmd
Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])

there's no String or command or anything in that that relates to something like "sm_admin, sm_kick totenfluch"
Help me out if I'm beeing noobish right now or just missing out the way to actually retrieve the command from this Action.

And I do appreciate your help a lot!
Totenfluch is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 11-13-2015 , 09:07   Re: MenuSelect
Reply With Quote #6

Sorry I meant to say OnClientCommand. Something like this should work:

PHP Code:
// Called when a client is sending a command:

public Action OnClientCommand(int iClientint nArgs)
{
    
// If this client is NOT an admin, exit:
    
if (!CheckCommandAccess(iClient"sm_1"ADMFLAG_GENERICtrue))
        return;
    
    
// Grab the command name.
    
GetCmdArg(0CmdNamesizeof(CmdName));
        
    
// The command has to prefix with SM:
    
if (StrContains(CmdName"sm_"false) != 0)
        return;
    
    
// This command must exist. Weed out invalid commands.
    
if (!CommandExists(CmdName))
        return;
    
    
// Grab the command argument:
    
GetCmdArgString(CmdArgssizeof(CmdArgs));
    
    
// Print out the usage of this command to the server's console and log it to the sourcemod logs:
    
GetClientName(iClientAdminNamesizeof(AdminName));
    
LogMessage("Admin \"%s<%d><[U:1:%d]>\" ran command \"%s %s\"."AdminNameGetClientUserId(iClient), GetSteamAccountID(iClient), CmdNameCmdArgs);

Potato Uno is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 11-13-2015 , 11:27   Re: MenuSelect
Reply With Quote #7

Thanks for your reply!


I think you misunderstood me <.<
Command logging works fine when they use chat or console commands.
The commands from menus are the ones I'm having trouble with.
For example when they use the admin menu and navigate to kick and select the player.

I get 4 callbacks

-> sm_admin
-> menuselect
-> menuselect
-> menuselect

and instead of menuselect(or smth like that) I want what they are actually using.

Last edited by Totenfluch; 11-13-2015 at 11:30.
Totenfluch is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 11-14-2015 , 15:21   Re: MenuSelect
Reply With Quote #8

can anyone atleast tell me if it's possible in general so that I don't waste time searching for a solution please ?
Totenfluch is offline
tommie113
AlliedModders Donor
Join Date: Oct 2013
Old 11-14-2015 , 15:45   Re: MenuSelect
Reply With Quote #9

Is this in your own plugin or as a plugin to control behaviour of another plugin.
If it's in your own you can get the 2 parameters from MenuAction_Select, which are client and the information that the menu has stored behind it's display value. For example, if you have a menu with clientid as info and name as display, it would store the clientid, not the displayed name.
__________________
No longer taking requests due to lack of time and interrest.
Only helping out with minor things through forum.
tommie113 is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 11-14-2015 , 16:52   Re: MenuSelect
Reply With Quote #10

Thanks for your reply!

To control the behaviour of another plugin and especially the Sourcemod Admin menu.

Last edited by Totenfluch; 11-14-2015 at 16:52.
Totenfluch 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 23:10.


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