Raised This Month: $276 Target: $400
 69% 

[CSGO] Block grenade radio sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Teamkiller324
Member
Join Date: Feb 2014
Location: sverige, örebro
Old 09-13-2020 , 02:34   [CSGO] Block grenade radio sound
Reply With Quote #1

Is there a way to block grenade radio sound, if so, how can i?
i am not talking about a command, i'm talking about a plugin if curious.
__________________
My Plugins

Steam Profile
Working on a large compact plugin.
Teamkiller324 is offline
Send a message via Skype™ to Teamkiller324
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 09-13-2020 , 18:12   Re: [CSGO] Block grenade radio sound
Reply With Quote #2

Well... There is a command and you can just use sv_ignoregrenaderadio and set it to 1.

If you want it set per user, replicate the cvar for each client using ReplicateToClient
__________________
Maxximou5 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-14-2020 , 01:29   Re: [CSGO] Block grenade radio sound
Reply With Quote #3

...and maybe hooking sound and block it.
Or hook usermessage.

Can't remember, but there was plugin before
sv_ignoregrenaderadio became
__________________
Do not Private Message @me
Bacardi is offline
Teamkiller324
Member
Join Date: Feb 2014
Location: sverige, örebro
Old 09-14-2020 , 01:44   Re: [CSGO] Block grenade radio sound
Reply With Quote #4

if i only knew how to properly hook sound of the radio and block it :/
__________________
My Plugins

Steam Profile
Working on a large compact plugin.
Teamkiller324 is offline
Send a message via Skype™ to Teamkiller324
Teamkiller324
Member
Join Date: Feb 2014
Location: sverige, örebro
Old 09-14-2020 , 03:17   Re: [CSGO] Block grenade radio sound
Reply With Quote #5

aswell getting not marked as FCVAR_REPLICATED on client error
__________________
My Plugins

Steam Profile
Working on a large compact plugin.
Teamkiller324 is offline
Send a message via Skype™ to Teamkiller324
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-14-2020 , 05:45   Re: [CSGO] Block grenade radio sound
Reply With Quote #6

I'm bit hurry to work


here something
PHP Code:
#include <sdktools>
#include <regex>

Regex regex_usermsg;
Regex regex_sound;

public 
void OnPluginStart()
{

    if(
GetUserMessageType() != UM_ProtobufSetFailState("Plugin work only UM_Protobuf UserMessages");

    
UserMsg msg GetUserMessageId("RadioText");
    if(
msg == INVALID_MESSAGE_IDSetFailState("Missing UserMessage RadioText");



    
regex_usermsg CompileRegex("^#SFUI_TitlesTXT_.+_in_the_hole$"PCRE_CASELESS|PCRE_MULTILINE);
    
    if(
regex_usermsg == nullSetFailState("Regex_usermsg error");
    
    
    
// I had bad time with back slashes \\, I replace them with hex value \x5c
    
regex_sound CompileRegex("player\x5c\x5cvo\x5c\x5c.+\x5c\x5c.+(decoy|fire|flashbang|grenade|molotov|smoke).*\x5c.wav");

    if(
regex_sound == nullSetFailState("Regex_sound error");


    
HookUserMessage(msgmsg_hooktrue);

    
AddNormalSoundHook(soundhook);
}

public 
Action msg_hook(UserMsg msg_idProtobuf msg, const int[] playersint playersNumbool reliablebool init)
{

    if(
msg.GetRepeatedFieldCount("params") < 4) return Plugin_Continue;

    
char buffer[40];

    
// Check translation #phrase (when map location missing = index 1);
    
msg.ReadString("params"buffersizeof(buffer), 1);


    if(
regex_usermsg.Match(buffer) > 0) return Plugin_Handled;

    
// Check translation #phrase (when map location included = index 2);
    
msg.ReadString("params"buffersizeof(buffer), 2);

    if(
regex_usermsg.Match(buffer) > 0) return Plugin_Handled;

    return 
Plugin_Continue;
}


public 
Action soundhook(int clients[MAXPLAYERS], int &numClientschar sample[PLATFORM_MAX_PATH],
      
int &entityint &channelfloat &volumeint &levelint &pitchint &flags,
      
char soundEntry[PLATFORM_MAX_PATH], int &seed)
{

    
    if(
regex_sound.Match(sample) > 0)
    {
        
PrintToServer(sample);
        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;

__________________
Do not Private Message @me
Bacardi is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 09-14-2020 , 16:38   Re: [CSGO] Block grenade radio sound
Reply With Quote #7

If all you want is to block the radio sound for the hegrenade without enabling sv_ignoregrenaderadio for the server, you can do this as well:
PHP Code:
#include <sdktools>

public void OnPluginStart()
{
    
AddNormalSoundHook(Event_NormalSound);
}

public 
Action Event_NormalSound(int clients[64], int &numClientschar sample[PLATFORM_MAX_PATH], int &clientint &channelfloat &volumeint &levelint &pitchint &flags)
{
    if (
StrContains(sample"_grenade") != -1)
    {
        
PrintToServer(sample);
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;

If you want to allow it to be toggled -
PHP Code:
#include <sdktools>

bool g_bToggleEnabled[MAXPLAYERS+1] = {false, ...};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_blockgrenade"Command_BlockGrenade);

    
AddNormalSoundHook(Event_NormalSound);
}

public 
Action Command_BlockGrenade(int clientint args)
{
    if (!
client || !IsClientInGame(client)) return Plugin_Handled;

    if (!
g_bToggleEnabled[client])
    {
        
g_bToggleEnabled[client] = true;
        
PrintToChat(client"Grenade Radio has been disabled.")
    }
    else
    {
        
g_bToggleEnabled[client] = false;
        
PrintToChat(client"Grenade Radio has been enabled.")
    }

    return 
Plugin_Handled;
}

public 
Action Event_NormalSound(int clients[64], int &numClientschar sample[PLATFORM_MAX_PATH], int &clientint &channelfloat &volumeint &levelint &pitchint &flags)
{
    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || IsFakeClient(client) || IsClientSourceTV(client) || IsClientReplay(client)) return Plugin_Continue;
    if (
g_bToggleEnabled[client] && StrContains(sample"_grenade") != -1)
        return 
Plugin_Handled;

    return 
Plugin_Continue;

If you want all grenades to be filter from the radio, use Bacardi's method.

I've also modified Bacardi's to be per client toggle if that interests you.
PHP Code:
#include <sdktools>
#include <regex>

#pragma newdecls required

Regex regex_usermsg;
Regex regex_sound;

bool g_bToggleEnabled[MAXPLAYERS+1] = {false, ...};

public 
void OnPluginStart()
{
    if (
GetUserMessageType() != UM_ProtobufSetFailState("Plugin work only UM_Protobuf UserMessages");

    
UserMsg msg GetUserMessageId("RadioText");
    if (
msg == INVALID_MESSAGE_IDSetFailState("Missing UserMessage RadioText");

    
regex_usermsg CompileRegex("^#SFUI_TitlesTXT_.+_in_the_hole$"PCRE_CASELESS|PCRE_MULTILINE);

    if (
regex_usermsg == nullSetFailState("Regex_usermsg error");

    
// I had bad time with back slashes \\, I replace them with hex value \x5c
    
regex_sound CompileRegex("player\x5c\x5cvo\x5c\x5c.+\x5c\x5c.+(decoy|fire|flashbang|grenade|molotov|smoke).*\x5c.wav");

    if (
regex_sound == nullSetFailState("Regex_sound error");

    
HookUserMessage(msgmsg_hooktrue);

    
AddNormalSoundHook(Event_NormalSound);

    
RegConsoleCmd("sm_blockgrenade"Command_BlockGrenade);
}

public 
Action Command_BlockGrenade(int clientint args)
{
    if (!
client || !IsClientInGame(client)) return Plugin_Handled;

    if (!
g_bToggleEnabled[client])
    {
        
g_bToggleEnabled[client] = true;
        
PrintToChat(client"Grenade Radio has been disabled.")
    }
    else
    {
        
g_bToggleEnabled[client] = false;
        
PrintToChat(client"Grenade Radio has been enabled.")
    }

    return 
Plugin_Handled;
}

public 
Action msg_hook(UserMsg msg_idProtobuf msg, const int[] playersint playersNumbool reliablebool init)
{

    if (
msg.GetRepeatedFieldCount("params") < 4) return Plugin_Continue;

    
char buffer[40];

    
// Check translation #phrase (when map location missing = index 1);
    
msg.ReadString("params"buffersizeof(buffer), 1);

    if (
regex_usermsg.Match(buffer) > 0) return Plugin_Handled;

    
// Check translation #phrase (when map location included = index 2);
    
msg.ReadString("params"buffersizeof(buffer), 2);

    if (
regex_usermsg.Match(buffer) > 0) return Plugin_Handled;

    return 
Plugin_Continue;
}

public 
Action Event_NormalSound(int clients[64], int &numClientschar sample[PLATFORM_MAX_PATH], int &clientint &channelfloat &volumeint &levelint &pitchint &flags)
{
    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || IsFakeClient(client) || IsClientSourceTV(client) || IsClientReplay(client)) return Plugin_Continue;
    if (
g_bToggleEnabled[client] && regex_sound.Match(sample) > 0) return Plugin_Handled;

    return 
Plugin_Continue;

__________________

Last edited by Maxximou5; 09-14-2020 at 16:39.
Maxximou5 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 14:10.


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