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 , 10:13   Nightvision NEED SMALL HELP!
Reply With Quote #1

Hello all, how do i check if player has nightvision and also if it enabled?

I need this really really fast. Thank you
__________________
Rest in piece.

Last edited by myusername; 01-13-2014 at 10:14.
myusername is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-13-2014 , 11:23   Re: Nightvision NEED SMALL HELP!
Reply With Quote #2

Quote:
Originally Posted by myusername View Post
how do i check if player has nightvision
cs_get_user_nvg
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
myusername
Senior Member
Join Date: Aug 2012
Old 01-13-2014 , 13:48   Re: Nightvision NEED SMALL HELP!
Reply With Quote #3

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 #4

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
myusername
Senior Member
Join Date: Aug 2012
Old 01-14-2014 , 07:47   Re: Nightvision NEED SMALL HELP!
Reply With Quote #5

That gives me this error.
PHP Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c1997-2013 ITB CompuPhaseAMX Mod X Team

Error
Invalid symbol name "" on line 12
Error
Invalid symbol name "" on line 13
Error
Number of arguments does not match definition on line 68

3 Errors


Or did i put somewhere wrong? Here is the code.
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;

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

new 
bHasNVG33 ];

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;
    
set_user_nvg(id0)
}

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");

__________________
Rest in piece.
myusername is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-14-2014 , 13:00   Re: Nightvision NEED SMALL HELP!
Reply With Quote #6

You've put define and const with same name
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
myusername
Senior Member
Join Date: Aug 2012
Old 01-15-2014 , 10:04   Re: Nightvision NEED SMALL HELP!
Reply With Quote #7

Thank you Connor. Problem solved.

@MOD: Close.
__________________
Rest in piece.
myusername 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