AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   Hide Cvar Chat Print (https://forums.alliedmods.net/showthread.php?t=154094)

Ginxeng 04-02-2011 18:26

Hide Cvar Chat Print
 
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()


Leonardo 04-03-2011 02:26

Re: Hide Cvar Chat Print
 
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[])); 


BlackHawk15 04-03-2011 04:15

Re: Hide Cvar Chat Print
 
Quote:

Originally Posted by Ginxeng (Post 1443461)
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!)))

Ginxeng 04-03-2011 16:33

Re: Hide Cvar Chat Print
 
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.

PpZ | Iconoclast 04-04-2011 09:35

Re: Hide Cvar Chat Print
 
I'd love to have this as a plugin as well...can you post the .smx please? :)

Lebson506th 04-04-2011 10:07

Re: Hide Cvar Chat Print
 
1 Attachment(s)
Posting the code with the aforementioned improvements plus I moved the declarations out of the for loop.

PpZ | Iconoclast 04-04-2011 10:10

Re: Hide Cvar Chat Print
 
Awesome, thanks mate! I'll give this a try on my L4D2 server tonight! :)

Edit: Works PERFECTLY. Thank you!! :)

diniboy 06-22-2018 13:26

Re: Hide Cvar Chat Print
 
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!

berkayjan 07-08-2018 14:45

Re: Hide Cvar Chat Print
 
Guys, i have no experince about scripts. Can you convert this as a plugin?

Tonblader 09-27-2020 21:01

Re: Hide Cvar Chat Print
 
better use this plugin
https://forums.alliedmods.net/showthread.php?p=2661102


All times are GMT -4. The time now is 12:25.

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