Raised This Month: $ Target: $400
 0% 

How to register a bool variable to catch flashlight on


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-10-2013 , 01:11   Re: How to register a bool variable to catch flashlight on
Reply With Quote #1

Actually, register_impulse is bad, it catches when cmd.impulse is set in CmdStart and when you block it blocks the whole function and this is a bad point.
Also, there are other conditions in the game in order to take impulse in account, for example if you are in a switch weapon process, impulse is not taken in account, register_impulse doesn't take this feature in account.
Correct method (use more cpu though, but still acceptable) is :

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >

public plugin_init()
{
    
RegisterHam(Ham_Player_ImpulseCommands"player""OnCBasePlayer_ImpulseCommands"false);
}

public 
OnCBasePlayer_ImpulseCommandsid )
{
    if( 
pev(idpev_impulse) == 100 // game gonna take it in account and switch flashlight on or off
    
{
        
// if you want to block, set impulse to 0
        
set_pev(idpev_impulse0);
        return 
HAM_HANDLED;
    }
    return 
HAM_IGNORED;

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 16:21.


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