RG_CBasePlayer_ImpulseCommands problem

Сообщения
278
Реакции
137
Hi, I wonder something about this command. When I use "client_impulse", it works perfect. But when I change to RG_CBasePlayer_ImpulseCommands, i have a problem.
When I use "impulse 201", it starts and never stops. How I can make it stop?

Код:
#include <amxmodx>
#include <engine>
#include <reapi>

public plugin_init() {
    RegisterHookChain(RG_CBasePlayer_ImpulseCommands, "CBasePlayer_ImpulseCommands", .post=false);
}

/* IT NEVER STOPS AND ALWAYS WRITE "Lololol" */
public CBasePlayer_ImpulseCommands(const id)
{
    static impulse;
    impulse = get_entvar(id, var_impulse);

    if(impulse == 201)
    {
        client_print(id, print_chat, "Lololol");
        return HC_SUPERCEDE;
    }
    return HC_CONTINUE;
}

/* Working perfecto ! :) */

public client_impulse(id, impulse)
{
    if(impulse == 201)
    {
        client_print(id, print_chat, "Lololol");
        return 1;
    }
    return 0;
}
 
Сообщения
1,419
Реакции
2,508
Помог
59 раз(а)
It works as expected. Why should client_print(id, print_chat, "Lololol"); not work? You print a message before you supercede.
 
Сообщения
278
Реакции
137
w0w,
It works anyway, it does not stop writing "Lololol". When you use "impulse 201", it always continues. It force you to use impulse 201.
Lemme explain;

Код:
+ w client_impulse;
Player used impulse 201
Lololol
Not sprayed [return 1]

+ w RG_CBasePlayer_ImpulseCommand;
Player used impulse 201
Lololol
Not sprayed [return 1]
Lololol
Not sprayed [return 1]
Lololol
Not sprayed [return 1]
Lololol
Not sprayed [return 1]
... (continues)
 
Сообщения
1,419
Реакции
2,508
Помог
59 раз(а)
Yes, it's the way this/each hook works.
 
Сообщения
278
Реакции
137
Can't we make it working as client_impulse?
For example; I am using client_impulse in "CS GO Spray plugin" and not able to change it to reapi. Weird.
 
Сообщения
576
Реакции
1,003
Помог
18 раз(а)
You should set var_impulse to 0 before supercede.
 
Сообщения
278
Реакции
137
@Mistrick,
So, for optimizing which one should I use?
Engine client_impulse or Reapi CBasePlayer....blabla
Is there any difference?

Код:
#include <engine>
#include <reapi>

public plugin_init() {
    RegisterHookChain(RG_CBasePlayer_ImpulseCommands, "CBasePlayer_ImpulseCommands", .post=false);
}

public CBasePlayer_ImpulseCommands(const id)
{
    static impulse;
    impulse = get_entvar(id, var_impulse);

    if(impulse == 201)
    {
        client_print(id, print_chat, "Lololol");
        set_entvar(id, var_impulse, 0);
        return HC_SUPERCEDE;
    }
    return HC_CONTINUE;
}

public client_impulse(id, impulse)
{
    if(impulse == 201)
    {
        client_print(id, print_chat, "Lololol");
        return 1;
    }
    return 0;
}
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу