Raised This Month: $ Target: $400
 0% 

Solved Hooking Buy Command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-06-2017 , 06:55   Hooking Buy Command
Reply With Quote #1

For some reason the hooks on the buy command don't work, did i do something wrong ?
And yes, i am in the buy zone when calling the commands
Seems like VGUI menu opens fine, even after returning the command handled, also there is no print chat message

Using the latest dev version

PHP Code:
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("buy""hookbuycmd")
}

public 
hookbuycmd(id)
{
    
client_print(0print_chat"blabla")

    return 
PLUGIN_HANDLED

__________________

Last edited by Depresie; 04-06-2017 at 07:02.
Depresie is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-06-2017 , 06:59   Re: Hooking Buy Command
Reply With Quote #2

It can't be hooked like that. See this - https://forums.alliedmods.net/showthread.php?t=149380
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-06-2017 , 07:02   Re: Hooking Buy Command
Reply With Quote #3

Ahm, fml... guess im gonna forget about my fancy buy menu and just remove the buy zone.. thanks
__________________
Depresie is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 04-06-2017 , 07:14   Re: Hooking Buy Command
Reply With Quote #4

i know you tag the post as solved, but i want to tel you this i saw in a code and it was working acctualy the buymenu was closed and one in the code replace it but it may not considre as an slowhack :
Spoiler
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality

Last edited by yas17sin; 04-06-2017 at 07:16.
yas17sin is offline
Send a message via ICQ to yas17sin
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-06-2017 , 11:54   Re: Hooking Buy Command
Reply With Quote #5

You want to block the buy menu? Without removing the buy zone you can hook "StatusIcon" message, filter for "buyzone" and alter m_fClientMapZone offset(234 or 235, can't remember) by removing CS_MAPZONE_BUY flag.
__________________

Last edited by HamletEagle; 04-06-2017 at 12:02.
HamletEagle is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-06-2017 , 18:57   Re: Hooking Buy Command
Reply With Quote #6

What i wanted to do actually was to block the vgui menu and all buy commands, and open another menu instead by pressing the "b" button while in the buy zone
__________________
Depresie is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 04-06-2017 , 18:58   Re: Hooking Buy Command
Reply With Quote #7

try what i gived you :/

btw, this is the code that use "b" to open
Attached Files
File Type: sma Get Plugin or Get Source (zp_buymenu.sma - 706 views - 37.9 KB)
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality

Last edited by yas17sin; 04-06-2017 at 18:59.
yas17sin is offline
Send a message via ICQ to yas17sin
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-07-2017 , 08:40   Re: Hooking Buy Command
Reply With Quote #8

The solution that I proposed does exactly that. From the message function simply open your custom menu.
__________________
HamletEagle is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-07-2017 , 08:44   Re: Hooking Buy Command
Reply With Quote #9

I guess this is what you meant, but the message is printed every one second while in the buy zone.. how am i supposed to trigger it only when the "b" button is pressed ?

PHP Code:
public en_msg_buy_zone(msg_idmsg_destmsg_entity)
{
    static 
szIcon[8];
    
get_msg_arg_string(2szIcon7);

    if(
equal(szIcon"buyzone") && get_msg_arg_int(1))
    {
        
set_pdata_int(msg_entity235get_pdata_int(msg_entity235) & ~(1<<0));
        
client_print(0print_chat"blabla 1")
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;

__________________

Last edited by Depresie; 04-07-2017 at 09:18.
Depresie is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-07-2017 , 10:09   Re: Hooking Buy Command
Reply With Quote #10

Then create an on-off system, like a bool which is set to true the first time when message is fired and set to false when user go out of buyzone. There are other solutions too, like blocking buy commands.
__________________

Last edited by HamletEagle; 04-07-2017 at 10:09.
HamletEagle 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 18:03.


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