Raised This Month: $51 Target: $400
 12% 

[ANY] Player Watchlist


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Shigbeard
Junior Member
Join Date: Oct 2021
Location: Hell
Plugin ID:
8075
Plugin Version:
2.1
Plugin Category:
Server Management
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Get alerted when specific players join or leave your server
    Old 06-05-2022 , 14:57   [ANY] Player Watchlist
    Reply With Quote #1

    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
    1. 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.
    2. Install the ripext extension.
    3. Upload the SMX file to your addons/sourcemod/plugins directory on your server.
    4. Upload the default watchlist.cfg file to your cfg/sourcemod directory
    5. 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.
    6. Modify the databases.cfg file in addons/sourcemod/configs, and add a database entry for "watchlist" (see examples below)
    7. 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.
    8. 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)
    Attached Files
    File Type: sp Get Plugin or Get Source (watchlist.sp - 101 views - 56.0 KB)
    File Type: smx watchlist.smx (18.3 KB, 57 views)
    File Type: zip watchlist.zip (30.7 KB, 92 views)
    __________________

    Last edited by Shigbeard; 06-09-2022 at 17:32. Reason: Rewrite notice
    Shigbeard is offline
    Shigbeard
    Junior Member
    Join Date: Oct 2021
    Location: Hell
    Old 06-05-2022 , 15:02   Re: [ANY] Player Watchlist
    Reply With Quote #2

    Migrating from 1.0
    Migrating is super simple, and easy to do...

    First... Save the webhook url from your old webhook and remove the /slack on the end. Append these to the new example discord.cfg file.

    Next, gently throw your watchlist.cfg into the trash and start with the new one.

    Finally, remove the old discord.smx file.

    How do I get the color values for the embeds?

    Simple. Use your fav color picker to get the HEX value of your color. So, red would be #FF0000. Press F12 in any browser, and goto the console. Put in your hex code, and replace the # with 0x. The number it gives you there is the number you want to use.

    Coming soon when I'm not about to pass out: screenshots of the embeds

    Last edited by Shigbeard; 06-09-2022 at 17:37.
    Shigbeard is offline
    freak.exe_uLow
    AlliedModders Donor
    Join Date: Jul 2012
    Location: Germany
    Old 06-07-2022 , 13:11   Re: [ANY] Player Watchlist
    Reply With Quote #3

    good plugin but if i remove this

    Quote:
    // Configuration for the SQL database
    // -
    // Default: "watchlist"
    watchlist_sqlconfig "HERE"
    i get this error....as i understand it is only for sql database and not mysql or? what is also strange is when I add a user via server (the watchlist is then entered here), but as soon as one of the users join, I get no message in the Discord.
    [watchlist.smx] [Player Watchlist] Error querying database: Table 'prometheus.watchlist' doesn't exist

    for once my line is not called prometheus but watchlist
    HTML Code:
    "watchlist"
        {
            "driver"              "mysql"
            "host"                "MYIP"
            "database"            "watchlist"
            "user"                "watchlist"
            "pass"                "MYPASSWORD"
        }
    }
    the "default" uses something else and works with my store system. If I also enter at the line watchlist, I get no message as soon as the player who is in the list on the Discord a message. Errors in the log are not present, use various other systems that work with the game server (eg Calladmin). I have checked everything and changed the IP to local and really do not see my error as no error log is created except when I remove watchlist from the watchlist.cfg at sql. Do you have any idea what the problem is?

    Last edited by freak.exe_uLow; 06-07-2022 at 13:12.
    freak.exe_uLow is offline
    Shigbeard
    Junior Member
    Join Date: Oct 2021
    Location: Hell
    Old 06-07-2022 , 13:23   Re: [ANY] Player Watchlist
    Reply With Quote #4

    Quote:
    Originally Posted by freak.exe_uLow View Post
    good plugin but if i remove this



    i get this error....as i understand it is only for sql database and not mysql or? what is also strange is when I add a user via server (the watchlist is then entered here), but as soon as one of the users join, I get no message in the Discord.
    [watchlist.smx] [Player Watchlist] Error querying database: Table 'prometheus.watchlist' doesn't exist

    for once my line is not called prometheus but watchlist
    HTML Code:
    "watchlist"
        {
            "driver"              "mysql"
            "host"                "MYIP"
            "database"            "watchlist"
            "user"                "watchlist"
            "pass"                "MYPASSWORD"
        }
    }
    the "default" uses something else and works with my store system. If I also enter at the line watchlist, I get no message as soon as the player who is in the list on the Discord a message. Errors in the log are not present, use various other systems that work with the game server (eg Calladmin). I have checked everything and changed the IP to local and really do not see my error as no error log is created except when I remove watchlist from the watchlist.cfg at sql. Do you have any idea what the problem is?
    That config option refers to a config entry in the mysql config - it's not explicitly for SQLite. I'm in the middle of a huge patch so I'll add fallback logic for that entry being missing. In the mean time, re-add it to restore functionality.

    By default, if there is no configured mysql configuration for the watchlist, it will switch to the "default" config, which in this case appears to be your prometheus store system.

    If you are getting no errors in the log, then it means that it's successfully querying the database but there's no matching Steam ID. Errors are only produced if the database connection or query results in an error, and not if a player joins but does not appear to be watched.

    Last edited by Shigbeard; 06-07-2022 at 13:24.
    Shigbeard is offline
    freak.exe_uLow
    AlliedModders Donor
    Join Date: Jul 2012
    Location: Germany
    Old 06-07-2022 , 13:42   Re: [ANY] Player Watchlist
    Reply With Quote #5

    Quote:
    Originally Posted by Shigbeard View Post
    That config option refers to a config entry in the mysql config - it's not explicitly for SQLite. I'm in the middle of a huge patch so I'll add fallback logic for that entry being missing. In the mean time, re-add it to restore functionality.

    By default, if there is no configured mysql configuration for the watchlist, it will switch to the "default" config, which in this case appears to be your prometheus store system.

    If you are getting no errors in the log, then it means that it's successfully querying the database but there's no matching Steam ID. Errors are only produced if the database connection or query results in an error, and not if a player joins but does not appear to be watched.
    Okay and thanks for the fast response. The SteamID should be correct, I have entered mine and also 2 other test users, with all I get no notification in Discord



    freak.exe_uLow is offline
    Shigbeard
    Junior Member
    Join Date: Oct 2021
    Location: Hell
    Old 06-07-2022 , 13:55   Re: [ANY] Player Watchlist
    Reply With Quote #6

    I'll have a fix out in the next 24 hours - I'm almost done with this patch (it's practically a rewrite at this stage)

    Last edited by Shigbeard; 06-07-2022 at 13:56. Reason: dumb signature
    Shigbeard is offline
    freak.exe_uLow
    AlliedModders Donor
    Join Date: Jul 2012
    Location: Germany
    Old 06-07-2022 , 14:12   Re: [ANY] Player Watchlist
    Reply With Quote #7

    Quote:
    Originally Posted by Shigbeard View Post
    I'll have a fix out in the next 24 hours - I'm almost done with this patch (it's practically a rewrite at this stage)
    Okay and I have time, just wanted to report my concern and thank you for your time
    freak.exe_uLow is offline
    Shigbeard
    Junior Member
    Join Date: Oct 2021
    Location: Hell
    Old 06-07-2022 , 20:08   Re: [ANY] Player Watchlist
    Reply With Quote #8

    Actually my rewrite is looking like it'll need another rewrite. Several other developers have approached me pointing out various tools I could use to better do some of the things I'm doing. For instance, Sarrus suggested I use his Discord API and Nexd suggested the same due to this one having memory leaks. Hopefully it's not too massive a code change to implement these changes but I'll do it ASAP, i'll try to keep this thread updated on where I'm at with that (because im a bit scatter brained and I had to stop coding earlier because I was staring at the same blank line for 30 minutes trying to remember what I needed to put into a buffer when the answer was two lines above)
    __________________
    Shigbeard is offline
    Shigbeard
    Junior Member
    Join Date: Oct 2021
    Location: Hell
    Old 06-09-2022 , 07:07   Re: [ANY] Player Watchlist
    Reply With Quote #9

    Updated the plugin, check it out fellas.
    __________________
    Shigbeard is offline
    freak.exe_uLow
    AlliedModders Donor
    Join Date: Jul 2012
    Location: Germany
    Old 06-09-2022 , 10:48   Re: [ANY] Player Watchlist
    Reply With Quote #10

    Quote:
    Originally Posted by Shigbeard View Post
    Updated the plugin, check it out fellas.
    Thank you and this appeared after I loaded it

    Code:
    L 06/09/2022 - 16:31:35: SourceMod error session started
    L 06/09/2022 - 16:31:35: Info (map "de_mirage") (file "/home/user2-2/server/csgo/csgo/addons/sourcemod/logs/errors_20220609.log")
    L 06/09/2022 - 16:31:35: [SM] Exception reported: Client index 115 is invalid
    L 06/09/2022 - 16:31:35: [SM] Blaming: watchlist.smx
    L 06/09/2022 - 16:31:35: [SM] Call stack trace:
    L 06/09/2022 - 16:31:35: [SM]   [0] IsClientAuthorized
    L 06/09/2022 - 16:31:35: [SM]   [1] Line 695, watchlist.sp::Watchlist_Validate_Player
    L 06/09/2022 - 16:31:35: [SM]   [2] Line 654, watchlist.sp::Watchlist_Event_PlayerDisconnect
    L 06/09/2022 - 16:31:40: [SM] Exception reported: Client index 114 is invalid
    L 06/09/2022 - 16:31:40: [SM] Blaming: watchlist.smx
    L 06/09/2022 - 16:31:40: [SM] Call stack trace:
    L 06/09/2022 - 16:31:40: [SM]   [0] IsClientAuthorized
    L 06/09/2022 - 16:31:40: [SM]   [1] Line 695, watchlist.sp::Watchlist_Validate_Player
    L 06/09/2022 - 16:31:40: [SM]   [2] Line 654, watchlist.sp::Watchlist_Event_PlayerDisconnect
    Edit: Idk, the plugin is supposed to run, but I don't get a Discord message (I added myself) when I enter the server or anything else. Adding also works, but the messages are not via Discord (there is no error log anymore).

    Last edited by freak.exe_uLow; 06-09-2022 at 12:15.
    freak.exe_uLow is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 13:47.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode