Simple request, without content...
Flash duration change depend player distance and view angle.
But I give you three (mode) options.
cvars:
Code:
//Plugin disabled
sm_flashbang_duration_mode 0
sm_flashbang_duration 1.0
Code:
//Change duration by percent, 1.2 = 120% or 0.8 = 80%
sm_flashbang_duration_mode 0
sm_flashbang_duration 1.2
Code:
//Add given value as seconds in duration 2 = +2 seconds or -1 = -1 seconds
sm_flashbang_duration_mode 1
sm_flashbang_duration 2
Code:
//Set solid duration time in seconds 6 = 6 seconds
sm_flashbang_duration_mode 2
sm_flashbang_duration 6
PHP Code:
/*
Server event "flashbang_detonate", Tick 3748:
- "userid" = "2"
- "entityid" = "297"
- "x" = "125.24"
- "y" = "2512.63"
- "z" = "-114.73"
Server event "player_blind", Tick 3748:
- "userid" = "2"
- "attacker" = "2"
- "entityid" = "297"
- "blind_duration" = "5.07"
*/
ConVar sm_flashbang_duration;
ConVar sm_flashbang_duration_mode;
public void OnPluginStart()
{
HookEvent("player_blind", player_blind);
sm_flashbang_duration_mode = CreateConVar("sm_flashbang_duration_mode", "0",
"0 = Use percent value 1.5 == 150\%\n"
..."1 = add up given value as seconds 1.0 or -1.0"
..."2 = set solid duration as seconds 6.0",
_, true, 0.0, true, 2.0);
sm_flashbang_duration = CreateConVar("sm_flashbang_duration", "1.0",
"Change flash duration\n"
..."- sm_flashbang_duration_mode 0 = Give input value as percent 1.5 == 150\%\n"
..."- sm_flashbang_duration_mode 1 = Give input value as seconds 1.0 == +1 seconds"
..."- sm_flashbang_duration_mode 2 = Give input value as seconds 6.0 == 6 seconds");
}
public void player_blind(Event event, char[] name, bool dontBroadcast)
{
int mode = sm_flashbang_duration_mode.IntValue;
float value = sm_flashbang_duration.FloatValue;
// same as plugin disabled. Do nothing.
if(mode == 0 && value == 1.0) return;
int client = GetClientOfUserId(event.GetInt("userid"));
// only T and CT
if(GetClientTeam(client) < 2) return;
switch(mode)
{
case 1:
{
float m_flFlashDuration = GetEntPropFloat(client, Prop_Send, "m_flFlashDuration");
SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", m_flFlashDuration + value);
}
case 2:
{
// disable flash ?
if(value < 1.0)
{
SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", 0.0);
return;
}
SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", value + GetRandomFloat(0.1, 1.0)); // To avoid flash bug, need give little random value
}
default:
{
float m_flFlashDuration = GetEntPropFloat(client, Prop_Send, "m_flFlashDuration");
SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", m_flFlashDuration * value);
}
}
}
__________________