AdvancedTargeting: Added @talking / @!talking and @speaking / @!speaking

This commit is contained in:
BotoX 2019-09-01 16:49:24 +02:00
parent 589f13c2f3
commit 6bbef012bb

View File

@ -8,9 +8,20 @@
#include <cstrike>
#include <AdvancedTargeting>
#undef REQUIRE_PLUGIN
#include <AdvancedTargeting>
#define REQUIRE_PLUGIN
#undef REQUIRE_EXTENSIONS
#tryinclude <voice>
#define REQUIRE_EXTENSIONS
#pragma newdecls required
Handle g_FriendsArray[MAXPLAYERS + 1] = {INVALID_HANDLE, ...};
bool g_Plugin_voiceannounce_ex = false;
bool g_Extension_Voice = false;
bool g_bLateLoad = false;
#include <SteamAPI.secret> //#define STEAM_API_KEY here
@ -20,7 +31,7 @@ public Plugin myinfo =
name = "Advanced Targeting",
author = "BotoX + Obus",
description = "Adds extra targeting methods",
version = "1.2",
version = "1.3",
url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/AdvancedTargeting/"
}
@ -35,6 +46,10 @@ public void OnPluginStart()
AddMultiTargetFilter("@randomt", Filter_RandomT, "a Random T", false);
AddMultiTargetFilter("@alivect", Filter_AliveCT, "Alive Humans", false);
AddMultiTargetFilter("@alivet", Filter_AliveT, "Alive Zombies", false);
AddMultiTargetFilter("@talking", Filter_Talking, "Talking", false);
AddMultiTargetFilter("@!talking", Filter_NotTalking, "Not Talking", false);
AddMultiTargetFilter("@speaking", Filter_Talking, "Talking", false);
AddMultiTargetFilter("@!speaking", Filter_NotTalking, "Not Talking", false);
RegConsoleCmd("sm_admins", Command_Admins, "Currently online admins.");
RegConsoleCmd("sm_friends", Command_Friends, "Currently online friends.");
@ -64,6 +79,10 @@ public void OnPluginEnd()
RemoveMultiTargetFilter("@randomt", Filter_RandomT);
RemoveMultiTargetFilter("@alivect", Filter_AliveCT);
RemoveMultiTargetFilter("@alivet", Filter_AliveT);
RemoveMultiTargetFilter("@talking", Filter_Talking);
RemoveMultiTargetFilter("@!talking", Filter_NotTalking);
RemoveMultiTargetFilter("@speaking", Filter_Talking);
RemoveMultiTargetFilter("@!speaking", Filter_NotTalking);
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
@ -72,6 +91,13 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("ReadClientFriends", Native_ReadClientFriends);
RegPluginLibrary("AdvancedTargeting");
g_Plugin_voiceannounce_ex = LibraryExists("voiceannounce_ex");
g_Extension_Voice = LibraryExists("Voice");
LogMessage("AdvancedTargeting capabilities:\nVoiceAnnounce: %s\nVoice: %s",
(g_Plugin_voiceannounce_ex ? "loaded" : "not loaded"),
(g_Extension_Voice ? "loaded" : "not loaded"));
g_bLateLoad = late;
return APLRes_Success;
}
@ -310,6 +336,47 @@ public bool Filter_RandomT(const char[] sPattern, Handle hClients, int client)
return true;
}
stock bool _IsClientSpeaking(int client)
{
#if defined _voiceannounceex_included_
if(g_Plugin_voiceannounce_ex)
return IsClientSpeaking(client);
#endif
#if defined _voice_included
if(g_Extension_Voice)
return IsClientTalking(client);
#endif
return false;
}
public bool Filter_Talking(const char[] sPattern, Handle hClients, int client)
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && !IsFakeClient(i) && _IsClientSpeaking(i))
{
PushArrayCell(hClients, i);
}
}
return true;
}
public bool Filter_NotTalking(const char[] sPattern, Handle hClients, int client)
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && !IsFakeClient(i) && !_IsClientSpeaking(i))
{
PushArrayCell(hClients, i);
}
}
return true;
}
public void OnClientAuthorized(int client, const char[] auth)
{
if(IsFakeClient(client))