AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hook/replace buy menu in cs 1.6 (https://forums.alliedmods.net/showthread.php?t=155902)

SeriousSam 04-28-2011 00:37

hook/replace buy menu in cs 1.6
 
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?

Hunter-Digital 04-28-2011 00:40

Re: hook/replace buy menu in cs 1.6
 
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.

SeriousSam 04-28-2011 01:17

Re: hook/replace buy menu in cs 1.6
 
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 :)

Hunter-Digital 04-28-2011 07:28

Re: hook/replace buy menu in cs 1.6
 
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 :}

SeriousSam 04-28-2011 13:01

Re: hook/replace buy menu in cs 1.6
 
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...

Hunter-Digital 04-28-2011 14:41

Re: hook/replace buy menu in cs 1.6
 
You can still buy using VGUI by registering weapon names as client console commands (see my mod's source).

SonicSonedit 04-28-2011 14:50

Re: hook/replace buy menu in cs 1.6
 
SeriousSam
Just override the buy command.

Hunter-Digital 04-28-2011 14:56

Re: hook/replace buy menu in cs 1.6
 
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.

SonicSonedit 04-28-2011 15:07

Re: hook/replace buy menu in cs 1.6
 
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.

Hunter-Digital 04-28-2011 15:13

Re: hook/replace buy menu in cs 1.6
 
You also can't disable it without altering player configs, read the previous posts.


All times are GMT -4. The time now is 03:41.

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