Update Nano's Shit Plugin
This commit is contained in:
parent
d9c128201b
commit
19477f7d1a
@ -1,15 +1,127 @@
|
||||
#pragma semicolon 1
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include <cstrike>
|
||||
#include <morecolors>
|
||||
|
||||
public OnPluginStart()
|
||||
#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 =
|
||||
{
|
||||
RegConsoleCmd("sm_smradio", Radio_Command);
|
||||
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_radiomute", Command_RadioMute);
|
||||
RegConsoleCmd("sm_muteradio", Command_RadioMute);
|
||||
RegConsoleCmd("sm_mr", Command_RadioMute);
|
||||
|
||||
HookUserMessage(RadioText, _hkRadioText, true);
|
||||
HookUserMessage(SendAudio, _hkSendAudio, true);
|
||||
}
|
||||
|
||||
public Action:Radio_Command(client, args)
|
||||
public void OnClientPostAdminCheck(int client)
|
||||
{
|
||||
FakeClientCommand(client, "ignorerad");
|
||||
g_bIsEnabled[client] = false;
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user