Raised This Month: $32 Target: $400
 8% 

Bug Night Vision ( no lag)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zollymaN
Junior Member
Join Date: Aug 2021
Location: Romania
Old 08-22-2021 , 19:16   Bug Night Vision ( no lag)
Reply With Quote #1

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

new const PLUGIN_VERSION[] = "1.0"

new g_nightvision[33]

new g_default_map_light[32]

new g_fwLightStyle

new g_msgScreenFade

public plugin_precache()
{
        register_plugin("New NightVision", PLUGIN_VERSION, "Fai")
       
        g_fwLightStyle = register_forward(FM_LightStyle, "fw_LightStyle")
}

public plugin_init()
{
        unregister_forward(FM_LightStyle, g_fwLightStyle)
       
        g_msgScreenFade = get_user_msgid("ScreenFade")
       
        register_message(g_msgScreenFade, "message_screenfade")
        register_message(get_user_msgid("NVGToggle"), "message_nvgtoggle")
       
        set_cvar_num("sv_skycolor_r", 0)
        set_cvar_num("sv_skycolor_g", 0)
        set_cvar_num("sv_skycolor_b", 0)
}

public fw_LightStyle(style, const val[])
{
        if (!style)
                copy(g_default_map_light, charsmax(g_default_map_light), val)
}

public message_screenfade(msg_id, msg_dest, msg_entity)
{
        if (!g_nightvision[msg_entity])
                return PLUGIN_CONTINUE;
       
        if (get_msg_arg_int(4) != 255 || get_msg_arg_int(5) != 255 || get_msg_arg_int(6) != 255 || get_msg_arg_int(7) < 200)
                return PLUGIN_CONTINUE;
       
        remove_task(msg_entity)
        set_task(get_msg_arg_int(1) / 4096.0, "task_restore_screenfade", msg_entity)
       
        return PLUGIN_CONTINUE;
}

public message_nvgtoggle(msg_id, msg_dest, msg_entity)
{
        static flag
        flag = get_msg_arg_int(1)
       
        message_begin(MSG_ONE_UNRELIABLE, SVC_LIGHTSTYLE, _, msg_entity)
        write_byte(0)
       
        if (flag)
                write_string("#")
        else
                write_string(g_default_map_light)
       
        message_end()
       
        if (!task_exists(msg_entity))
        {
                message_begin(MSG_ONE, g_msgScreenFade, _, msg_entity)
                write_short((1<<12))
                write_short(0)
                write_short(0x0004)
               
                if (flag)
                {
                        write_byte(128)
                        write_byte(255)
                        write_byte(128)
                        write_byte(73)
                }
                else
                {
                        write_byte(0)
                        write_byte(0)
                        write_byte(0)
                        write_byte(0)
                }
               
                message_end()
        }
       
        g_nightvision[msg_entity] = flag
       
        return PLUGIN_HANDLED;
}

public task_restore_screenfade(id)
{
        if (!g_nightvision[id])
                return;
       
        message_begin(MSG_ONE, g_msgScreenFade, _, id)
        write_short((1<<12))
        write_short(0)
        write_short(0x0004)
        write_byte(128)
        write_byte(255)
        write_byte(128)
        write_byte(73)
        message_end()
}
so I don't understand .. press "N" to start night vision, but after a few seconds it gets dark and remains green

image here -> https://imgur.com/a/wYRLedA

Last edited by zollymaN; 08-22-2021 at 19:17.
zollymaN is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 08-22-2021 , 22:00   Re: Bug Night Vision ( no lag)
Reply With Quote #2

You should post this in Suggest/Request (is this the 3rd time I told you this?)

Anyway, it is because Zombie Plague lighting which update every 5 seconds so it override the new lighting from the nightvision.

There is nothing much you can do unless you modified the lighting of ZP
__________________
My plugin:
Celena Luna is offline
Reply


Thread Tools
Display Modes

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 08:35.


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