AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Flashlight to Nightvision (https://forums.alliedmods.net/showthread.php?t=216547)

myusername 05-22-2013 13:27

Flashlight to Nightvision
 
Hello allied modders. If player in terrorist team then i want to bind F to nightvision. If he press F button then nightvision will toggle. And if in ct team then button F is impulse 100(flashlight).


Thank you.

Bos93 05-22-2013 13:52

Re: Flashlight to Nightvision
 
try:

PHP Code:

#include < amxmodx >
#include < cstrike >
#include < engine >

#define PLUGIN_NAME "x"
#define PLUGIN_VERSION "0.0.0.1"
#define PLUGIN_AUTHOR "x"

public plugin_init( ) 
{
    
register_plugin
    

        
PLUGIN_NAME
        
PLUGIN_VERSION
        
PLUGIN_AUTHOR 
    
);

    
register_impulse100"ClientCommand__Impulse" );
}

public 
ClientCommand__ImpulsepPlayer )
{
    if( !
is_user_alivepPlayer ) || cs_get_user_teampPlayer ) != CS_TEAM_T )
        return 
PLUGIN_CONTINUE;

    
cs_set_user_nvgpPlayer, .nvgoggles = !cs_get_user_nvgpPlayer ) );

    return 
PLUGIN_HANDLED;



ConnorMcLeod 05-22-2013 16:29

Re: Flashlight to Nightvision
 
This only set item to true or false, you need to execute engclient_cmd(id, "nightvision").

Bos93 05-22-2013 18:31

Re: Flashlight to Nightvision
 
yeah,my bad,thanks.

Jhob94 05-22-2013 20:08

Re: Flashlight to Nightvision
 
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <engine>

#define PLUGIN_NAME "x"
#define PLUGIN_VERSION "0.0.2"
#define PLUGIN_AUTHOR "x"

new only_disable_fl

public plugin_init()
{
    
register_plugin(PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_AUTHOR)
    
    
register_impulse(100"ClientCommand__Impulse")
    
    
only_disable_fl register_cvar("only_disable_fl""0"// Set 1 For Just Ignore When Terro Try To Use Flashlight
}

public 
ClientCommand__Impulse(id)
{
    if(!
is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_T)
        return 
PLUGIN_CONTINUE
    
    
else
    {
        if(
get_pcvar_num(only_disable_fl))
            
client_print(idprint_center"YOU ARENT ALLOWED TO USE FLASHLIGHT")
    
        else
        {
            if(!
cs_get_user_nvg(id))
                
cs_set_user_nvg(id1)
        
            
engclient_cmd(id"nightvision")
        }
    }
    
    return 
PLUGIN_HANDLED


I made cvar because no makes sence use flashlight to nightvision, since they can use n. So if you want just disable flashlight and shows message that they cant use flashlight set the cvar to 1.
If cvar is 0, it does nightvision instead of flashlight for Terrorists

myusername 05-23-2013 13:40

Re: Flashlight to Nightvision
 
Jhob94 version works like charm. Thank you.

@MOD: Solved.


All times are GMT -4. The time now is 16:20.

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