ConnectAnnounce: sm_hide_connect_csays vip only

This commit is contained in:
Dogan 2019-10-29 16:36:30 +01:00
parent c0e6fce862
commit e9ca5cbe77

View File

@ -30,7 +30,7 @@ public Plugin myinfo = {
name = "Connect Announce", name = "Connect Announce",
author = "Neon + Botox + Dogan", author = "Neon + Botox + Dogan",
description = "Connect Announcer with special features for VIPS", description = "Connect Announcer with special features for VIPS",
version = "3.0", version = "3.1",
url = "" url = ""
} }
@ -50,7 +50,7 @@ public void OnPluginStart()
RegAdminCmd("sm_joinmsg", Command_JoinMsg, ADMFLAG_CUSTOM1, "Sets a custom message which will be shown upon connecting to the server"); RegAdminCmd("sm_joinmsg", Command_JoinMsg, ADMFLAG_CUSTOM1, "Sets a custom message which will be shown upon connecting to the server");
RegAdminCmd("sm_resetjoinmsg", Command_ResetJoinMsg, ADMFLAG_CUSTOM1, "Resets your custom connect message"); RegAdminCmd("sm_resetjoinmsg", Command_ResetJoinMsg, ADMFLAG_CUSTOM1, "Resets your custom connect message");
RegConsoleCmd("sm_hide_connect_csays", OnToggleHideCsays, "Toggle blocking connect csay messages"); RegAdminCmd("sm_hide_connect_csays", OnToggleHideCsays, ADMFLAG_CUSTOM1, "Toggle blocking connect csay messages");
g_hCookieHideCsays = RegClientCookie("csays_blocked", "are csays blocked", CookieAccess_Protected); g_hCookieHideCsays = RegClientCookie("csays_blocked", "are csays blocked", CookieAccess_Protected);
@ -71,6 +71,15 @@ public void OnDatabaseConnect(Database db, const char[] error, any data)
g_hDatabase = db; g_hDatabase = db;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientCookiesCached(int client)
{
if(IsClientAuthorized(client))
ReadClientCookies(client);
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -85,20 +94,17 @@ public void ToggleHideCsays(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientCookiesCached(int client) public void ReadClientCookies(int client)
{ {
char sBuffer[2]; char sBuffer[2];
GetClientCookie(client, g_hCookieHideCsays, sBuffer, sizeof(sBuffer)); if(CheckCommandAccess(client, "", ADMFLAG_CUSTOM1))
GetClientCookie(client, g_hCookieHideCsays, sBuffer, sizeof(sBuffer));
if(sBuffer[0] != '\0') if(sBuffer[0] != '\0')
{
g_bHideCsays[client] = true; g_bHideCsays[client] = true;
}
else else
{
g_bHideCsays[client] = false; g_bHideCsays[client] = false;
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -123,6 +129,12 @@ public Action OnToggleHideCsays(int client, int args)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void ShowSettingsMenu(int client) public void ShowSettingsMenu(int client)
{ {
if(!CheckCommandAccess(client, "", ADMFLAG_CUSTOM1))
{
PrintToChat(client, "[SM] You don't have access to these Settings.");
return;
}
Menu menu = new Menu(MenuHandler_MainMenu); Menu menu = new Menu(MenuHandler_MainMenu);
menu.SetTitle("ConnectCsay Settings", client); menu.SetTitle("ConnectCsay Settings", client);
@ -434,8 +446,11 @@ public void TQueryCB(Handle owner, Handle rs, const char[] error, any data)
CPrintToChatAll(sRawMsg); CPrintToChatAll(sRawMsg);
for(int i = 1; i <= MaxClients; i++) for(int i = 1; i <= MaxClients; i++)
{ {
if(!g_bHideCsays[i] && IsClientInGame(i)) if(IsClientInGame(i))
{ {
if(g_bHideCsays[i] || (g_bHideCsays[i] && client == i))
continue;
PrintCenterText(i, "%s %s %s", "[VIP]", sName, "connected"); PrintCenterText(i, "%s %s %s", "[VIP]", sName, "connected");
} }
} }
@ -446,8 +461,11 @@ public void TQueryCB(Handle owner, Handle rs, const char[] error, any data)
CPrintToChatAll(sFinalMessage); CPrintToChatAll(sFinalMessage);
for(int i = 1; i <= MaxClients; i++) for(int i = 1; i <= MaxClients; i++)
{ {
if(!g_bHideCsays[i] && IsClientInGame(i)) if(IsClientInGame(i))
{ {
if(g_bHideCsays[i] || (g_bHideCsays[i] && client == i))
continue;
CRemoveTags(sCustomMessage, 256); CRemoveTags(sCustomMessage, 256);
PrintCenterText(i, "%s %s %s %s", "[VIP]", sName, "connected", sCustomMessage); PrintCenterText(i, "%s %s %s %s", "[VIP]", sName, "connected", sCustomMessage);
} }
@ -459,8 +477,11 @@ public void TQueryCB(Handle owner, Handle rs, const char[] error, any data)
CPrintToChatAll(sRawMsg); CPrintToChatAll(sRawMsg);
for(int i = 1; i <= MaxClients; i++) for(int i = 1; i <= MaxClients; i++)
{ {
if(!g_bHideCsays[i] && IsClientInGame(i)) if(IsClientInGame(i))
{ {
if(g_bHideCsays[i] || (g_bHideCsays[i] && client == i))
continue;
PrintCenterText(i, "%s %s %s", "[VIP]", sName, "connected"); PrintCenterText(i, "%s %s %s", "[VIP]", sName, "connected");
} }
} }
@ -474,6 +495,9 @@ public void OnClientPostAdminCheck(int client)
if(IsFakeClient(client)) if(IsFakeClient(client))
return; return;
if(AreClientCookiesCached(client))
ReadClientCookies(client);
if(g_hDatabase == INVALID_HANDLE) if(g_hDatabase == INVALID_HANDLE)
return; return;