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

Hide Cvar Chat Print


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ginxeng
Senior Member
Join Date: Nov 2009
Location: Timber Doodle
Old 04-02-2011 , 18:26   Hide Cvar Chat Print
Reply With Quote #1

Is there a plugin to hide cvar printed the chat? For example lets say I do sv_alltalk 1, I dont want to server to print in the chat that it was changed. Someone gave me this a while ago
Code:
new Handle:p_Notify = INVALID_HANDLE;
 
public OnPluginStart ()
{
p_Notify = CreateConVar("sm_core_notify", "sv_gravity, sv_airaccelerate, sv_wateraccelerate, sv_alltalk, mp_limitteams", "Setting: List of cvars, comma limited, to strip notifications from.");
}
 
public OnConfigsExecuted()
{
StripNotifyCvars();
}
 
StripNotifyCvars()
{
decl String:cvars[1024], String:ncvars[16][64];
GetConVarString(p_Notify, cvars, sizeof(cvars));
if(strcmp(cvars, "", false)!=0)
{
    new cvarc = ExplodeString(cvars, ", ", ncvars, 16, 64);
    for(new i=0;i<cvarc;i++)
    {
TrimString(ncvars[i]);
        new Handle:cvar = FindConVar(ncvars[i]);
        new flags = GetConVarFlags(cvar);
flags &= ~FCVAR_NOTIFY;
SetConVarFlags(cvar, flags);
    }
}
} 
It does the job but it gives me errors and I want to fix that.

Code:
[SM] Native "GetConVarFlags" reported: Invalid convar handle 0 (error 4)
Code:
[SM] Displaying call stack trace for plugin "no_print.smx":
[SM] [0] Line 24, /groups/sourcemod/upload_tmp/text5FE4tU.sp::StripNotifyCvars()
[SM] [1] Line 10, /groups/sourcemod/upload_tmp/text5FE4tU.sp::OnConfigsExecuted()
__________________

Last edited by Ginxeng; 04-03-2011 at 16:18.
Ginxeng is offline
Send a message via AIM to Ginxeng Send a message via MSN to Ginxeng Send a message via Skype™ to Ginxeng
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 04-03-2011 , 02:26   Re: Hide Cvar Chat Print
Reply With Quote #2

PHP Code:
         new Handle:cvar FindConVar(ncvars[i]);
         if(
cvar==INVALID_HANDLE) continue; // ignore if ConVar isn't exists 
also, it's a veeeeeeery bad idea to create variables (using 'new') in cycles

also
PHP Code:
new cvarc ExplodeString(cvars", "ncvars1664); 
must be
PHP Code:
new cvarc ExplodeString(cvars", "ncvars1563); 
or
PHP Code:
new cvarc ExplodeString(cvars", "ncvarssizeof(ncvars), sizeof(ncvars[])); 

Last edited by Leonardo; 04-03-2011 at 02:28.
Leonardo is offline
BlackHawk15
Junior Member
Join Date: Apr 2011
Old 04-03-2011 , 04:15   Re: Hide Cvar Chat Print
Reply With Quote #3

Quote:
Originally Posted by Ginxeng View Post
Is here a plugin to hide cvar printed the chat? For example lets say I do sv_alltalk 1, I dont want to server to print in the chat that it was changed. Someone gave me this a while ago
Code:
new Handle:p_Notify = INVALID_HANDLE;
 
public OnPluginStart ()
{
p_Notify = CreateConVar("sm_core_notify", "sv_gravity, sv_airaccelerate, sv_wateraccelerate, sv_alltalk, mp_limitteams", "Setting: List of cvars, comma limited, to strip notifications from.");
}
 
public OnConfigsExecuted()
{
StripNotifyCvars();
}
 
StripNotifyCvars()
{
decl String:cvars[1024], String:ncvars[16][64];
GetConVarString(p_Notify, cvars, sizeof(cvars));
 if(strcmp(cvars, "", false)!=0)
 {
     new cvarc = ExplodeString(cvars, ", ", ncvars, 16, 64);
     for(new i=0;i<cvarc;i++)
     {
TrimString(ncvars[i]);
         new Handle:cvar = FindConVar(ncvars[i]);
         new flags = GetConVarFlags(cvar);
flags &= ~FCVAR_NOTIFY;
SetConVarFlags(cvar, flags);
     }
 }
} 
It does the job but it gives me errors and I want to fix that.

Code:
[SM] Native "GetConVarFlags" reported: Invalid convar handle 0 (error 4)
Code:
[SM] Displaying call stack trace for plugin "no_print.smx":
[SM] [0] Line 24, /groups/sourcemod/upload_tmp/text5FE4tU.sp::StripNotifyCvars()
[SM] [1] Line 10, /groups/sourcemod/upload_tmp/text5FE4tU.sp::OnConfigsExecuted()
Ginxeng, BIG THX for this code!! It's what that i need!)))
BlackHawk15 is offline
Ginxeng
Senior Member
Join Date: Nov 2009
Location: Timber Doodle
Old 04-03-2011 , 16:33   Re: Hide Cvar Chat Print
Reply With Quote #4

Thanks Leonardo, your changes worked. No more errors in my console. Also Blackhawk, I'm not trying to take credit for this plugin, I was simply trying to get the errors fixed, I didn't write this plugin.
__________________
Ginxeng is offline
Send a message via AIM to Ginxeng Send a message via MSN to Ginxeng Send a message via Skype™ to Ginxeng
PpZ | Iconoclast
Senior Member
Join Date: Feb 2008
Old 04-04-2011 , 09:35   Re: Hide Cvar Chat Print
Reply With Quote #5

I'd love to have this as a plugin as well...can you post the .smx please?
__________________
PpZ | Iconoclast is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 04-04-2011 , 10:07   Re: Hide Cvar Chat Print
Reply With Quote #6

Posting the code with the aforementioned improvements plus I moved the declarations out of the for loop.
Attached Files
File Type: sp Get Plugin or Get Source (strip_notify.sp - 2009 views - 913 Bytes)
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th is offline
PpZ | Iconoclast
Senior Member
Join Date: Feb 2008
Old 04-04-2011 , 10:10   Re: Hide Cvar Chat Print
Reply With Quote #7

Awesome, thanks mate! I'll give this a try on my L4D2 server tonight!

Edit: Works PERFECTLY. Thank you!!
__________________

Last edited by PpZ | Iconoclast; 04-04-2011 at 18:20.
PpZ | Iconoclast is offline
diniboy
Junior Member
Join Date: Jun 2018
Old 06-22-2018 , 13:26   Re: Hide Cvar Chat Print
Reply With Quote #8

Hi,

Thanks for this plugin, that's exactly what I need now. But I got this error:

Code:
WARNING: Command too long... ignoring!
Code:
Cbuf_AddText: buffer overflow
What can I do?

Thanks!
diniboy is offline
berkayjan
Junior Member
Join Date: Jul 2018
Old 07-08-2018 , 14:45   Re: Hide Cvar Chat Print
Reply With Quote #9

Guys, i have no experince about scripts. Can you convert this as a plugin?
berkayjan is offline
Tonblader
Senior Member
Join Date: Jul 2011
Location: Peru
Old 09-27-2020 , 21:01   Re: Hide Cvar Chat Print
Reply With Quote #10

better use this plugin
https://forums.alliedmods.net/showthread.php?p=2661102
Tonblader 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 06:15.


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