Couch/EventNotifier changes

This commit is contained in:
2026-10-08 16:28:13 +01:00
parent 54a921c1a5
commit 82d16c163a
3 changed files with 53 additions and 12 deletions
+5 -1
View File
@@ -639,12 +639,16 @@ bool IsClientRefused(int couch, int client, bool notify = true)
return false;
}
// Without the playtime plugin nobody is refused.
// Without the playtime plugin nobody is refused. Admins (ADMFLAG_GENERIC by default) skip the
// tier check; change who with an admin override on "sm_couch_tier_bypass".
bool MeetsTier(int client, int required)
{
if (required <= 0)
return true;
if (CheckCommandAccess(client, "sm_couch_tier_bypass", ADMFLAG_GENERIC))
return true;
if (GetFeatureStatus(FeatureType_Native, "GetPlayerTier_native") != FeatureStatus_Available)
return true;
+7 -6
View File
@@ -40,7 +40,7 @@ public void OnPluginStart()
RegAdminCmd("sm_gotocouch", Command_GotoCouch, ADMFLAG_CHANGEMAP, "Teleports you to the couch");
RegAdminCmd("sm_removecouch", Command_RemoveCouch, ADMFLAG_CHANGEMAP, "Removes the couch");
RegAdminCmd("sm_couchpistolonly", Command_PistolOnly, ADMFLAG_CHANGEMAP, "sm_couchpistolonly [0|1] - only pistols and knives move the couch; no argument toggles");
RegAdminCmd("sm_couchlog", Command_Log, ADMFLAG_CHANGEMAP, "sm_couchlog [0|1] - show who moves the couch and how in your console, grenades in chat too; no argument toggles");
RegAdminCmd("sm_couchlog", Command_Log, ADMFLAG_CHANGEMAP, "sm_couchlog [0|1] - show who moves the couch and how in your console; no argument toggles");
}
// Game time restarts with the map.
@@ -314,7 +314,7 @@ void DoSetLogging(int client, bool bEnable)
g_bLogging[client] = bEnable;
if (bEnable)
PrintToChat(client, PREFIX ... "\x01Couch log \x04on\x01, see your console for who moves the couch and how. Grenades also show here.");
PrintToChat(client, PREFIX ... "\x01Couch log \x04on\x01, see your console for who moves the couch and how.");
else
PrintToChat(client, PREFIX ... "\x01Couch log \x04off\x01.");
}
@@ -325,6 +325,11 @@ void DoSetLogging(int client, bool bEnable)
public void Couch_OnCouchInteraction(int couch, int client, CouchMethod method, const char[] weapon)
{
// Grenades are rare and knock the couch far, so everyone is told. One blast is one report, so no
// rate limit is needed. The userid is there so an admin can put it straight into sm_couchban.
if (method == CouchMethod_Grenade)
PrintToChatAll("\x01[Couch] \x04%N\x01 (#%d) hit the couch with a \x04grenade", client, GetClientUserId(client));
if (!AnyoneLogging())
return;
@@ -354,7 +359,6 @@ public void Couch_OnCouchInteraction(int couch, int client, CouchMethod method,
default: FormatEx(sHow, sizeof(sHow), "moved the couch with %s", weapon[0] != '\0' ? weapon : "something");
}
// Everything goes to the console; grenades are rare and knock the couch far, so they go to chat too.
// The userid is there so it can go straight into sm_couchban.
int userid = GetClientUserId(client);
for (int i = 1; i <= MaxClients; i++)
@@ -363,9 +367,6 @@ public void Couch_OnCouchInteraction(int couch, int client, CouchMethod method,
continue;
PrintToConsole(i, "[Couch] %N (#%d) %s", client, userid, sHow);
if (method == CouchMethod_Grenade)
PrintToChat(i, "\x01[Couch] \x04%N\x01 (#%d) hit the couch with a \x04grenade", client, userid);
}
}
@@ -45,7 +45,7 @@ public void OnPluginStart()
AutoExecConfig(true, "EventNotifierAnnouncements");
RegAdminCmd("sm_event_announce", Command_Announce, ADMFLAG_GENERIC, "Posts the next event announcement in chat now");
RegAdminCmd("sm_event_announce", Command_Announce, ADMFLAG_GENERIC, "sm_event_announce [event number] - Posts an event announcement in chat now (next in rotation if no number given)");
}
public void OnConfigsExecuted()
@@ -80,10 +80,38 @@ public Action Timer_Announce(Handle timer)
public Action Command_Announce(int client, int args)
{
if (PostAnnouncement())
ReplyToCommand(client, "[Events] Announcement posted.");
if (args < 1)
{
if (PostAnnouncement())
ReplyToCommand(client, "[Events] Announcement posted.");
else
ReplyToCommand(client, "[Events] No upcoming events to announce.");
return Plugin_Handled;
}
char arg[16];
GetCmdArg(1, arg, sizeof(arg));
int number;
if (StringToIntEx(arg, number) != strlen(arg) || number <= 0)
{
ReplyToCommand(client, "[Events] Usage: sm_event_announce [event number]");
return Plugin_Handled;
}
int index = EventNotifier_FindEventByNumber(number);
if (index == -1)
{
ReplyToCommand(client, "[Events] Event #%d is not in the upcoming list.", number);
return Plugin_Handled;
}
// Explicitly requested events are posted outside the rotation so the
// automatic announcements carry on where they left off.
if (AnnounceEvent(index))
ReplyToCommand(client, "[Events] Announcement for event #%d posted.", number);
else
ReplyToCommand(client, "[Events] No upcoming events to announce.");
ReplyToCommand(client, "[Events] Event #%d could not be announced.", number);
return Plugin_Handled;
}
@@ -91,7 +119,8 @@ public Action Command_Announce(int client, int args)
// Announcement
// ---------------------------------------------------------------------------
// Posts one event from the rotation window. Returns false when there is nothing to post.
// Posts the next event from the rotation window and advances the rotation.
// Returns false when there is nothing to post.
bool PostAnnouncement()
{
int count = EventNotifier_GetEventCount();
@@ -105,6 +134,13 @@ bool PostAnnouncement()
int index = g_iRotation % window;
g_iRotation = (index + 1) % window;
return AnnounceEvent(index);
}
// Posts the event at the given list index to everyone. Returns false if the
// index is out of range.
bool AnnounceEvent(int index)
{
EventInfo ev;
if (!EventNotifier_GetEvent(index, ev))
return false;