|
发表于 2024-6-6 00:41:15
|
显示全部楼层
来自 中国–四川–成都
- #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(255)
- write_byte(128)
- 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(255)
- write_byte(128)
- write_byte(128)
- write_byte(73)
- message_end()
- }
复制代码
代码来源:https://forums.alliedmods.net/showthread.php?t=181953 |
|