AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bug Night Vision ( no lag) (https://forums.alliedmods.net/showthread.php?t=334003)

zollymaN 08-22-2021 19:16

Bug Night Vision ( no lag)
 
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

Celena Luna 08-22-2021 22:00

Re: Bug Night Vision ( no lag)
 
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


All times are GMT -4. The time now is 02:31.

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