Good night all i have problème with the flashlight only ct his flashlight hasn't the multicolor (red,blue,green,normal)
Can you help me for correct it and lock nightvision for CT team
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#define MAX_PLAYERS 32
new bool:hasLight[32]
new bool:g_restart_attempt[MAX_PLAYERS + 1]
new flashlight[33];
public plugin_init()
{
//event
register_event("ResetHUD", "event_hud_reset", "be")
register_event("TextMsg", "event_restart_attempt", "a", "2=#Game_will_restart_in")
register_event("Flashlight","event_flashlight","b");
//cvar
register_cvar("flashlight_custom","1");
register_cvar("flashlight_r","100");
register_cvar("flashlight_g","100");
register_cvar("flashlight_b","100");
register_cvar("flashlight_radius","9");
register_cvar("flashlight_decay","60");
register_clcmd("fullupdate", "clcmd_fullupdate")
}
public clcmd_fullupdate()
{
return PLUGIN_HANDLED_MAIN
}
public event_restart_attempt()
{
new players[32], num
get_players(players, num, "a")
for (new i; i < num; ++i)
g_restart_attempt[players[i]] = true
}
public event_hud_reset(id)
{
if (g_restart_attempt[id])
{
g_restart_attempt[id] = false
return
}
event_player_spawn(id)
}
public event_flashlight(id)
{
if(!get_cvar_num("flashlight_custom"))
{
return;
}
if(flashlight[id])
{
flashlight[id] = 0;
}
else
{
flashlight[id] = 1;
}
message_begin(MSG_ONE,get_user_msgid("Flashlight"),{0,0,0},id);
write_byte(flashlight[id]);
write_byte(100);
message_end();
entity_set_int(id,EV_INT_effects,entity_get_int(id,EV_INT_effects) & ~EF_DIMLIGHT);
}
public client_PreThink(id)
{
if(!get_cvar_num("flashlight_custom"))
{
return;
}
if(flashlight[id])
{
new origin[3];
get_user_origin(id,origin,3);
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(27); // TE_DLIGHT
write_coord(origin[0]); // X
write_coord(origin[1]); // Y
write_coord(origin[2]); // Z
write_byte(get_cvar_num("flashlight_radius")); // radius
write_byte(get_cvar_num("flashlight_r")); // R
write_byte(get_cvar_num("flashlight_g")); // G
write_byte(get_cvar_num("flashlight_b")); // B
write_byte(1); // life
write_byte(get_cvar_num("flashlight_decay")); // decay rate
message_end();
}
}
public event_player_spawn(id)
{
hasLight[id] = false
}
public client_impulse(id, impulse)
{
if(impulse != 100)
return PLUGIN_HANDLED_MAIN
if(!hasLight[id] && cs_get_user_team(id) == CS_TEAM_T)
{
return PLUGIN_HANDLED_MAIN
}
return PLUGIN_CONTINUE
}