sm-plugins/AntiLenny/scripting/AntiLenny.sp
2018-12-10 23:26:23 +01:00

100 lines
2.2 KiB
SourcePawn

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <zombiereloaded>
#include <cstrike>
#include <ccc>
#include <multicolors>
#include <clientprefs>
bool g_bHideLennies[MAXPLAYERS + 1] = { false, ... };
bool g_bHideLenniesHooked = false;
Handle g_hCookieHideLennies = null;
char g_cLennies[23][] = {"( ͡° ͜ʖ ͡°)", "͜ʖ", "(° ͜ʖ °)", "( ͝͠°͜ل͝͠°)", "( ͡° ͜ ͡°)", "( ͡°╭͜ʖ╮͡° )", "( ͠° ͜ʖ ͡°)", "( ° ͜ʖ °)", "(╯°□°)╯", "_(ツ)_", "_ツ_", "( ̿°̿ ͜ل͜ ̿°̿ )", "( ͡", "( ͠", "( ͝", "( °", "", "ಠ_ಠ", "͡°", "°͡", "ʖ", "͡", "͜"};
public Plugin myinfo =
{
name = "AntiLenny",
author = "Dogan",
description = "Makes it possible to selfmute Lennies",
version = "1.2.0",
url = ""
}
public void OnPluginStart()
{
RegConsoleCmd("sm_hide_lennies", HideLennies, "Toggle blocking Lennies");
g_hCookieHideLennies = RegClientCookie("lennies_blocked", "are lennies blocked", CookieAccess_Protected);
}
public Action CCC_OnChatMessage(int client, int author, const char[] message)
{
for(int i = 0; i < 23; i++)
{
if(g_bHideLennies[client] && StrContains(message, g_cLennies[i], false) != -1)
{
return Plugin_Handled;
}
}
return Plugin_Continue;
}
public Action HideLennies(int client, int args)
{
g_bHideLennies[client] = !g_bHideLennies[client];
CheckHideLenniesHooks();
if(g_bHideLennies[client])
{
ReplyToCommand(client, "You blocked Lennies");
SetClientCookie(client, g_hCookieHideLennies, "1");
}
else
{
ReplyToCommand(client, "You unblocked Lennies");
SetClientCookie(client, g_hCookieHideLennies, "");
}
return Plugin_Handled;
}
public void OnClientCookiesCached(int client)
{
char sBuffer[2];
GetClientCookie(client, g_hCookieHideLennies, sBuffer, sizeof(sBuffer));
if(sBuffer[0] != '\0')
{
g_bHideLennies[client] = true;
g_bHideLenniesHooked = true;
}
else
{
g_bHideLennies[client] = false;
}
}
public void OnClientDisconnect(int client)
{
g_bHideLennies[client] = false;
CheckHideLenniesHooks();
}
public void CheckHideLenniesHooks()
{
bool bShouldHook = false;
for(int i = 1; i <= MaxClients; i++)
{
if(g_bHideLennies[i])
{
bShouldHook = true;
break;
}
}
g_bHideLenniesHooked = bShouldHook;
}