Monthly Target: $400 Donations: $602
 150% 

hook/replace buy menu in cs 1.6


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-28-2011 , 00:37   hook/replace buy menu in cs 1.6
Reply With Quote #1

I thought this should have been done before, yet my search returned no results. I want to close the buy menu right away, and instead launch a new menu. I've seen similar things done with the submenus for weapon categories for both vgui menu and old-style text menu (good example is this http://forums.alliedmods.net/showthread.php?t=50926) But I want to do it with the main buy menu, and replace it with my own text buy menu with custom weapons and items. Can I please have a code example?
__________________
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-28-2011 , 00:40   Re: hook/replace buy menu in cs 1.6
Reply With Quote #2

My jCTF mod ( http://forums.alliedmods.net/showthread.php?t=132115 ) hooks every buy method and overrides it with a new buy menu.

However I can't override VGUI without changing client settings, so that's a bummer... but VGUI users can't hack it tough, they buy the weapons at my defined prices.
__________________
Hunter-Digital is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-28-2011 , 01:17   Re: hook/replace buy menu in cs 1.6
Reply With Quote #3

I see, btw the code of the plugin that I linked to in the first post gives the possibility to override the submenus of the vgui buy menu (if modified a little bit), so I think there should be a way to override the main buy menu as well. I managed to replace the vgui team/class selection menu with my own, only if I knew how to do the same with the main buy menu...

So I was thinking, I used this method for the vgui team select menu
PHP Code:
public plugin_init()
{
    
register_message(get_user_msgid("VGUIMenu"), "message_VGUIMenu");
}

public 
message_VGUIMenu(iMsgidiDestid)
{
    if(
get_msg_arg_int(1) != VGUI_JOIN_TEAM_NUM)
    {
        return 
PLUGIN_CONTINUE;
    }

    
//block message, show new menu, after selection finished - unblock message

, and it works perfectly, but I don't know where that VGUI_JOIN_TEAM_NUM is defined, and I suspect that there should be a define for the buymenu as well...
If you haven't looked at the code of the plugin in the first post, it has
PHP Code:
    //VGUI Menus
    
register_menucmd(-29,keys,"hook_menu1"//buy pistols
    
register_menucmd(-30,keys,"hook_menu2"//buy shotguns
    
register_menucmd(-32,keys,"hook_menu3"//buy smgs
    
register_menucmd(-31,keys,"hook_menu4"//buy rifles
    
register_menucmd(-33,keys,"hook_menu5"//buy machine gun 
so there should be an offset for the main buymenu as well, I hope. If anyone know how to get it to work with either of these 2 ways or a new way, please share it
__________________

Last edited by SeriousSam; 04-28-2011 at 01:40.
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-28-2011 , 07:28   Re: hook/replace buy menu in cs 1.6
Reply With Quote #4

AFAIK "VGUIMenu" message is not triggered when a player opens buy menu.

If you find a way to overwrite VGUI buy menu somehow (without altering client settings), please do post it here 'cause I'm really curious :}
__________________
Hunter-Digital is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-28-2011 , 13:01   Re: hook/replace buy menu in cs 1.6
Reply With Quote #5

Darn, if it's not triggered my idea goes to hell... I think I will just use restmenu.amxx to restrict everything in the buymenu, and make a new menu that is opened with a console command, and a message in the chat to bind that command, I think this would be the best way, but I know there will be still noobs that will not read the message and bitch about not being able to buy...
__________________
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-28-2011 , 14:41   Re: hook/replace buy menu in cs 1.6
Reply With Quote #6

You can still buy using VGUI by registering weapon names as client console commands (see my mod's source).
__________________
Hunter-Digital is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-28-2011 , 14:50   Re: hook/replace buy menu in cs 1.6
Reply With Quote #7

SeriousSam
Just override the buy command.
__________________

SonicSonedit is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-28-2011 , 14:56   Re: hook/replace buy menu in cs 1.6
Reply With Quote #8

Sonic, when using VGUI, the "buy" command is not sent to the server, VGUI only sends weapon names as console commands to the server (eg: m4a1, awp, usp, etc).
And you can buy using those commands alone, so you should hook/block them anyway.
__________________
Hunter-Digital is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-28-2011 , 15:07   Re: hook/replace buy menu in cs 1.6
Reply With Quote #9

Hunter-Digital
Hmm, I didn't test it with VGUI. Anyway, since you can't create custom VGUI, you can just disable it and live happily - you have nothing to replace it with anyway.
__________________

SonicSonedit is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-28-2011 , 15:13   Re: hook/replace buy menu in cs 1.6
Reply With Quote #10

You also can't disable it without altering player configs, read the previous posts.
__________________
Hunter-Digital is offline
Reply


Thread Tools
Display Modes

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 00:24.


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