diff --git a/RadioMute/scripting/RadioMute.sp b/RadioMute/scripting/RadioMute.sp index 9dc850a..1d7431c 100644 --- a/RadioMute/scripting/RadioMute.sp +++ b/RadioMute/scripting/RadioMute.sp @@ -1,23 +1,38 @@ #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; -bool g_bBlocked[MAXPLAYERS + 1]; + +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 = "Very simple plugin to block players from using the in-game radio in supported games.", - author = "Obus", - version = "1.0.1", + 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"); @@ -35,31 +50,46 @@ public void OnPluginStart() 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_bBlocked[i] = false; + g_iBanTime[i] = 0; } } public void OnClientDisconnect(int client) { - g_bBlocked[client] = false; + //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 "); + ReplyToCommand(client, "[SM] Usage: sm_radiomute