add cookies to save sm_hide_lennies
This commit is contained in:
parent
c33b9284a3
commit
6a9a9ee612
@ -6,8 +6,11 @@
|
||||
#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][] = {"( ͡° ͜ʖ ͡°)", "͜ʖ", "(° ͜ʖ °)", "( ͝͠°͜ل͝͠°)", "( ͡° ͜ ͡°)", "( ͡°╭͜ʖ╮͡° )", "( ͠° ͜ʖ ͡°)", "( ° ͜ʖ °)", "(╯°□°)╯", "_(ツ)_", "_ツ_", "( ̿°̿ ͜ل͜ ̿°̿ )", "( ͡", "( ͠", "( ͝", "( °", "(͡", "ಠ_ಠ", "͡°", "°͡", "ʖ", "͡", "͜"};
|
||||
|
||||
@ -23,6 +26,8 @@ public Plugin myinfo =
|
||||
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)
|
||||
@ -45,19 +50,56 @@ public Action CCC_OnChatMessage(int client, int author, const char[] message)
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user