AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [CSGO] Block grenade radio sound (https://forums.alliedmods.net/showthread.php?t=327343)

Teamkiller324 09-13-2020 02:34

[CSGO] Block grenade radio sound
 
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.

Maxximou5 09-13-2020 18:12

Re: [CSGO] Block grenade radio sound
 
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

Bacardi 09-14-2020 01:29

Re: [CSGO] Block grenade radio sound
 
...and maybe hooking sound and block it.
Or hook usermessage.

Can't remember, but there was plugin before
sv_ignoregrenaderadio became

Teamkiller324 09-14-2020 01:44

Re: [CSGO] Block grenade radio sound
 
if i only knew how to properly hook sound of the radio and block it :/

Teamkiller324 09-14-2020 03:17

Re: [CSGO] Block grenade radio sound
 
aswell getting not marked as FCVAR_REPLICATED on client error

Bacardi 09-14-2020 05:45

Re: [CSGO] Block grenade radio sound
 
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;



Maxximou5 09-14-2020 16:38

Re: [CSGO] Block grenade radio sound
 
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;




All times are GMT -4. The time now is 20:24.

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