EventNotifier should show dates/times in the client's timezone

This commit is contained in:
2026-09-29 18:58:22 +01:00
parent cbe461ac26
commit d6f3d622dd
6 changed files with 7787 additions and 14 deletions
@@ -5,7 +5,7 @@
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1.0"
#define PLUGIN_VERSION "1.1"
// Shortest automatic announcement interval, in seconds. Values below this are
// raised to it; 0 or below disables the timer entirely.
@@ -114,21 +114,25 @@ bool PostAnnouncement()
if (!name[0])
strcopy(name, sizeof(name), "Unnamed event");
int now = GetTime();
char span[32];
if (ev.start <= 0)
{
CPrintToChatAll("{darkorange}[Events] {yellow}#%d: {lightgreen}%s {grey}date TBA", ev.number, name);
}
else if (now < ev.start)
{
EventNotifier_FormatDuration(ev.start - now, span, sizeof(span));
CPrintToChatAll("{darkorange}[Events] {yellow}#%d: {lightgreen}%s {lime}starts in %s", ev.number, name, span);
}
else
{
EventNotifier_FormatDuration(now - ev.start, span, sizeof(span));
CPrintToChatAll("{darkorange}[Events] {yellow}#%d: {lightgreen}%s {orchid}started %s ago", ev.number, name, span);
// Each player gets the start time in their own timezone.
bool started = GetTime() >= ev.start;
for (int client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client) || IsFakeClient(client))
continue;
char when[48];
EventNotifier_FormatClientTime(client, ev.start, when, sizeof(when), false);
// CPrintToChatEx rather than CPrintToChat: the latter only accepts string format arguments.
CPrintToChatEx(client, client, "{darkorange}[Events] {yellow}#%d: {lightgreen}%s %s %s", ev.number, name,
started ? "{orchid}started" : "{white}starts{lime}", when);
}
}
if (ev.maps[0])