sm-plugins/AntiLenny/scripting/AntiLenny.sp

166 lines
5.2 KiB
SourcePawn
Raw Normal View History

2018-12-10 23:26:23 +01:00
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <zombiereloaded>
#include <cstrike>
#include <ccc>
#include <multicolors>
#include <clientprefs>
bool g_bHideLennies[MAXPLAYERS + 1] = { false, ... };
Handle g_hCookieHideLennies = null;
2019-01-13 16:58:02 +01:00
#define NUMBEROFLENNIES 23
2018-12-10 23:26:23 +01:00
2019-01-13 16:58:02 +01:00
char g_cLennies[NUMBEROFLENNIES][] = {"( ͡° ͜ʖ ͡°)", "͜ʖ", "(° ͜ʖ °)", "( ͝͠°͜ل͝͠°)", "( ͡° ͜ ͡°)", "( ͡°╭͜ʖ╮͡° )", "( ͠° ͜ʖ ͡°)", "( ° ͜ʖ °)", "(╯°□°)╯", "_(ツ)_", "_ツ_", "( ̿°̿ ͜ل͜ ̿°̿ )", "( ͡", "( ͠", "( ͝", "( °", "", "ಠ_ಠ", "͡°", "°͡", "ʖ", "͡", "͜"};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-12-10 23:26:23 +01:00
public Plugin myinfo =
{
name = "AntiLenny",
author = "Dogan",
description = "Makes it possible to selfmute Lennies",
2019-01-13 16:58:02 +01:00
version = "1.3.0",
2018-12-10 23:26:23 +01:00
url = ""
}
2019-01-13 16:58:02 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-12-10 23:26:23 +01:00
public void OnPluginStart()
{
2019-01-13 16:58:02 +01:00
RegConsoleCmd("sm_hide_lennies", OnToggleLennies, "Toggle blocking Lennies");
2018-12-10 23:26:23 +01:00
g_hCookieHideLennies = RegClientCookie("lennies_blocked", "are lennies blocked", CookieAccess_Protected);
2019-01-13 16:58:02 +01:00
SetCookieMenuItem(MenuHandler_CookieMenu, 0, "Hide Lennies");
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action OnToggleLennies(int client, int args)
{
ToggleLennies(client);
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ShowSettingsMenu(int client)
{
Menu menu = new Menu(MenuHandler_MainMenu);
menu.SetTitle("AntiLenny Settings", client);
char sBuffer[128];
Format(sBuffer, sizeof(sBuffer), "Hiding Lennies: %s", g_bHideLennies[client] ? "Enabled" : "Disabled");
menu.AddItem("0", sBuffer);
menu.ExitBackButton = true;
menu.Display(client, MENU_TIME_FOREVER);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void MenuHandler_CookieMenu(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
{
switch(action)
{
case(CookieMenuAction_DisplayOption):
{
Format(buffer, maxlen, "AntiLenny", client);
}
case(CookieMenuAction_SelectOption):
{
ShowSettingsMenu(client);
}
}
2018-12-10 23:26:23 +01:00
}
2019-01-13 16:58:02 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int selection)
{
switch(action)
{
case(MenuAction_Select):
{
switch(selection)
{
case(0): ToggleLennies(client);
}
ShowSettingsMenu(client);
}
case(MenuAction_Cancel):
{
ShowCookieMenu(client);
}
case(MenuAction_End):
{
delete menu;
}
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-12-10 23:26:23 +01:00
public Action CCC_OnChatMessage(int client, int author, const char[] message)
{
2019-01-13 16:58:02 +01:00
for(int i = 0; i < NUMBEROFLENNIES; i++)
2018-12-10 23:26:23 +01:00
{
if(g_bHideLennies[client] && StrContains(message, g_cLennies[i], false) != -1)
{
return Plugin_Handled;
}
}
return Plugin_Continue;
}
2019-01-13 16:58:02 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ToggleLennies(int client)
2018-12-10 23:26:23 +01:00
{
g_bHideLennies[client] = !g_bHideLennies[client];
2019-01-13 16:58:02 +01:00
SetClientCookie(client, g_hCookieHideLennies, g_bHideLennies[client] ? "1" : "");
CPrintToChat(client, "{cyan}[AntiLenny] {white}%s", g_bHideLennies[client] ? "Lennies are now hidden" : "Lennies are not hidden anymore");
2018-12-10 23:26:23 +01:00
}
2019-01-13 16:58:02 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-12-10 23:26:23 +01:00
public void OnClientCookiesCached(int client)
{
char sBuffer[2];
GetClientCookie(client, g_hCookieHideLennies, sBuffer, sizeof(sBuffer));
if(sBuffer[0] != '\0')
{
g_bHideLennies[client] = true;
}
else
{
g_bHideLennies[client] = false;
}
}
2019-01-13 16:58:02 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-12-10 23:26:23 +01:00
public void OnClientDisconnect(int client)
{
g_bHideLennies[client] = false;
}