Raised This Month: $ Target: $400
 0% 

Nightvision NEED SMALL HELP!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
myusername
Senior Member
Join Date: Aug 2012
Old 01-13-2014 , 13:48   Re: Nightvision NEED SMALL HELP!
Reply With Quote #1

Yes cs_set_user_nvg( id, 1 ) works but it has a problem.

Example on zombie server: Human has a nightvision. And it was enabled. Then human becomes zombie.
Problem: I give nightvision on zombie infect (and its enabled by auto like client_cmd nightvision). So if human has nightvision it will turned off because off i've enabling nightvision in client_cmd.

So how can i solve this?
I think i need to check human has nightvision then if has remove and regive? Also how can i give nightvision to spec's?


Here is the code ive got so far... (some code token from drop nvg)
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zp50_core>

#define HAS_NVGS        (1<<0)
#define USES_NVGS        (1<<8)
#define get_user_nvg(%1)    (get_pdata_int(%1,OFFSET_NVGOGGLES) & HAS_NVGS)

const OFFSET_NVGOGGLES 129;
const 
LINUX_OFFSET_DIFF 5;

new 
bHasNVG33 ];
new 
gMessageNVG;

public 
plugin_init()   
{
    
gMessageNVG get_user_msgid"NVGToggle" );


public 
zp_fw_core_infect_post(idattacker)
{
    
EnableNightVision(id)
}

public 
zp_fw_core_cure_post(idattacker)
{
    
DisableNightVision(id)
}

EnableNightVision(id)
{        
    
bHasNVGid ] = true;
    
set_user_nvgid);
    
client_cmd(id"nightvision")
}

DisableNightVision(id)
{
    
bHasNVGid ] = false;
    
remove_user_nvgid );
}

stock set_user_nvgindexnvgoggles )
{
    if( 
nvgoggles )
    {
        
set_pdata_intindexOFFSET_NVGOGGLESget_pdata_intindexOFFSET_NVGOGGLES ) | HAS_NVGS );
    }

    else
    {
        
set_pdata_intindexOFFSET_NVGOGGLESget_pdata_intindexOFFSET_NVGOGGLES ) & ~HAS_NVGS );
    }
}
    
stock remove_user_nvgindex )
{
    new 
iNvgs get_pdata_intindexOFFSET_NVGOGGLESLINUX_OFFSET_DIFF );

    if( !
iNvgs )
    {
        return;
    }

    if( 
iNvgs USES_NVGS )
    {
        
emessage_beginMSG_ONE_UNRELIABLEgMessageNVG_index );
        
ewrite_byte);
        
emessage_end();
    }

    
set_pdata_intindexOFFSET_NVGOGGLES0LINUX_OFFSET_DIFF );

__________________
Rest in piece.

Last edited by myusername; 01-13-2014 at 13:51.
myusername is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-14-2014 , 00:17   Re: Nightvision NEED SMALL HELP!
Reply With Quote #2

Try this :

Instead of remove_user_nvg, use set_user_nvg(id, 0)
To force nvg ON, use set_user_nvg(id, 1, 1)

PHP Code:
const HAS_NVGS 1<<0;
const 
USES_NVGS 1<<8;
const 
OFFSET_NVGOGGLES 129;
const 
m_flNextNightVisionTime 619

set_user_nvg(idnvgoggles 0turnon 0)
{
    new 
nvg get_pdata_int(idOFFSET_NVGOGGLES);
    if( 
nvgoggles )
    {
        if( 
nvg HAS_NVGS )
        {
            if( 
turnon && ~nvg USES_NVGS )
            {
                
force_client_use_nvg(id);
            }
        }
        else
        {
            
set_pdata_int(idOFFSET_NVGOGGLESHAS_NVGS);
            
force_client_use_nvg(id);
        }
    }
    else
    {
        if( 
nvg HAS_NVGS )
        {
            if( 
nvg USES_NVGS )
            {
                
force_client_use_nvg(id);
            }
            
set_pdata_int(OFFSET_NVGOGGLES0);
        }
    }
}

force_client_use_nvg(id)
{
    
set_pdata_float(idm_flNextNightVisionTime0.0);
    
engclient_cmd(id"nightvision");

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-14-2014 at 00:18.
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 10:12.


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