Raised This Month: $65 Target: $400
 16% 

Help l4d_nightvision


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BlackSabbarh
Junior Member
Join Date: Sep 2018
Old 10-21-2018 , 20: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 21:00.
BlackSabbarh is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-22-2018 , 14:40   Re: Help l4d_nightvision
Reply With Quote #2

First of all put the code in a proper [code] or [php] tags, then go and post in the SourceMod section instead of the AMXModX one.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:24.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode