diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index d45a4218..d5730fa4 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -102,6 +102,7 @@ float gF_PauseEyeAngles[MAXPLAYERS+1][3]; // cookies Handle gH_HideCookie = null; Handle gH_CheckpointsCookie = null; +Cookie gH_BlockAdvertsCookie = null; // cvars Convar gCV_GodMode = null; @@ -290,6 +291,8 @@ public void OnPluginStart() gA_Advertisements = new ArrayList(300); hostname = FindConVar("hostname"); hostport = FindConVar("hostport"); + RegConsoleCmd("sm_toggleadverts", Command_ToggleAdverts, "Toggles visibility of advertisements"); + gH_BlockAdvertsCookie = new Cookie("shavit-blockadverts", "whether to block shavit-misc advertisements", CookieAccess_Private); // cvars and stuff gCV_GodMode = new Convar("shavit_misc_godmode", "3", "Enable godmode for players?\n0 - Disabled\n1 - Only prevent fall/world damage.\n2 - Only prevent damage from other players.\n3 - Full godmode.", 0, true, 0.0, true, 3.0); @@ -890,6 +893,17 @@ public Action Timer_Advertisement(Handle timer) { if(IsClientConnected(i) && IsClientInGame(i)) { + if(AreClientCookiesCached(i)) + { + char sCookie[2]; + gH_BlockAdvertsCookie.Get(i, sCookie, sizeof(sCookie)); + + if (sCookie[0] == '1') + { + continue; + } + } + char sTempMessage[300]; gA_Advertisements.GetString(gI_AdvertisementsCycle, sTempMessage, 300); @@ -1612,6 +1626,19 @@ public Action Command_Spec(int client, int args) return Plugin_Handled; } +public Action Command_ToggleAdverts(int client, int args) +{ + if (IsValidClient(client)) + { + char sCookie[4]; + gH_BlockAdvertsCookie.Get(client, sCookie, sizeof(sCookie)); + gH_BlockAdvertsCookie.Set(client, (sCookie[0] == '1') ? "0" : "1"); + Shavit_PrintToChat(client, "%T", (sCookie[0] == '1') ? "AdvertisementsEnabled" : "AdvertisementsDisabled", client); + } + + return Plugin_Handled; +} + public Action Command_Teleport(int client, int args) { if(!IsValidClient(client)) diff --git a/addons/sourcemod/translations/shavit-misc.phrases.txt b/addons/sourcemod/translations/shavit-misc.phrases.txt index 2255173d..4a72280b 100644 --- a/addons/sourcemod/translations/shavit-misc.phrases.txt +++ b/addons/sourcemod/translations/shavit-misc.phrases.txt @@ -199,4 +199,12 @@ "#format" "{1:s},{2:s}" "en" "{1}NEW {2} WR!!!" } + "AdvertisementsEnabled" + { + "en" "Advertisements enabled" + } + "AdvertisementsDisabled" + { + "en" "Advertisements disabled" + } }