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 bHasNVG[ 33 ];
new gMessageNVG;
public plugin_init()
{
gMessageNVG = get_user_msgid( "NVGToggle" );
}
public zp_fw_core_infect_post(id, attacker)
{
EnableNightVision(id)
}
public zp_fw_core_cure_post(id, attacker)
{
DisableNightVision(id)
}
EnableNightVision(id)
{
bHasNVG[ id ] = true;
set_user_nvg( id, 1 );
client_cmd(id, "nightvision")
}
DisableNightVision(id)
{
bHasNVG[ id ] = false;
remove_user_nvg( id );
}
stock set_user_nvg( index, nvgoggles = 1 )
{
if( nvgoggles )
{
set_pdata_int( index, OFFSET_NVGOGGLES, get_pdata_int( index, OFFSET_NVGOGGLES ) | HAS_NVGS );
}
else
{
set_pdata_int( index, OFFSET_NVGOGGLES, get_pdata_int( index, OFFSET_NVGOGGLES ) & ~HAS_NVGS );
}
}
stock remove_user_nvg( index )
{
new iNvgs = get_pdata_int( index, OFFSET_NVGOGGLES, LINUX_OFFSET_DIFF );
if( !iNvgs )
{
return;
}
if( iNvgs & USES_NVGS )
{
emessage_begin( MSG_ONE_UNRELIABLE, gMessageNVG, _, index );
ewrite_byte( 0 );
emessage_end();
}
set_pdata_int( index, OFFSET_NVGOGGLES, 0, LINUX_OFFSET_DIFF );
}
__________________