From 7b4b8fee77f12f930904dee8df876d39945dc2b7 Mon Sep 17 00:00:00 2001 From: zaCade Date: Sun, 23 Jul 2023 19:00:42 +0200 Subject: [PATCH] [BotTargeting] Boredum too stronk. --- BotTargeting/scripting/BotTargeting.sp | 116 ++++++++++++++++++ .../scripting/include/BotTargeting.inc | 24 ++++ 2 files changed, 140 insertions(+) create mode 100644 BotTargeting/scripting/BotTargeting.sp create mode 100644 BotTargeting/scripting/include/BotTargeting.inc diff --git a/BotTargeting/scripting/BotTargeting.sp b/BotTargeting/scripting/BotTargeting.sp new file mode 100644 index 0000000..4d1e3b6 --- /dev/null +++ b/BotTargeting/scripting/BotTargeting.sp @@ -0,0 +1,116 @@ +#pragma semicolon 1 +#pragma newdecls required + +#include +#include + +bool g_bLateLoad = false; +bool g_bIsAutismBot[MAXPLAYERS+1] = { false, ... }; + +public Plugin myinfo = +{ + name = "Bot Targeting", + author = "zaCade", + description = "Adds extra targeting methods", + version = "1.0" +}; + +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) +{ + g_bLateLoad = late; + + CreateNative("IsClientAutismBot", Native_IsAutismBot); + + RegPluginLibrary("BotTargetting"); + return APLRes_Success; +} + +public void OnPluginStart() +{ + AddMultiTargetFilter("@autismbots", Filter_AutismBot, "Autism Bots", false); + AddMultiTargetFilter("@!autismbots", Filter_NonAutismBot, "Non Autism Bots", false); + + if(g_bLateLoad) + { + char sAuthID[32]; + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i) && !IsFakeClient(i) && IsClientAuthorized(i) && + GetClientAuthId(i, AuthId_Steam2, sAuthID, sizeof(sAuthID))) + { + OnClientAuthorized(i, sAuthID); + } + } + } +} + +public void OnPluginEnd() +{ + RemoveMultiTargetFilter("@autismbots", Filter_AutismBot); + RemoveMultiTargetFilter("@!autismbots", Filter_NonAutismBot); +} + +public void OnClientAuthorized(int client, const char[] sAuthID) +{ + g_bIsAutismBot[client] = \ + StrEqual(sAuthID, "STEAM_0:1:60189040") || \ + StrEqual(sAuthID, "STEAM_0:0:204398871") || \ + StrEqual(sAuthID, "STEAM_0:0:518094602") || \ + StrEqual(sAuthID, "STEAM_0:0:610560766"); +} + +public void OnClientDisconnected(int client) +{ + g_bIsAutismBot[client] = false; +} + +public bool Filter_AutismBot(const char[] sPattern, Handle hClients, int client) +{ + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i) && !IsFakeClient(i) && g_bIsAutismBot[i]) + { + PushArrayCell(hClients, i); + } + } + + return true; +} + +public bool Filter_NonAutismBot(const char[] sPattern, Handle hClients, int client) +{ + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i) && !IsFakeClient(i) && !g_bIsAutismBot[i]) + { + PushArrayCell(hClients, i); + } + } + + return true; +} + +public int Native_IsAutismBot(Handle hPlugin, int numParams) +{ + int client = GetNativeCell(1); + + if(client > MaxClients || client <= 0) + { + ThrowNativeError(SP_ERROR_NATIVE, "Client is not valid."); + return false; + } + + if(!IsClientInGame(client)) + { + ThrowNativeError(SP_ERROR_NATIVE, "Client is not in-game."); + return false; + } + + if(!IsClientAuthorized(client)) + { + ThrowNativeError(SP_ERROR_NATIVE, "Client is not authorized."); + return false; + } + + return g_bIsAutismBot[client]; +} diff --git a/BotTargeting/scripting/include/BotTargeting.inc b/BotTargeting/scripting/include/BotTargeting.inc new file mode 100644 index 0000000..dfc9125 --- /dev/null +++ b/BotTargeting/scripting/include/BotTargeting.inc @@ -0,0 +1,24 @@ +#if defined _BotTargeting_Included + #endinput +#endif +#define _BotTargeting_Included + +native bool IsClientAutismBot(int client); + +public SharedPlugin __pl_BotTargeting = +{ + name = "BotTargeting", + file = "BotTargeting.smx", +#if defined REQUIRE_PLUGIN + required = 1, +#else + required = 0, +#endif +}; + +#if !defined REQUIRE_PLUGIN +public __pl_BotTargeting_SetNTVOptional() +{ + MarkNativeAsOptional("IsClientAutismBot"); +} +#endif