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
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-09-2013 , 23:45   Re: How to register a bool variable to catch flashlight on
Reply With Quote #1

Quote:
Originally Posted by a7811311622 View Post
register_event("Flashlight", ...) and read_data(1).
That event only updates the HUD. This will not do any good if you want to modify the how the flashlight works.
__________________
fysiks is offline
a7811311622
Member
Join Date: Apr 2010
Old 06-10-2013 , 00:51   Re: How to register a bool variable to catch flashlight on
Reply With Quote #2

Quote:
Originally Posted by fysiks View Post
That event only updates the HUD. This will not do any good if you want to modify the how the flashlight works.
Sorry, I'm confused about topic name, it looks like get but his code is set...
__________________
a7811311622 is offline
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 #3

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