moving to shared since i added on unloze

This commit is contained in:
DoganGFL 2018-12-13 21:09:25 +01:00
parent 4f9754727c
commit 1a93cd9abb

View File

@ -0,0 +1,127 @@
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <multicolors>
#define PLUGIN_VERSION "2.0"
#pragma newdecls required
bool g_bProtoBuf;
bool g_bBlocked[MAXPLAYERS + 1];
bool g_bIsEnabled[MAXPLAYERS + 1];
int g_iMessageClient = -1;
public Plugin myinfo =
{
name = "Toggle radio mute command",
author = "Nano",
description = "You can enable or disable the radio voice/text messages using a command",
version = PLUGIN_VERSION,
url = "http://steamcommunity.com/id/marianzet1"
};
public void OnPluginStart()
{
LoadTranslations("common.phrases");
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
g_bProtoBuf = true;
UserMsg RadioText = GetUserMessageId("RadioText");
if (RadioText == INVALID_MESSAGE_ID)
SetFailState("This game does not support the \"RadioText\" UserMessage.");
UserMsg SendAudio = GetUserMessageId("SendAudio");
if (SendAudio == INVALID_MESSAGE_ID)
SetFailState("This game does not support the \"SendAudio\" UserMessage.");
RegConsoleCmd("sm_radio", Command_RadioMute);
RegConsoleCmd("sm_smradio", Command_RadioMute);
//RegConsoleCmd("sm_mr", Command_RadioMute);
HookUserMessage(RadioText, _hkRadioText, true);
HookUserMessage(SendAudio, _hkSendAudio, true);
}
public void OnClientPostAdminCheck(int client)
{
g_bIsEnabled[client] = false;
}
public void OnClientDisconnect(int client)
{
g_bIsEnabled[client] = false;
g_bBlocked[client] = false;
}
public Action Command_RadioMute(int client, int args)
{
if(!g_bIsEnabled[client])
{
g_bIsEnabled[client] = true;
g_bBlocked[client] = true;
CPrintToChat(client, "{green}[{lightgreen}Mute-Radio{green}]{default} You have {purple}disabled the radio messages.");
return Plugin_Handled;
}
else
{
g_bIsEnabled[client] = false;
g_bBlocked[client] = false;
CPrintToChat(client, "{green}[{lightgreen}Mute-Radio{green}]{default} You have {purple}enabled the radio messages.");
return Plugin_Handled;
}
}
public Action _hkRadioText(UserMsg msg_id, Handle bf, const int[] players, int playersNum, bool reliable, bool init)
{
if (g_bProtoBuf)
{
g_iMessageClient = PbReadInt(bf, "client");
}
else
{
BfReadByte(bf);
g_iMessageClient = BfReadByte(bf);
}
if (g_bBlocked[g_iMessageClient])
{
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action _hkSendAudio(UserMsg msg_id, Handle bf, const int[] players, int playersNum, bool reliable, bool init)
{
if (g_iMessageClient == -1)
return Plugin_Continue;
char sSound[128];
if(g_bProtoBuf)
PbReadString(bf, "radio_sound", sSound, sizeof(sSound));
else
BfReadString(bf, sSound, sizeof(sSound), false);
if (strncmp(sSound[6], "lock", 4, false) == 0)
return Plugin_Continue;
if (g_bBlocked[g_iMessageClient])
{
g_iMessageClient = -1;
return Plugin_Handled;
}
g_iMessageClient = -1;
return Plugin_Continue;
}