#pragma semicolon 1 //Yes, this should be a convar. No, I cant be bothered to do the convar hooks. #define DEFAULT_BAN 60 #include #include #pragma newdecls required bool g_bLateLoad = false; bool g_bProtoBuf; int g_iBanTime[MAXPLAYERS + 1]; //CAREFUL! 0 ON THIS VARIABLE MEANS NOT BANNED, BUT 0 FROM COOKIE OUTPUT IS AN ERROR! Cookie g_CookieBanTime = null; //bool g_bBlocked[MAXPLAYERS + 1]; int g_iMessageClient = -1; public Plugin myinfo = { name = "RadioMute", description = "(No longer that) Very simple plugin to block players from using the in-game radio in supported games.", author = "Obus, Pan32", version = "1.1.0", url = "" } public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { g_bLateLoad = late; return APLRes_Success; } 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."); g_CookieBanTime = new Cookie("radiomute_ban_time", "Stores the unix epoch time in which a players ban expires", CookieAccess_Private); RegAdminCmd("sm_radiomute", Command_RadioMute, ADMFLAG_BAN, "Block a client from using the in-game radio."); RegAdminCmd("sm_radiounmute", Command_RadioUnmute, ADMFLAG_BAN, "Unblock a client from using the in-game radio."); HookUserMessage(RadioText, _hkRadioText, true); HookUserMessage(SendAudio, _hkSendAudio, true); if (g_bLateLoad) { for (int i = 1; i <= MaxClients; i++) { if (IsClientConnected(i) && IsClientInGame(i)) { OnClientCookiesCached(i); } } } } public void OnMapEnd() { for (int i = 1; i <= MaxClients; i++) { //g_bBlocked[i] = false; g_iBanTime[i] = 0; } } public void OnClientDisconnect(int client) { //g_bBlocked[client] = false; g_iBanTime[client] = 0; } public Action Command_RadioMute(int client, int argc) { if (argc < 1) { ReplyToCommand(client, "[SM] Usage: sm_radiomute