View Single Post
login101
Member
Join Date: Sep 2017
Old 07-23-2019 , 00:51   Re: [L4D2] I want to clear the [cvar] message in the server chat window.
Reply With Quote #4

Quote:
Originally Posted by Crasher_3637 View Post
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
    
name "Quiet ConVar Changer",
    
description "Quietly change a ConVar's value.",
    
author "Psyk0tik (Crasher_3637)",
    
version "1.0",
    
url "http://forums.alliedmods.net/"
};

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_qcvar"Command_QuietCvarADMFLAG_CONVARS"sm_qcvar <ConVar> <Value> - Quietly change a ConVar's value");
}

public 
Action Command_QuietCvar(int clientint args)
{
    if (
args || args 2)
    {
        
ReplyToCommand(client"[SM] Usage: sm_qcvar <ConVar> <Value> - Quietly change a ConVar's value");
        return 
Plugin_Handled;
    }

    
char sConVar[64];
    
GetCmdArg(1sConVarsizeof(sConVar));
    
ConVar cvSetting FindConVar(sConVar);
    if (
cvSetting != null)
    {
        switch (
args)
        {
            case 
1:
            {
                
char sValue[64];
                
cvSetting.GetString(sValuesizeof(sValue));
                
ReplyToCommand(client"[SM] Value of cvar \"%s\": \"%s\""sConVarsValue);
            }
            case 
2:
            {
                
char sValue[64];
                
GetCmdArg(2sValuesizeof(sValue));
                
int iFlags cvSetting.Flags;
                if (
iFlags FCVAR_NOTIFY)
                {
                    
cvSetting.Flags iFlags & ~FCVAR_NOTIFY;
                    
cvSetting.SetString(sValue);
                    
cvSetting.Flags iFlags|FCVAR_NOTIFY;
                }
                else
                {
                    
cvSetting.SetString(sValue);
                }

                
//LogAction(client, -1, "\"%L\" changed cvar (cvar \"%s\") (value \"%s\")", client, sConVar, sValue);
            
}
        }

        
delete cvSetting;
        return 
Plugin_Handled;
    }

    
ReplyToCommand(client"[SM] Invalid ConVar: %s"sConVar);
    return 
Plugin_Handled;

I've had this plugin for awhile.

Instead of sm_cvar use sm_qcvar

I'll try it later. Thank you very much for giving me the answer. Thanks to you guys, l4d2 has fun.
login101 is offline