AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Hooking Buy Command (https://forums.alliedmods.net/showthread.php?t=295844)

Depresie 04-06-2017 06:55

Hooking Buy Command
 
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



OciXCrom 04-06-2017 06:59

Re: Hooking Buy Command
 
It can't be hooked like that. See this - https://forums.alliedmods.net/showthread.php?t=149380

Depresie 04-06-2017 07:02

Re: Hooking Buy Command
 
Ahm, fml... guess im gonna forget about my fancy buy menu and just remove the buy zone.. thanks

yas17sin 04-06-2017 07:14

Re: Hooking Buy Command
 
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

HamletEagle 04-06-2017 11:54

Re: Hooking Buy Command
 
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.

Depresie 04-06-2017 18:57

Re: Hooking Buy Command
 
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

yas17sin 04-06-2017 18:58

Re: Hooking Buy Command
 
1 Attachment(s)
try what i gived you :/

btw, this is the code that use "b" to open

HamletEagle 04-07-2017 08:40

Re: Hooking Buy Command
 
The solution that I proposed does exactly that. From the message function simply open your custom menu.

Depresie 04-07-2017 08:44

Re: Hooking Buy Command
 
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;



HamletEagle 04-07-2017 10:09

Re: Hooking Buy Command
 
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.


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

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