Raised This Month: $ Target: $400
 0% 

Custom nightvision problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 09-19-2011 , 09:22   Custom nightvision problem
Reply With Quote #1

OK, I have created custom nightvision which consists of TE_DLIGHT + once sent ScreenFade message.But I am facing one problem, my nightvision conflicts with flashbangs.Whenever player is flashed, he can just turn on my nightvision and flash effect disappears.How can i prevent that?

I thought about blocking ScreenFade effect when player is flashed, but more problem appears.How to get whenever player is flashed.

I suppose through ScreenFade event/message hooking.Or maybe there is any private data offset, something like m_fIsFlashed?

This is piece of code I have right now:

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

new bool:g_fNightVisionEnabled[ 33 ];

const FFADE_STAYOUT = 0x0004;

#define TASK_NVG    19368
#define ID_NVG    ( taskid - TASK_NVG )

public plugin_init( )
{
    register_clcmd( "nightvision",    "_nightvision_"    );
}

// ... code

public _nightvision_( Player )
{
    if( !FBitSet( g_afPlayerFlags[ Player ], PF_ALIVE )
        return PLUGIN_CONTINUE;
        
    if( FBitSet( g_afPlayerFlags[ Player ], PF_ZOMBIE )
    {
        g_fNightVisionEnabled[ Player ]    = !( g_fNightVisionEnabled[ Player ] );
        
        if( g_fNightVisionEnabled[ Player ] )
        {
            MSG_ScreenFade( Player, 1 << 12, 1 << 12, FFADE_STAYOUT, 253, 95, 95, 125 );
        
            set_task( 0.1, "TASK_EnableNVG", Player + TASK_NVG, _, _, "b" );
            emit_sound( Player, CHAN_ITEM, "items/nvg_on.wav", 0.94, ATTN_NORM, 0, 98 );
        }
        else
        {
            emit_sound( Player, CHAN_ITEM, "items/nvg_off.wav", 0.94, ATTN_NORM, 0, 98 );
        }
        
        return PLUGIN_HANDLED;
    }
    
    return PLUGIN_CONTINUE;
}

// ... more code...

public TASK_EnableNVG( taskid )
{
    if( !FBitSet( g_afPlayerFlags[ ID_NVG ], PF_ALIVE ) || !g_fNightVisionEnabled[ ID_NVG ] )
    {
        MSG_ScreenFade( ID_NVG );
        
        remove_task( ID_NVG );
        return;
    }

    EFX_DLight( MSG_ONE, ID_NVG, 150, 253, 95, 95, 1, 1 );
}

EFX_DLight( iDest, Player, iRadius, iRed, iGreen, iBlue, iLife, iDecayRate )
{
    static Float:vOrigin[ 3 ];
    ExecuteHam( Ham_EyePosition, Player, vOrigin );

    engfunc( EngFunc_MessageBegin, iDest, SVC_TEMPENTITY, vOrigin, 0 );
    write_byte( TE_DLIGHT );
    engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
    engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
    engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] );
    write_byte( iRadius );
    write_byte( iRed );
    write_byte( iGreen );
    write_byte( iBlue );
    write_byte( iLife );
    write_byte( iDecayRate );
    message_end( );
}

MSG_ScreenFade( Player, iDuration = 0, HoldTime = 0, iFlags = 0, iRed = 0, iGreen = 0, iBlue = 0, iAlpha = 0 )
{
    message_begin( MSG_ONE, gmsgScreenFade, _, Player );
    write_short( iDuration );
    write_short( HoldTime );
    write_short( iFlags );
    write_byte( iRed );
    write_byte( iGreen );
    write_byte( iBlue );
    write_byte( iAlpha );
    message_end( );
}
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
 



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 19:37.


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