From 4a14b776db8791fb0d62fea1f4491429a8153d37 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 9 Nov 2014 16:35:52 -0800 Subject: [PATCH] Port basecomm.sp. --- plugins/basecomm.sp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/basecomm.sp b/plugins/basecomm.sp index 2cc7c193..6c2993e7 100644 --- a/plugins/basecomm.sp +++ b/plugins/basecomm.sp @@ -50,8 +50,8 @@ public Plugin:myinfo = new bool:g_Muted[MAXPLAYERS+1]; // Is the player muted? new bool:g_Gagged[MAXPLAYERS+1]; // Is the player gagged? -new Handle:g_Cvar_Deadtalk = INVALID_HANDLE; // Holds the handle for sm_deadtalk -new Handle:g_Cvar_Alltalk = INVALID_HANDLE; // Holds the handle for sv_alltalk +ConVar g_Cvar_Deadtalk; // Holds the handle for sm_deadtalk +ConVar g_Cvar_Alltalk; // Holds the handle for sv_alltalk new bool:g_Hooked = false; // Tracks if we've hooked events for deadtalk TopMenu hTopMenu; @@ -89,8 +89,8 @@ public OnPluginStart() RegAdminCmd("sm_ungag", Command_Ungag, ADMFLAG_CHAT, "sm_ungag - Restores a player's ability to use chat."); RegAdminCmd("sm_unsilence", Command_Unsilence, ADMFLAG_CHAT, "sm_unsilence - Restores a player's ability to use voice and chat."); - HookConVarChange(g_Cvar_Deadtalk, ConVarChange_Deadtalk); - HookConVarChange(g_Cvar_Alltalk, ConVarChange_Alltalk); + g_Cvar_Deadtalk.AddChangeHook(ConVarChange_Deadtalk); + g_Cvar_Alltalk.AddChangeHook(ConVarChange_Alltalk); /* Account for late loading */ TopMenu topmenu; @@ -122,7 +122,7 @@ public OnAdminMenuReady(TopMenu topmenu) public ConVarChange_Deadtalk(Handle:convar, const String:oldValue[], const String:newValue[]) { - if (GetConVarInt(g_Cvar_Deadtalk)) + if (g_Cvar_Deadtalk.IntValue) { HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post); HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post); @@ -155,11 +155,11 @@ public Action:OnClientSayCommand(client, const String:command[], const String:sA return Plugin_Continue; } -public ConVarChange_Alltalk(Handle:convar, const String:oldValue[], const String:newValue[]) +public void ConVarChange_Alltalk(ConVar convar, const char[] oldValue, const char[] newValue) { - new mode = GetConVarInt(g_Cvar_Deadtalk); + int mode = g_Cvar_Deadtalk.IntValue; - for (new i = 1; i <= MaxClients; i++) + for (int i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i)) { @@ -170,7 +170,7 @@ public ConVarChange_Alltalk(Handle:convar, const String:oldValue[], const String { SetClientListeningFlags(i, VOICE_MUTED); } - else if (GetConVarBool(g_Cvar_Alltalk)) + else if (g_Cvar_Alltalk.BoolValue) { SetClientListeningFlags(i, VOICE_NORMAL); } @@ -209,7 +209,7 @@ public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) { - new client = GetClientOfUserId(GetEventInt(event, "userid")); + int client = GetClientOfUserId(GetEventInt(event, "userid")); if (!client) { @@ -222,13 +222,13 @@ public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) return; } - if (GetConVarBool(g_Cvar_Alltalk)) + if (g_Cvar_Alltalk.BoolValue) { SetClientListeningFlags(client, VOICE_NORMAL); return; } - new mode = GetConVarInt(g_Cvar_Deadtalk); + int mode = g_Cvar_Deadtalk.IntValue; if (mode == 1) { SetClientListeningFlags(client, VOICE_LISTENALL);