Raised This Month: $12 Target: $400
 3% 

Solved Detect CVar value change ?


Post New Thread Reply   
 
Thread Tools Display Modes
luckykevin
Member
Join Date: Feb 2017
Old 03-23-2017 , 18:10   Re: Detect CVar value change ?
Reply With Quote #11

FYI

Code:
L 03/22/2017 - 21:05:29: SourceMod error session started
L 03/22/2017 - 21:05:29: Info (map "am_multimap") (file "errors_20170322.log")
L 03/22/2017 - 21:05:29: [SM] Exception reported: Client 14 is not connected
L 03/22/2017 - 21:05:29: [SM] Blaming: noslam.smx
L 03/22/2017 - 21:05:29: [SM] Call stack trace:
L 03/22/2017 - 21:05:29: [SM]   [0] QueryClientConVar
L 03/22/2017 - 21:05:29: [SM]   [1] Line 34, C:\Users\Admin\Desktop\sourcemod-1.8.0-git5977-windows\addons\sourcemod\scripting\noslam.sp::StartVarChecker
L 03/22/2017 - 21:21:18: Error log file session closed.
Not sure what caused this error. I compiled the plugin on my desktop...then moved it to my server. Why is it giving me a C drive error as if the file is on my desktop?

I keep seeing this error over and over again

Last edited by luckykevin; 03-23-2017 at 18:12.
luckykevin is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 03-23-2017 , 19:35   Re: Detect CVar value change ?
Reply With Quote #12

Needs to pass in userid, not clientid in timer and needs to check if client is in game otherwise you get those errors.

Code:
#include <sourcemod>
#include <sdktools>
#include <basecomm>
#include <voiceannounce_ex>
#pragma newdecls required
#define PLUGIN_VERSION "1.0"
#define message "You were kicked for attempting to micspam. Please set voice_inputfromfile to 0."

public Plugin myinfo = 
{
	name = "Slam Protection",
	author = "Furchee",
	description = "Kicks clients that have voice_inputfromfile set to 1.",
	version = PLUGIN_VERSION,
	url = "http://furchee.com"
};

public void OnClientPutInServer(int client)
{
	CreateTimer(2.0, StartVarChecker, GetClientUserId(client));
}

public void OnClientSpeakingEx(int client)
{
	QueryClientConVar(client, "voice_inputfromfile", view_as<ConVarQueryFinished>(ClientConVar), client);
}

public Action StartVarChecker(Handle timer, int userid)
{
	int client = GetClientOfUserId(userid);
	
	if (!IsClientInGame(client))
		return Plugin_Stop;
	
	QueryClientConVar(client, "voice_inputfromfile", view_as<ConVarQueryFinished>(ClientConVar), client);
	return Plugin_Continue;
}

public void ClientConVar(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
{
	if (!StrEqual(cvarValue, "0"))
	{
		LogAction(client, -1, "%L triggered mic spam protection, kicking", client);
		KickClient(client, "%s", message);
	}
}
__________________
Chaosxk is offline
luckykevin
Member
Join Date: Feb 2017
Old 03-24-2017 , 18:58   Re: Detect CVar value change ?
Reply With Quote #13

Nope, still getting these errors with your changes Chaosxk,

Code:
L 03/24/2017 - 15:05:25: SourceMod error session started
L 03/24/2017 - 15:05:25: Info (map "de_nuke") (file "errors_20170324.log")
L 03/24/2017 - 15:05:25: [SM] Exception reported: Client index 0 is invalid
L 03/24/2017 - 15:05:25: [SM] Blaming: noslam.smx
L 03/24/2017 - 15:05:25: [SM] Call stack trace:
L 03/24/2017 - 15:05:25: [SM]   [0] IsClientInGame
L 03/24/2017 - 15:05:25: [SM]   [1] Line 32, C:\Users\Admin\Desktop\sourcemod-1.8.0-git5977-windows\addons\sourcemod\scripting\noslam.sp::StartVarChecker
L 03/24/2017 - 15:08:29: Error log file session closed.

Last edited by luckykevin; 03-24-2017 at 19:46.
luckykevin is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-26-2017 , 03:30   Re: Detect CVar value change ?
Reply With Quote #14

Line 32, edit to
Code:
if (client == 0 || !IsClientInGame(client) || IsFakeClient(client))
__________________
Do not Private Message @me

Last edited by Bacardi; 03-26-2017 at 03:31.
Bacardi is offline
luckykevin
Member
Join Date: Feb 2017
Old 03-26-2017 , 12:07   Re: Detect CVar value change ?
Reply With Quote #15

Quote:
Originally Posted by Bacardi View Post
Line 32, edit to
Code:
if (client == 0 || !IsClientInGame(client) || IsFakeClient(client))
Seems to be working - haven't gotten any error spams yet.

Thank you!
luckykevin is offline
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 11:19.


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