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

Uninamer (Unicode name changer)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
red!
Senior Member
Join Date: Sep 2007
Location: Germany
Plugin ID:
252
Plugin Version:
1.2
Plugin Category:
Server Management
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    rename/kick players who abusively use unicode names
    Old 01-08-2008 , 18:01   Uninamer (Unicode name changer)
    Reply With Quote #1

    This plugin checks any connected player for using character values above un_characterthreshold in their names. Everything above a un_characterthreshold of 160 is country-specific/unicode. Brackets and and the standard chars from american keyboards are below value 160 and will therefor be allowed for naming by default.

    Install:

    Copy the uninamer.smx plugin to your sourcemod/plugins folder and the uninamer.phrases.txt to sourcemod/translations.

    Todo:

    maybe I could add a ban option instead of just renaming/kicking. If somebody would be interested in additional features, post here.


    CVars:

    un_enable 1/0: enable/disable uninamer (default 1)
    un_punishmode 1/0: 0: rename player, 1: kick player (default 0)
    un_defaultname <name>: name to use for un_punishmode=0 (default "bad name")
    un_characterthreshold <int>: character value of last character which will be allowed (default 160)
    un_maxbadchars <int>: number of bad/unicode character that are allowed for a single name (default 2)
    un_mingoodcharsequence<int>: number of good/non-unicode character that need to be in direct sequence (default 0). 0 disables this feature. keep in mind that a players with a name shorter than this constant will also fail the test and will be punished. (may be changed/configurable if needed by anybody)

    Changelog:
    1.2: added un_mingoodcharsequence
    1.1: added a kick-option instead of renaming
    1.0.2: implemented full utf-8 support
    1.0.1: minor changes on debug output; fixed bug on round-end check
    1.0: added cvars un_characterthreshold and un_maxbadchars; added round end checks; added check for name termination char
    0.1: Initial release
    Attached Files
    File Type: sp Get Plugin or Get Source (uninamer.sp - 2944 views - 7.5 KB)
    File Type: txt uninamer.phrases.txt (167 Bytes, 1408 views)

    Last edited by red!; 11-01-2008 at 11:06. Reason: new release
    red! is offline
    Greyscale
    SourceMod Plugin Approver
    Join Date: Dec 2007
    Location: strYoMommasHouse[you];
    Old 01-10-2008 , 21:58   Re: Uninamer (Unicode name changer)
    Reply With Quote #2

    PrintToConsole(0, "") will error won't it?

    Or does it just print to server console? You should look at PrintToServer()
    Greyscale is offline
    pRED*
    Join Date: Dec 2006
    Old 01-11-2008 , 00:29   Re: Uninamer (Unicode name changer)
    Reply With Quote #3

    There's no point in looping the full length of the string.

    The last character of the name will be followed by a null terminator which has the integer value 0 or char value '\0'

    So you can loop

    Code:
    while (num = nameBuf[i++])
    {
    		if (num>160)
    		{
    			uni=true;
    		}
    }
    or similar.
    pRED* is offline
    r5053
    SourceMod Donor
    Join Date: May 2007
    Location: Germany
    Old 01-11-2008 , 03:43   Re: Uninamer (Unicode name changer)
    Reply With Quote #4

    God idea for a plugin i can't tell you how i hate it if there are players with special chars in the name, it's looking like shit in the webinterface of my TF2 stats plugin because it can't display the special chars on the webpage
    __________________
    Visit HLPortal.de (this is not my Page)


    r5053 is offline
    Send a message via ICQ to r5053 Send a message via Skype™ to r5053
    red!
    Senior Member
    Join Date: Sep 2007
    Location: Germany
    Old 01-11-2008 , 18:37   Re: Uninamer (Unicode name changer)
    Reply With Quote #5

    Quote:
    Originally Posted by pRED* View Post
    There's no point in looping the full length of the string.

    The last character of the name will be followed by a null terminator which has the integer value 0 or char value '\0'

    So you can loop

    Code:
    while (num = nameBuf[i++])
    {
            if (num>160)
            {
                uni=true;
            }
    }
    or similar.
    thats not a real performance issue thus linear memory access is not that expensive. but i'll look for that. i am planing a next version which is somehow more advanced in its behavior which will include a check for the string terminator. this first pre-release was just something like a feasibility study.
    red! is offline
    red!
    Senior Member
    Join Date: Sep 2007
    Location: Germany
    Old 01-12-2008 , 20:03   Re: Uninamer (Unicode name changer)
    Reply With Quote #6

    updated
    red! is offline
    red!
    Senior Member
    Join Date: Sep 2007
    Location: Germany
    Old 01-13-2008 , 07:58   Re: Uninamer (Unicode name changer)
    Reply With Quote #7

    Quote:
    Originally Posted by Greyscale View Post
    PrintToConsole(0, "") will error won't it?

    Or does it just print to server console? You should look at PrintToServer()
    it's the server console. but you're right PrintToServer does the same. I'll replace this for better readability of the code.
    red! is offline
    J@y-R
    Senior Member
    Join Date: Jan 2007
    Location: Hamburg (Germany)
    Old 04-26-2008 , 09:47   Re: Uninamer (Unicode name changer)
    Reply With Quote #8

    A Kick function had nice

    Greetz
    JaY
    J@y-R is offline
    Send a message via ICQ to J@y-R Send a message via MSN to J@y-R
    sfPlayer
    Senior Member
    Join Date: Dec 2007
    Location: Germany
    Old 04-26-2008 , 11:20   Re: Uninamer (Unicode name changer)
    Reply With Quote #9

    you are comparing individual characters in an utf-8 encoded string and not real unicode values.

    I hacked something together to convert it properly, but it's untested.
    PHP Code:
    nameCheck(clientSlot) { 
        
    decl String:nameBuf[128];
         
        if (
    GetClientName(clientSlotnameBufsizeof(nameBuf))) { 
            new 
    badcharcount=0;
             
            for (new 
    i=0nameBuf[i]; i++) {
                
    decl ucValue;
                new 
    cc nameBuf[i];
                if (
    cc 1<<7) {
                    if (
    cc 1<<6) { // 2|3|4 byte
                        
    if (cc 1<<5) { // 3|4 byte
                            
    if (cc 1<<4) { // 4 byte
                                
    ucValue cc & (1<<1);
                                
                                for (new 
    n=0n<3n++) {
                                    
    i++;
                                    
    cc nameBuf[i];
                                    if ((
    cc 192) == 128) {
                                        
    ucValue = (ucValue<<6) | (cc & (1<<1));
                                    } else {
                                        
    LogError("invalid utf-8 sequence");
                                        return;
                                    }
                                }
                            } else { 
    // 3 byte
                                
    ucValue cc & (1<<1);
                                
                                for (new 
    n=0n<2n++) {
                                    
    i++;
                                    
    cc nameBuf[i];
                                    if ((
    cc 192) == 128) {
                                        
    ucValue = (ucValue<<6) | (cc & (1<<1));
                                    } else {
                                        
    LogError("invalid utf-8 sequence");
                                        return;
                                    }
                                }
                            }
                        } else { 
    // 2 byte
                            
    ucValue cc & (1<<1);
                            
                            
    i++;
                            
    cc nameBuf[i];
                            if ((
    cc 192) == 128) {
                                
    ucValue = (ucValue<<6) | (cc & (1<<1));
                            } else {
                                
    LogError("invalid utf-8 sequence");
                                return;
                            }
                        }
                    } else {
                        
    LogError("invalid utf-8 sequence");
                        return;
                    }
                } else {
                    
    ucValue cc;
                }
                 
                if (
    ucValue s_characterThreshold) { 
                    
    badcharcount++; 
                } 
            } 
            if (
    badcharcount s_maxBadChars) {     
                
    PrintToServer("[Uninamer] renaming %s (bad chars: %d>%d)"nameBufbadcharcounts_maxBadChars); 
                
    LogMessage("renaming %s (bad chars: %d>%d)"nameBufbadcharcounts_maxBadChars); 
                
    GetConVarString(s_defaultNamenameBuf128); 
                
    ClientCommand(clientSlot"name \"%s\""nameBuf); 
            } 
        } 

    sfPlayer is offline
    red!
    Senior Member
    Join Date: Sep 2007
    Location: Germany
    Old 04-26-2008 , 16:49   Re: Uninamer (Unicode name changer)
    Reply With Quote #10

    Quote:
    Originally Posted by J@y-R View Post
    A Kick function had nice

    Greetz
    JaY
    yes, could do this.

    this plugin was a quick hack and deserves closer attention. A kick-feature is a reasonable option for this plugin. and revising the unicode name handling will also be of interest. unfortunately I was a bit short on time the last days ... (changed occupation, moved to a new place, and I am still fighting nature - and my 10 weeks old dog - to get the damned garden to an eligible condition)
    red! 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 10:27.


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