AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can't hook +use on ReHLDS (https://forums.alliedmods.net/showthread.php?t=318645)

Leonidddd 09-11-2019 21:12

Can't hook +use on ReHLDS
 
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 09-11-2019 21:36

Re: Can't hook +use on ReHLDS
 
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. :roll:

Leonidddd 09-11-2019 22:25

Re: Can't hook +use on ReHLDS
 
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 09-13-2019 10:03

Re: Can't hook +use on ReHLDS
 
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:):lol:


.


All times are GMT -4. The time now is 17:26.

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