AntiLenny: added into !settings
This commit is contained in:
parent
1934adce30
commit
5bd15e63c1
@ -12,27 +12,114 @@ bool g_bHideLennies[MAXPLAYERS + 1] = { false, ... };
|
||||
bool g_bHideLenniesHooked = false;
|
||||
Handle g_hCookieHideLennies = null;
|
||||
|
||||
char g_cLennies[23][] = {"( ͡° ͜ʖ ͡°)", "͜ʖ", "(° ͜ʖ °)", "( ͝͠°͜ل͝͠°)", "( ͡° ͜ ͡°)", "( ͡°╭͜ʖ╮͡° )", "( ͠° ͜ʖ ͡°)", "( ° ͜ʖ °)", "(╯°□°)╯", "_(ツ)_", "_ツ_", "( ̿°̿ ͜ل͜ ̿°̿ )", "( ͡", "( ͠", "( ͝", "( °", "(͡", "ಠ_ಠ", "͡°", "°͡", "ʖ", "͡", "͜"};
|
||||
#define NUMBEROFLENNIES 23
|
||||
|
||||
char g_cLennies[NUMBEROFLENNIES][] = {"( ͡° ͜ʖ ͡°)", "͜ʖ", "(° ͜ʖ °)", "( ͝͠°͜ل͝͠°)", "( ͡° ͜ ͡°)", "( ͡°╭͜ʖ╮͡° )", "( ͠° ͜ʖ ͡°)", "( ° ͜ʖ °)", "(╯°□°)╯", "_(ツ)_", "_ツ_", "( ̿°̿ ͜ل͜ ̿°̿ )", "( ͡", "( ͠", "( ͝", "( °", "(͡", "ಠ_ಠ", "͡°", "°͡", "ʖ", "͡", "͜"};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "AntiLenny",
|
||||
author = "Dogan",
|
||||
description = "Makes it possible to selfmute Lennies",
|
||||
version = "1.2.0",
|
||||
version = "1.3.0",
|
||||
url = ""
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
RegConsoleCmd("sm_hide_lennies", HideLennies, "Toggle blocking Lennies");
|
||||
RegConsoleCmd("sm_hide_lennies", OnToggleLennies, "Toggle blocking Lennies");
|
||||
|
||||
g_hCookieHideLennies = RegClientCookie("lennies_blocked", "are lennies blocked", CookieAccess_Protected);
|
||||
|
||||
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");
|
||||
|
||||
//AddMenuItem(menu, "0", "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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// 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:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action CCC_OnChatMessage(int client, int author, const char[] message)
|
||||
{
|
||||
for(int i = 0; i < 23; i++)
|
||||
for(int i = 0; i < NUMBEROFLENNIES; i++)
|
||||
{
|
||||
if(g_bHideLennies[client] && StrContains(message, g_cLennies[i], false) != -1)
|
||||
{
|
||||
@ -42,24 +129,22 @@ public Action CCC_OnChatMessage(int client, int author, const char[] message)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action HideLennies(int client, int args)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ToggleLennies(int client)
|
||||
{
|
||||
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;
|
||||
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");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientCookiesCached(int client)
|
||||
{
|
||||
char sBuffer[2];
|
||||
@ -77,12 +162,18 @@ public void OnClientCookiesCached(int client)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_bHideLennies[client] = false;
|
||||
CheckHideLenniesHooks();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void CheckHideLenniesHooks()
|
||||
{
|
||||
bool bShouldHook = false;
|
||||
|
Loading…
Reference in New Issue
Block a user