About
Provides a super simple alert when certain players join or leave your server. Requires MySQL, and the
ripext extension.
This is the version 2.0 rewrite, featuring a high level of customization compared to 1.0... here's a brief rundown on the things that 2.0 brings to the table.
- 5 different notification types - "Added", "Removed", "Connected", "Disconnected", "Cleared", and each of them can be given a separate webhook and can mention a separate role.
- Each notification can be switched off in the config individually - handy if you don't want to be alerted for disconnects.
- Don't want certain pieces of information making it into the notification? Each field has a toggle in the config.
- Two new commands!
Some of the more sourcepawn savvy of you might have noticed that despite dropping the requirement for Zipcore's Discord/Slack api, we still use his CFG file. I hijacked it because it still did the job I needed. If you don't want to look for his API nor use it alongside this one, I provide a discord.cfg file that contains all the default webhooks for this plugin.
Installation- The very first step is to setup a database and a login for that database. You can do this however you like, the specific method will be different depending on your setup.
- Install the ripext extension.
- Upload the SMX file to your addons/sourcemod/plugins directory on your server.
- Upload the default watchlist.cfg file to your cfg/sourcemod directory
- Modify the watchlist.cfg file to your liking. The default settings should be good, but they won't reflect your server's IP or hostname.
- Modify the databases.cfg file in addons/sourcemod/configs, and add a database entry for "watchlist" (see examples below)
- Upload and modify the discord.cfg file in the same location and add webhooks for your discord server. Click here for more info on making a webhook.
- Restart your server.
Usage- watchlist_add <STEAMID> <reason> - Adds a Steam ID to the watchlist. An alert will go out to discord when you do this. Can be used from client console as long as you have KICK permissions
- watchlist_remove <STEAMID> - Removes a Steam ID from the watchlist. An alert will go out to discord when you do this. Can be used from client console as long as you have KICK permissions
- watchlist_clear - Removes ALL STEAM IDS from the watchlist. An alert will go out to discord when you do this. Can be used from client console as long as you have RCON permissions.
- watchlist_list (STEAMID or PAGE) - Lists all (or one) Steam ID from the watchlist, sorted by date descending (meaning new entries are on top), 10 at a time.
- watchlist_setup_database - Sets up the database (shouldn't need to do this, should be automatic).
- watchlist_healthcheck - Basic checkup command to make sure the config isn't scuffed.
Default watchlist.cfg
PHP Code:
// ConVars for plugin "watchlist.smx"
//////////////////////
// GENERAL SETTINGS //
//////////////////////
// Configuration for the SQL database - Required even if you use SQLite.
// -
// Default: "watchlist"
watchlist_sqlconfig "watchlist"
// The name of the server - will be used as the username for the webhook.
// -
// Default: "My TF2 Server"
watchlist_server_name "My TF2 Server"
// The IP or URL that players can use to connect to your server (including port). Will be used to provide a connect link in the webhook.
// -
// Default: "127.0.0.1"
watchlist_server_ip "127.0.0.1"
///////////////////////
// FALLBACK SETTINGS //
///////////////////////
// The fallback webhook config - if no webhook is given for a specific notification, use this one.
// -
// Default: "fallback"
watchlist_fallback_webhook "fallback"
// The fallback mention - if no mention is given for a specific notification, use this one.
// -
// Default: "@here"
watchlist_fallback_mention "@here"
///////////////////////////
// CONNECT NOTIFICATIONS //
///////////////////////////
// Enable the connect notification.
// -
// Default: 1
watchlist_notify_connect_enabled 1
// Which webhook config to use
// -
// Default: "connected"
watchlist_notify_connect_webhook "connected"
// The color for this embed - needs to be hex, as a base10 int. See the forum post for more info.
// -
// Default: 65280 (is the same as #00ff00 or 0,255,0)
watchlist_notify_connect_color 65280
// Mention for this embed
// -
// Default: "@here"
watchlist_notify_connect_mention "@here"
//////////////////////////////
// DISCONNECT NOTIFICATIONS //
//////////////////////////////
// Enable the disconnect notification.
// -
// Default: 1
watchlist_notify_disconnect_enabled 1
// Which webhook config to use
// -
// Default: "disconnected"
watchlist_notify_disconnect_webhook "disconnected"
// The color for this embed - needs to be hex, as a base10 int. See the forum post for more info.
// -
// Default: 16711680 (is the same as #ff0000 or 255,0,0)
watchlist_notify_disconnect_color 16711680
// Mention for this embed
// -
// Default: "@here"
watchlist_notify_disconnect_mention "@here"
/////////////////////////
// ADDED NOTIFICATIONS //
/////////////////////////
// Enable the added notification.
// -
// Default: 1
watchlist_notify_added_enabled 1
// Which webhook config to use
// -
// Default: "added"
watchlist_notify_added_webhook "added"
// The color for this embed - needs to be hex, as a base10 int. See the forum post for more info.
// -
// Default: 16711935 (is the same as #ff00ff or 255,0,255)
watchlist_notify_added_color 16711935
// Mention for this embed
// -
// Default: "@here"
watchlist_notify_added_mention "@here"
///////////////////////////
// REMOVED NOTIFICATIONS //
///////////////////////////
// Enable the removed notification.
// -
// Default: 1
watchlist_notify_removed_enabled 1
// Which webhook config to use
// -
// Default: "removed"
watchlist_notify_removed_webhook "removed"
// The color for this embed - needs to be hex, as a base10 int. See the forum post for more info.
// -
// Default: 65535 (is the same as #00ffff or 0,255,255)
watchlist_notify_removed_color 65535
// Mention for this embed
// -
// Default: "@here"
watchlist_notify_removed_mention "@here"
///////////////////////////
// CLEARED NOTIFICATIONS //
///////////////////////////
// Enable the cleared notification.
// -
// Default: 1
watchlist_notify_cleared_enabled 1
// Which webhook config to use
// -
// Default: "cleared"
watchlist_notify_cleared_webhook "cleared"
// The color for this embed - needs to be hex, as a base10 int. See the forum post for more info.
// -
// Default: 16777215 (is the same as #ffffff or 255,255,255)
watchlist_notify_cleared_color 16777215
// Mention for this embed
// -
// Default: "@here"
watchlist_notify_cleared_mention "@here"
//////////////////
// EMBED FIELDS //
//////////////////
// Send the Player Name in the notification.
// -
// Default: 1
watchlist_embed_field_player 1
// Send the SteamID in the notification.
// -
// Default: 1
watchlist_embed_field_steamid 1
// Send the IP Address in the notification. Off by default because it's rarely useful in banning a user.
// -
// Default: 0
watchlist_embed_field_ip 0
// Send the Profile URL in the notification.
// -
// Default: 1
watchlist_embed_field_profile 1
// Send the Watched Since in the notification.
// -
// Default: 1
watchlist_embed_field_watched_since 1
// Send the Watched By in the notification.
// -
// Default: 1
watchlist_embed_field_watched_by 1
// Send the Reason in the notification.
// -
// Default: 1
watchlist_embed_field_reason 1
// Send the Server Name in the notification.
// -
// Default: 1
watchlist_embed_field_server 1
Example Database Configuration
PHP Code:
"watchlist"
{
"driver" "mysql"
"host" "12.34.56.78"
"database" "database"
"user" "username"
"pass" "secretPassword"
//"timeout" "0"
"port" "3306"
}
Example Discord Configuration
PHP Code:
"Discord"
{
"connected"
{
"url" "https://discord.com/api/webhooks/asdfasdfasdfasdf"
}
"disconnected"
{
"url" "https://discord.com/api/webhooks/asdfasdfasdfasdf"
}
"added"
{
"url" "https://discord.com/api/webhooks/asdfasdfasdfasdf"
}
"removed"
{
"url" "https://discord.com/api/webhooks/asdfasdfasdfasdf"
}
"cleared"
{
"url" "https://discord.com/api/webhooks/asdfasdfasdfasdf"
}
"fallback"
{
"url" "https://discord.com/api/webhooks/asdfasdfasdfasdf"
}
}
Things that are out of scope for this- Steam/Pushbullet/Any other platform - Not particularly interested, sorry. Source code is there, it wouldn't be too hard to adapt it to pushbullet, but interacting with Steam is a hell I'd wish upon nobody. Good luck if you wanna do this.
- Watch by IP - I thought about this for a while, and I came to the conclusion that while there is a use case to be argued for tracking an IP address, there's so much abuse that could be had from that. I won't enable it. (Also for my own setup I have another method of connecting IPs to alt accounts)
Compiling this yourself!
This plugin makes use of two external includes. Firstly, there's
Discord Webhook API by Sarrus1, and secondly there's
DateTime by Nexd/KillStr3aK. You also technically need ripext but the includes are bundles with the Webhook API. You still need the extension for it running on your server.
Code:
CHANGELOG:
NEWEST VERSION IS ALWAYS AT THE TOP
2.1 - Hotfix for errors on disconnect.
2.0 - Complete rewrite, added watchlist_list and watchlist_clear, made the discord.smx plugin obsolete, uninstalled sanity from my brain, fixed the database not making itself automatically.
1.1 - Fixed a bug where if you modified the watchlist from console, the "Admin" would appear to be the server's hostname (but cut off). Instead, it now displays "Console".
1.0 - Release
... everybody laugh at my terrible code.
(Shoutouts to the AlliedModders discord for helping me out with a ton of stuff)