Raised This Month: $51 Target: $400
 12% 

Catching custom menus


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-02-2017 , 18:29   Catching custom menus
Reply With Quote #1

Is there any way to hook when a custom menu is opened or when a player selects an option from a custom menu ?

This doesn't seem to catch the custom ones, only the team menu from the game and probably the buy menu
Code:
register_message(get_user_msgid("ShowMenu"), "hook_message_menu_text")
__________________
Depresie is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 12-03-2017 , 07:22   Re: Catching custom menus
Reply With Quote #2

I'm not sure if you can hook custom menus, but probably not. Anyway you have another variant, make custom forwards.
KiLLeR. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-03-2017 , 09:41   Re: Catching custom menus
Reply With Quote #3

You have to use orpheu to hook pfnMessageBegin and check for ShowMenu.
PHP Code:
#include <amxmodx>
#include <orpheu>
#include <orpheu_stocks>

new gmsgShowMenu

public plugin_init()
{
    
OrpheuRegisterHook(OrpheuGetEngineFunction("pfnMessageBegin""MessageBegin"), "pfnMessageBegin"OrpheuHookPre)
    
gmsgShowMenu get_user_msgid("ShowMenu")
}

public 
pfnMessageBegin(MsgDestMsgTypeFloat:Origin[], id)
{
    if(
MsgType == gmsgShowMenu)
    {
        
//ShowMenu message is being sent
    
}

Do not send any kind of message in pfnMessageBegin hook.

Code:
{
    "name" : "MessageBegin",
    "library" : "engine",
    "arguments" :
    [
        {
            "type" : "int"
        },
		{
            "type" : "int"
        },
		{
            "type" : "pointer"
        },
		{
            "type" : "edict_s *"
        }
    ]
}
Place this file in addons/amxmodx/configs/orpheu/functions. The file should be called "MessageBegin".
You should notice that it does not use any kind of signature, so there's 0 chance for it to break on windows/linux, or if cs is updated.

If you are going to say you do not want to use orpheu and you want another way, don't bother to reply anymore. I'm sick of this bullshit.
__________________

Last edited by HamletEagle; 12-03-2017 at 09:44.
HamletEagle is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-03-2017 , 11:19   Re: Catching custom menus
Reply With Quote #4

Quote:
Do not send any kind of message in pfnMessageBegin hook.
That i figured out from last time

Quote:
If you are going to say you do not want to use orpheu and you want another way, don't bother to reply anymore. I'm sick of this bullshit.
Sadly i'm running ReHLDS, won't gonna bother with ReAPI tho.. i will just do the stuff i have to do in each menu manually since i'm not gonna have many
__________________
Depresie is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 12-03-2017 , 12:43   Re: Catching custom menus
Reply With Quote #5

well you should try playing with it.
PHP Code:
#include <amxmodx> 
#include <reapi> 

public plugin_init() { 
    
RegisterHookChain(RG_ShowMenu"ShowMenu")


public 
ShowMenu(indexbitSlotsiDisplayTimeiNeedMorepsztext) {


tho i`m not entirely sure if i hooked the right thing.
https://github.com/s1lentq/reapi/blo...edll_const.inc
__________________
retired chump

Last edited by DjSoftero; 12-04-2017 at 08:32.
DjSoftero is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-03-2017 , 13:11   Re: Catching custom menus
Reply With Quote #6

I'm working on a big pile of plugins.. and i would like to keep them fully compatible with both using and not using regame, in case shit hits the fan

So going with ReAPI or Orpheu right now doesn't seem like a smart move, because it is gonna get me stuck on one of the two configurations
__________________

Last edited by Depresie; 12-03-2017 at 13:13.
Depresie is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-03-2017 , 13:12   Re: Catching custom menus
Reply With Quote #7

As I said, pfnMessageBegin does not need any byte signature. I would try the above plugin even if you are using rehlds, maybe it will work.
Give it a shot.

Or you can do something else, make a define like #define USING_REGAMEDLL. Then when you hook ShowMenu check if USING_REGAMEDLL is defined and hook with regamedll, else hook with orpheu. It's minimal code and it makes sure it will work on both dlls.
__________________

Last edited by HamletEagle; 12-03-2017 at 13:14.
HamletEagle is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-03-2017 , 13:27   Re: Catching custom menus
Reply With Quote #8

Using just Orpheu would be better, less to write and worry about
I Will give it a try this week, thanks hamlet
__________________

Last edited by Depresie; 12-03-2017 at 13:28.
Depresie is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-03-2017 , 13:30   Re: Catching custom menus
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
As I said, pfnMessageBegin does not need any byte signature. I would try the above plugin even if you are using rehlds, maybe it will work.
Give it a shot.

Or you can do something else, make a define like #define USING_REGAMEDLL. Then when you hook ShowMenu check if USING_REGAMEDLL is defined and hook with regamedll, else hook with orpheu. It's minimal code and it makes sure it will work on both dlls.
Or even better use set_module_filter() to detect at runtime if there's ReAPI running on the server. No recompilation needed.

Last edited by klippy; 12-03-2017 at 13:30.
klippy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-03-2017 , 17:13   Re: Catching custom menus
Reply With Quote #10

The things is, i don't have the time to write everything using two different methods, especially to test their functionality..

So it is safer to go with a method that is compatible with both
__________________
Depresie 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 07:20.


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