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_Protobuf) SetFailState("Plugin work only UM_Protobuf UserMessages");
UserMsg msg = GetUserMessageId("RadioText");
if(msg == INVALID_MESSAGE_ID) SetFailState("Missing UserMessage RadioText");
regex_usermsg = CompileRegex("^#SFUI_TitlesTXT_.+_in_the_hole$", PCRE_CASELESS|PCRE_MULTILINE);
if(regex_usermsg == null) SetFailState("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 == null) SetFailState("Regex_sound error");
HookUserMessage(msg, msg_hook, true);
AddNormalSoundHook(soundhook);
}
public Action msg_hook(UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init)
{
if(msg.GetRepeatedFieldCount("params") < 4) return Plugin_Continue;
char buffer[40];
// Check translation #phrase (when map location missing = index 1);
msg.ReadString("params", buffer, sizeof(buffer), 1);
if(regex_usermsg.Match(buffer) > 0) return Plugin_Handled;
// Check translation #phrase (when map location included = index 2);
msg.ReadString("params", buffer, sizeof(buffer), 2);
if(regex_usermsg.Match(buffer) > 0) return Plugin_Handled;
return Plugin_Continue;
}
public Action soundhook(int clients[MAXPLAYERS], int &numClients, char sample[PLATFORM_MAX_PATH],
int &entity, int &channel, float &volume, int &level, int &pitch, int &flags,
char soundEntry[PLATFORM_MAX_PATH], int &seed)
{
if(regex_sound.Match(sample) > 0)
{
PrintToServer(sample);
return Plugin_Handled;
}
return Plugin_Continue;
}
__________________