Skip to content

Commit 87aad32

Browse files
committed
v1.1.1 - Optional Discord exclusion in compilation process, added text logging (requested by RGL)
1 parent 361c92d commit 87aad32

File tree

6 files changed

+51
-15
lines changed

6 files changed

+51
-15
lines changed

.github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
cd ./scripting
3131
pwd
3232
spcomp -i"./include/" demo_check.sp -o ../plugins/demo_check.smx
33+
spcomp -i"./include/" NO_DISCORD=true demo_check.sp -o ../plugins/demo_check_no_discord.smx
3334
ls -la
3435
3536
- name: Zip packages

README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ This plugin is used to check if players are recording demos or not.
66

77
All includes and extensions are bundled with this repository. Special thanks to [Dr. McKay](https://github.com/DoctorMcKay/sourcemod-plugins/blob/master/scripting/include/morecolors.inc) and [Sapphonie](https://github.com/sapphonie/StAC-tf2) from whom I shamelessly stole morecolors.inc and SteamWorks.inc/discord.inc (plus extensions) from.
88

9+
Note: Don't like Discord? You can compile without Discord by passing `NO_DISCORD=true` to spcomp.
10+
11+
```bash
12+
./spcomp64 -i"/path/to/sourcemod/scripting/include" -i"/path/to/demo_check/repo/clone/scripting/include" NO_DISCORD=true "/path/to/demo_check/repo/clone/scripting/demo_check.sp" -o "/path/to/demo_check/repo/clone/plugins/demo_check_no_demo.smx"
13+
```
14+
915
## Installation
1016

1117
1. Download the plugin from the [releases page](https://github.com/ozfortres/demo-check-plugin/releases).
12-
2. Install the `plugins/demo_check.smx` file into your `tf/addons/sourcemod/plugins` directory.
18+
2. Install the `plugins/demo_check.smx` file or the `plugins/demo_check_no_discord.smx` file into your `tf/addons/sourcemod/plugins` directory.
1319
3. Install the `translations/demo_check.phrases.txt` file into your `tf/addons/sourcemod/translations` directory.
1420
4. Restart your server.
1521

@@ -20,12 +26,13 @@ The plugin has a few cvars that can be configured:
2026
- `sm_democheck_enabled <0/1>` - Enable or disable the plugin. Default: `1`
2127
- `sm_democheck_onreadyup <0/1>` - Performs an additional check at ready up. Requires SoapDM to be running. Default: `0`
2228
- `sm_democheck_warn <0/1>` - Set the plugin into warning only mode. Default: `0`. If enabled, players will be warned if they are not recording demos, but will not be kicked.
29+
- `sm_democheck_announce_textfile <0/1>` - Log kicks to a text file (democheck.log). Default: `0`
2330

2431
Additionally if your use case requires different languages or links to documentation, you can modify the `demo_check.phrases.txt` file in the `translations` directory. Currently only English is supported, and existing documentation links are for ozfortress.
2532

2633
We've also included Discord Webhook support! Starting from version 1.1.0, you can now configure the plugin to send a message to a Discord webhook when a player is kicked for not recording demos. To enable this feature, you will need to set the following cvars:
2734

28-
- `sm_democheck_announce_discord <0/1>` - Enable or disable the Discord webhook feature. Default: `0`
35+
- `sm_democheck_announce_discord <0/1>` - Enable or disable the Discord webhook feature. Default: `0`. This Cvar and feature is not included when compiled with NO_DISCORD=true
2936

3037
Additionally, modify `/tf/addons/sourcemod/configs/discord.cfg` with the following:
3138

plugins/demo_check.smx

376 Bytes
Binary file not shown.

plugins/demo_check_no_discord.smx

12.2 KB
Binary file not shown.

scripting/demo_check.sp

+35-13
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,39 @@
44
* Plugin to check if a player is recording a demo.
55
*/
66

7-
/**
8-
* DEV NOTES
9-
*
10-
* https://sourcemod.dev/#/convars/function.QueryClientConVar
11-
*
12-
* ds_enable 0/1/2 - if set to one of these, boot with config on, warn with config off
13-
* ds_enable 3 - if this is on, a ok
14-
* ds_autodelete 1 instant boot with config on, prompt player to turn it off
15-
*/
16-
177
#include <sourcemod>
188
#include <sdktools>
199
#include <morecolors>
2010
#include <SteamWorks>
11+
#if !defined NO_DISCORD
2112
#include <discord>
13+
#endif
2214

2315
#define DEMOCHECK_TAG "{lime}[{red}Demo Check{lime}]{white} "
2416

2517
public Plugin:myinfo =
2618
{
19+
#if !defined NO_DISCORD
2720
name = "Demo Check",
21+
#else
22+
name = "Demo Check (No Discord)",
23+
#endif
2824
author = "Shigbeard",
2925
description = "Checks if a player is recording a demo",
30-
version = "1.1.0",
26+
version = "1.1.1",
3127
url = "https://ozfortress.com/"
3228
};
3329

3430
ConVar g_bDemoCheckEnabled;
3531
ConVar g_bDemoCheckOnReadyUp; // Requires SoapDM
3632
ConVar g_bDemoCheckWarn;
3733
ConVar g_bDemoCheckAnnounce;
34+
#if !defined NO_DISCORD
3835
ConVar g_bDemoCheckAnnounceDiscord; // Requires Discord
3936
ConVar g_HostName;
4037
ConVar g_HostPort;
38+
#endif
39+
ConVar g_bDemoCheckAnnounceTextFile; // Dumps to a text file
4140

4241
public void OnPluginStart()
4342
{
@@ -48,7 +47,12 @@ public void OnPluginStart()
4847

4948
g_bDemoCheckWarn = CreateConVar("sm_democheck_warn", "0", " Set the plugin into warning only mode.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
5049
g_bDemoCheckAnnounce = CreateConVar("sm_democheck_announce", "1", "Announce passed demo checks to chat", FCVAR_NOTIFY, true, 0.0, true, 1.0);
50+
#if !defined NO_DISCORD
5151
g_bDemoCheckAnnounceDiscord = CreateConVar("sm_democheck_announce_discord", "0", "Announce failed demo checks to discord", FCVAR_NOTIFY, true, 0.0, true, 1.0);
52+
g_HostName = FindConVar("hostname");
53+
g_HostPort = FindConVar("hostport");
54+
#endif
55+
g_bDemoCheckAnnounceTextFile = CreateConVar("sm_democheck_announce_textfile", "0", "Dump failed demo checks to a text file", FCVAR_NOTIFY, true, 0.0, true, 1.0);
5256

5357
RegServerCmd("sm_democheck", Cmd_DemoCheck_Console, "Check if a player is recording a demo", 0);
5458
RegServerCmd("sm_democheck_enable", Cmd_DemoCheckEnable_Console, "Enable demo check", 0);
@@ -57,8 +61,6 @@ public void OnPluginStart()
5761

5862
HookConVarChange(g_bDemoCheckEnabled, OnDemoCheckEnabledChange)
5963

60-
g_HostName = FindConVar("hostname");
61-
g_HostPort = FindConVar("hostport");
6264
}
6365

6466
public void SOAP_StopDeathMatching()
@@ -265,6 +267,7 @@ public Action Timer_KickClient(Handle timer, int client)
265267
{
266268
return Plugin_Stop;
267269
}
270+
#if !defined NO_DISCORD
268271
if (GetConVarBool(g_bDemoCheckAnnounceDiscord))
269272
{
270273
char sName[64];
@@ -302,6 +305,25 @@ public Action Timer_KickClient(Handle timer, int client)
302305
Format(sMsg, sizeof(sMsg), "[Demo Check] %t", "discord_democheck", sName, sSteamID, sProfileURL, sServerName, sServerIP);
303306
Discord_SendMessage("democheck", sMsg);
304307
}
308+
#endif
309+
if (GetConVarBool(g_bDemoCheckAnnounceTextFile))
310+
{
311+
char sName[64];
312+
char sSteamID[64];
313+
char sProfileURL[64];
314+
char sDateTime[64];
315+
FormatTime(sDateTime, sizeof(sDateTime), "%Y-%m-%d %H:%M:%S");
316+
GetClientName(client, sName, sizeof(sName));
317+
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
318+
GetClientAuthId(client, AuthId_SteamID64, sProfileURL, sizeof(sProfileURL));
319+
Format(sProfileURL, sizeof(sProfileURL), "https://steamcommunity.com/profiles/%s", sProfileURL);
320+
GetClientName(client, sName, sizeof(sName));
321+
char sMsg[512];
322+
Format(sMsg, sizeof(sMsg), "[Demo Check] %t", sName, sSteamID, sProfileURL, sDateTime);
323+
Handle file = OpenFile("democheck.log", "a");
324+
WriteFileLine(file, sMsg);
325+
CloseHandle(file);
326+
}
305327
KickClient(client, "[Demo Check] %t", "kicked");
306328
return Plugin_Stop;
307329
}

translations/demo_check.phrases.txt

+6
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,10 @@
5252
"#format" "{1:s},{2:s},{3:s},{4:s},{5:s}"
5353
"en" "[{1} ({2})]({3}) failed the demo check at {4} - `{5}`"
5454
}
55+
56+
"logs_democheck"
57+
{
58+
"#format" "{1:s},{2:s},{3:s},{4:s}"
59+
"en" "{4} - {1} ({2}) [{3}] failed the demo check"
60+
}
5561
}

0 commit comments

Comments
 (0)