View Single Post
Author Message
BlackSabbarh
Senior Member
Join Date: Sep 2018
Old 10-21-2018 , 19:59   Help l4d_nightvision
Reply With Quote #1

Does anyone help to add a time cvars to this add-on so that it activates within a time of 30 seconds and then deactivates and then reactivates?


/* Plugin Template generated by Pawn Studio */
#include <sourcemod>

new IMPULS_FLASHLIGHT = 100;
new FloatressTime[MAXPLAYERS+1];

new Mode;
new bool:EnableSuvivor;
new bool:EnableInfected;
new Handle:l4d_nt_team;

public Plugin:myinfo =
{
name = "Night Vision",
author = "Pan Xiaohai & Mr. Zero",
description = "<- Description ->",
version = "1.0",
url = "<- URL ->"
}

public OnPluginStart()
{
RegConsoleCmd("sm_nightvision", sm_nightvision);
l4d_nt_team = CreateConVar("l4d_nt_team", "1", " 0:disable, 1:enable for survivor and infected, 2:enable for survivor, 3:enable for infected ", FCVAR_PLUGIN);
AutoExecConfig(true, "l4d_nightvision");
HookConVarChange(l4d_nt_team, ConVarChange);
GetConVar();

}
public ConVarChange(Handle:convar, const StringldValue[], const String:newValue[])
{
GetConVar();
}
GetConVar()
{
Mode=GetConVarInt(l4d_nt_team);
EnableSuvivor=(Mode==1 || Mode==2);
EnableInfected=(Mode==1 || Mode==3);
}
public Action:sm_nightvision(client,args)
{
if(IsClientInGame(client))SwitchNightVision(c lient);
}
//code from "Block Flashlight",
public Action:OnPlayerRunCmd(client, &buttons, &impuls, Float:vel[3], Float:angles[3], &weapon)
{
if(Mode==0)return;
if(impuls==IMPULS_FLASHLIGHT)
{
new team=GetClientTeam(client);
if(team==2 && EnableSuvivor )
{
new Float:time=GetEngineTime();
if(time-PressTime[client]<0.3)
{
SwitchNightVision(client);
}
PressTime[client]=time;

}
if(team==3 && EnableInfected)
{
new Float:time=GetEngineTime();
if(time-PressTime[client]>0.1)
{
SwitchNightVision(client);
}
PressTime[client]=time;
}
}
}
SwitchNightVision(client)
{
new d=GetEntProp(client, Prop_Send, "m_bNightVisionOn");
if(d==0)
{
SetEntProp(client, Prop_Send, "m_bNightVisionOn",1);
PrintHintText(client, "Night Vision On");

}
else
{
SetEntProp(client, Prop_Send, "m_bNightVisionOn",0);
PrintHintText(client, "Night Vision Off");
}

}




Sorry my English is poor: oops:C

Last edited by BlackSabbarh; 10-21-2018 at 20:00.
BlackSabbarh is offline