Raised This Month: $7 Target: $400
 1% 

[ANY] Name Filter


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Grognak
SourceMod Donor
Join Date: Jan 2012
Plugin ID:
2978
Plugin Version:
1.1
Plugin Category:
Server Management
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Prevents people with undesired names from connecting or playing.
    Unapprover:
    Reason for Unapproving:
    reported problems with plugin, author AWOL
    Old 05-29-2012 , 00:00   [ANY] Name Filter
    Reply With Quote #1

    Name Filter - by Grognak


    Ever try to keep up a fun, community-oriented server when people with overly-offensive names connect? This plugin will automatically rename or kick anybody who connects or changes their name if their name contains a "bad word" from a list that you set.

    Note: I haven't yet tested the Regex version. Use only if you don't mind the unexpected happening.

    Instructions:
    1. Place namefilter.smx or namefilter.regex.smx in /sourcemod/plugins
    2. Edit badnames.txt to your liking. Place in /sourcemod/configs

    Cvars:
    namefilter_version: The plugin's version. Please don't change this.
    namefilter_mode: What to do with a bad name. If 0 - kick the player. If 1 - rename the player with a warning. Default mode is 1.
    namefilter_name: What to change the renamed player's name to. Mode 1 only, default "Player."
    namefilter_warning: The message to give the kicked/renamed player. By default it's "Please don't use offensive names on this server."

    Possible future updates:
    • Admin Immunity (if anyone needs it)

    Versions:
    Quote:
    1.0 - Initial Release
    1.1 - Added Renaming as an alternative (thank you GoD-Tony and minimoney1!)
    1.1b - Added Regex Support. For testing purposes only. {3}
    1.1c - Fixed flaw in Regex support. {153}
    1.2 - ditched Regex, plugin should be error-free now
    Warning: The badnames.txt I have here for download contains very offensive language from a vulgar word list I found on here. Read at your own risk. If you would rather build your own, make a similarly-named text file and put each bad word on a separate line.
    Attached Files
    File Type: txt badnames.txt (3.6 KB, 1232 views)
    File Type: sp Get Plugin or Get Source (namefilter.sp - 1768 views - 5.4 KB)

    Last edited by Grognak; 08-10-2012 at 21:26.
    Grognak is offline
    minimoney1
    SourceMod Donor
    Join Date: Dec 2010
    Old 05-29-2012 , 00:11   Re: [ANY] Name Filter
    Reply With Quote #2

    Great job on the plugin, you should definitely add regex support to this.
    The name change shouldn't be a problem, you can change names in CSS using this snippet. If you can't do it instantly you can just make a timer w/ .5 seconds and then rename (with the checks of course).
    minimoney1 is offline
    Grognak
    SourceMod Donor
    Join Date: Jan 2012
    Old 05-29-2012 , 01:25   Re: [ANY] Name Filter
    Reply With Quote #3

    Quote:
    Originally Posted by minimoney1 View Post
    Great job on the plugin, you should definitely add regex support to this.
    The name change shouldn't be a problem, you can change names in CSS using this snippet. If you can't do it instantly you can just make a timer w/ .5 seconds and then rename (with the checks of course).
    Thanks for the encouragement and the link. I've been looking all over for that! I've updated the plugin to 1.1, it should rename nicely now.

    I don't see the need for regex, it seems like it's a bit overkill. The current method will search all of the player's string for the bad word right now and it's not case sensitive. For example, if Mini was put as a bad word, it would kick you despite your name being minimoney1.
    Grognak is offline
    minimoney1
    SourceMod Donor
    Join Date: Dec 2010
    Old 05-29-2012 , 01:30   Re: [ANY] Name Filter
    Reply With Quote #4

    Quote:
    Originally Posted by Grognak View Post
    Thanks for the encouragement and the link. I've been looking all over for that! I've updated the plugin to 1.1, it should rename nicely now.

    I don't see the need for regex, it seems like it's a bit overkill. The current method will search all of the player's string for the bad word right now and it's not case sensitive. For example, if Mini was put as a bad word, it would kick you despite your name being minimoney1.
    But then, let's say I would want to kick anyone that has an IP in their name (Even though there is a plugin for this, this is just a mere example), I wouldn't be able to do it with this version
    minimoney1 is offline
    Grognak
    SourceMod Donor
    Join Date: Jan 2012
    Old 05-29-2012 , 19:30   Re: [ANY] Name Filter
    Reply With Quote #5

    Added an alternate version with Regex. Let me know if it doesn't work.
    Grognak is offline
    minimoney1
    SourceMod Donor
    Join Date: Dec 2010
    Old 05-29-2012 , 20:48   Re: [ANY] Name Filter
    Reply With Quote #6

    Quote:
    Originally Posted by Grognak View Post
    Added an alternate version with Regex. Let me know if it doesn't work.
    Great job, but a couple of things.
    You're better off using a pre-compiled regex, look at the regex API, it's pretty easy, you can also take a look at my URL chat block plugin to get an example.

    Another main thing that will also apply to pre-compiled regular expressions.
    Code:
    if (SimpleRegexMatch(ClientName, sLine, PCRE_CASELESS|PCRE_EXTENDED))
    should be something like
    Code:
    if (SimpleRegexMatch(ClientName, sLine, PCRE_CASELESS|PCRE_EXTENDED) != -1)
    from what I know.
    minimoney1 is offline
    Grognak
    SourceMod Donor
    Join Date: Jan 2012
    Old 05-29-2012 , 21:24   Re: [ANY] Name Filter
    Reply With Quote #7

    Quote:
    Originally Posted by minimoney1 View Post
    Great job, but a couple of things.
    You're better off using a pre-compiled regex, look at the regex API, it's pretty easy, you can also take a look at my URL chat block plugin to get an example.
    Can I load the entire file as a RegexString? Slightly confusing for me.

    Quote:
    Another main thing that will also apply to pre-compiled regular expressions.
    Code:
    if (SimpleRegexMatch(ClientName, sLine, PCRE_CASELESS|PCRE_EXTENDED))
    should be something like
    Code:
    if (SimpleRegexMatch(ClientName, sLine, PCRE_CASELESS|PCRE_EXTENDED) != -1)
    from what I know.
    Thanks, fixed.
    Grognak is offline
    minimoney1
    SourceMod Donor
    Join Date: Dec 2010
    Old 05-29-2012 , 22:18   Re: [ANY] Name Filter
    Reply With Quote #8

    Quote:
    Originally Posted by Grognak View Post
    Can I load the entire file as a RegexString? Slightly confusing for me.


    Thanks, fixed.
    Actually, ignore what I said, it does apply but you should do something like this:
    Code:
    if (SimpleRegexMatch(ClientName, sLine, PCRE_CASELESS|PCRE_EXTENDED) > 0)


    Quote:
    Originally Posted by Grognak View Post
    Can I load the entire file as a RegexString? Slightly confusing for me.
    It's pretty simple, you just make a global handle, let's name it g_hGlobalRegex.
    OnPluginStart you use g_hGlobalRegex = CompileRegex("your_regex");
    Then instead of using SimpleRegexMatch() you use MatchRegex() using your global regex.
    It's just a minor optimization but it makes things a bit faster.

    Last edited by minimoney1; 05-29-2012 at 22:25.
    minimoney1 is offline
    Grognak
    SourceMod Donor
    Join Date: Jan 2012
    Old 05-29-2012 , 22:35   Re: [ANY] Name Filter
    Reply With Quote #9

    Quote:
    Originally Posted by minimoney1 View Post
    It's pretty simple, you just make a global handle, let's name it g_hGlobalRegex.
    OnPluginStart you use g_hGlobalRegex = CompileRegex("your_regex");
    Then instead of using SimpleRegexMatch() you use MatchRegex() using your global regex.
    It's just a minor optimization but it makes things a bit faster.
    Yeah, but right now I loop line by line in the text file and see if there's match. I'm pretty much using it as a drop-in for StrContains. Would I feed the whole contents of the file to CompileRegex, then see if:

    Code:
    MatchRegex(g_hGlobalRegex, sUserName)

    turns up a number larger then 0?

    Thanks.

    Last edited by Grognak; 05-29-2012 at 22:39.
    Grognak is offline
    minimoney1
    SourceMod Donor
    Join Date: Dec 2010
    Old 05-29-2012 , 23:25   Re: [ANY] Name Filter
    Reply With Quote #10

    Quote:
    Originally Posted by Grognak View Post
    Yeah, but right now I loop line by line in the text file and see if there's match. I'm pretty much using it as a drop-in for StrContains. Would I feed the whole contents of the file to CompileRegex, then see if:

    Code:
    MatchRegex(g_hGlobalRegex, sUserName)

    turns up a number larger then 0?

    Thanks.
    Well, what I would recommend is having a keyvalue structure.
    Something like this:
    Code:
    "Name Filter"
    {
    	"1" // an id to give to the filter
    	{
    		"regex"		"[Bb][Aa][Dd][Ww][Oo][Rr][Dd]" // the regex to the filter
    		"string"	"BadWord" // plaintext string filtering
    	}
    }
    And reading off of that.
    And then it'd be optional to use "regex", "string", or both.

    Last edited by minimoney1; 05-29-2012 at 23:26.
    minimoney1 is offline
    Reply


    Thread Tools
    Display Modes

    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 22:40.


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