Raised This Month: $32 Target: $400
 8% 

Can't hook +use on ReHLDS


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Leonidddd
Member
Join Date: Apr 2012
Old 09-11-2019 , 21:12   Can't hook +use on ReHLDS
Reply With Quote #1

Hi there!

I was writing a one simple plugin for a hooking +use, but stuck on the strange problem. I've tested the same code on HLDS and there was no any problems, but I'm using ReHLDS(with ReGamedll&Reunion&Reapi of the last versions) now and it seems doesn't support such kind of code, do u have any ideas how to pass this problem?


PHP Code:
new bool:ButtonPressed[MAX_PLAYERS+1]; 
in plugin_init():
PHP Code:
register_forward(FM_CmdStart"CmdStart_Handler"); 
And here's a code:

PHP Code:
public CmdStart_Handler(idUC_Handle){

    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;
        
    static 
OldButtonOldButton =  pev(idpev_oldbuttons);
    static 
NewButtonNewButton pev(idpev_button);
    
    if(
ButtonPressed[id] && NewButton IN_USE)
        return 
FMRES_IGNORED;
        
    if(!
ButtonPressed[id] && OldButton IN_USE)
        return 
FMRES_IGNORED;

    if(
OldButton IN_USE){

        
server_print("Unsued");

        
ButtonPressed[id] = false;
    }
    if(
NewButton IN_USEserver_print("Used"), ButtonPressed[id] = true;
    
    return 
FMRES_IGNORED;

I've tried to use reapi's functions such like
get_entvar(id, var_button) and get_entvar(id, var_oldbuttons), but the result was the same.

Also code smth like:
PHP Code:
   if ((NewButton IN_USE) && !(OldButton IN_USE))
        
server_print("Used");

   if (!(
NewButton IN_USE) && (OldButton IN_USE))
        
server_print("Unsued"); 
Doesn't work too... . The server is clean and have no any unstandart plugins.
Also, I have amxx 1.9.0 version.


Well, thx for the attention, I hope u could help me to find the solution.
Leonidddd is offline
Leonidddd
Member
Join Date: Apr 2012
Old 09-11-2019 , 21:36   Re: Can't hook +use on ReHLDS
Reply With Quote #2

After some tests with a lot of the logs it seems like

PHP Code:
   pev(idpev_oldbuttons) == pev(idpev_button
all time while a button is pressed, it doesn't remembering oldbuttons after unpressing and the first pressing of button has equal to oldbutton already, but it mustn't work like that... strange.

Correct me if I'm wrong.
Leonidddd is offline
Leonidddd
Member
Join Date: Apr 2012
Old 09-11-2019 , 22:25   Re: Can't hook +use on ReHLDS
Reply With Quote #3

The solution:

PHP Code:
public CmdStart_Handler(idUC_Handle){

    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;

    static 
OldButtonNewButton;

    
OldButton get_member(idm_afButtonReleased);
    
NewButton get_member(idm_afButtonPressed);
    
    if(
ButtonPressed[id] && NewButton IN_USE)
        return 
FMRES_IGNORED;
        
    if(!
ButtonPressed[id] && OldButton IN_USE)
        return 
FMRES_IGNORED;

    if(
OldButton IN_USE){

        
server_print("Unsued");

        
ButtonPressed[id] = false;
    }
    if(
NewButton IN_USEserver_print("Used"), ButtonPressed[id] = true;
    
    return 
FMRES_IGNORED;

Leonidddd is offline
Leonidddd
Member
Join Date: Apr 2012
Old 09-13-2019 , 10:03   Re: Can't hook +use on ReHLDS
Reply With Quote #4

UDP:

PHP Code:
    /*
    * Description:      Called when a player press use and if a suitable candidate is not found.
    * Return type:      void
    * Params:           (const this)
    */
    
RG_CBasePlayer_UseEmpty 

facepalm


.
Leonidddd 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 21:23.


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