AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   Uninamer (Unicode name changer) (https://forums.alliedmods.net/showthread.php?t=65455)

red! 01-08-2008 18:01

Uninamer (Unicode name changer)
 
7 Attachment(s)
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

Greyscale 01-10-2008 21:58

Re: Uninamer (Unicode name changer)
 
PrintToConsole(0, "") will error won't it?

Or does it just print to server console? You should look at PrintToServer()

pRED* 01-11-2008 00:29

Re: Uninamer (Unicode name changer)
 
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.

r5053 01-11-2008 03:43

Re: Uninamer (Unicode name changer)
 
God idea for a plugin :D 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

red! 01-11-2008 18:37

Re: Uninamer (Unicode name changer)
 
Quote:

Originally Posted by pRED* (Post 572751)
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! 01-12-2008 20:03

Re: Uninamer (Unicode name changer)
 
updated

red! 01-13-2008 07:58

Re: Uninamer (Unicode name changer)
 
Quote:

Originally Posted by Greyscale (Post 572724)
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.

J@y-R 04-26-2008 09:47

Re: Uninamer (Unicode name changer)
 
A Kick function had nice

Greetz
JaY

sfPlayer 04-26-2008 11:20

Re: Uninamer (Unicode name changer)
 
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); 
        } 
    } 



red! 04-26-2008 16:49

Re: Uninamer (Unicode name changer)
 
Quote:

Originally Posted by J@y-R (Post 617110)
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)

kill0r 04-26-2008 17:33

Re: Uninamer (Unicode name changer)
 
Most players hate to get renamed, just kick them. And btw. "ClientCommand(clientSlot, "name \"%s\"", nameBuf);" is useless, alias name "echo lol" ftw ;-)

Jérémie 04-29-2008 18:39

Re: Uninamer (Unicode name changer)
 
Quote:

Originally Posted by r5053 (Post 572780)
God idea for a plugin :D i can't tell you how i hate it if there are players with special chars in the name,

Nice, but some of us have non-ascii character in our language, and thus in our Steam alias.

If someone is allowed "Mozart" as a pseudo, why would I be punish for choosing "Dvořák" for example?

Although, I agree that people using wrong unicode glyph to "emulate" standard character, like a new l33t alphabet or something, are just dumb and should be kicked on sight. But there's a nuance here.
Quote:

it's looking like shit in the webinterface of my TF2 stats plugin because it can't display the special chars on the webpage
That's most probably an issue with your webpage, nothing wrong with unicode.

red! 04-30-2008 02:42

Re: Uninamer (Unicode name changer)
 
update - improved the utf-8 handling as suggested by sfPlayer

@jeremie: you're right. the national chars are a reason to allow unicode names. but I have made the observation that users of "funny" unicode substitution names have a strong tendency to be complete idiots.

on my server I allow exactly 2 unicode chracters. that has to be enough - in my opinion - even for "Dvořák"

red! 04-30-2008 03:23

Re: Uninamer (Unicode name changer)
 
update 2: implemented kick instead of renaming. warning, needs a translation file now.

Chaos Llama 05-11-2008 19:23

Re: Uninamer (Unicode name changer)
 
This plugin is great, but ive noticed a problem.

Often users who join, who then have their name renamed - will just rename themselves back to whatever they joined with. It would be great to have this plugin keep monitoring only users that have special chars in their name and change when necessary/

red! 05-12-2008 04:43

Re: Uninamer (Unicode name changer)
 
The names are re-checked every round-end so they are renamed again if they got back to their unicode name. I made the observation that these guys normally get tired of renaming after a few rounds ...

But as a matter of fact I coded this plugin with Counterstrike Source where the roundtimes are shorter than for games with player respawning. I will think about a solution.

sofwmrebiteme 07-18-2008 11:13

Re: Uninamer (Unicode name changer)
 
I take that this mod will not work on the final version of dod

red! 07-18-2008 15:23

Re: Uninamer (Unicode name changer)
 
And could you give me a clue why you think so?

Lebson506th 07-18-2008 18:59

Re: Uninamer (Unicode name changer)
 
Because the orange box engine uses the steam friends name rather than a name generated via the "name" command.

To change it you would use
Code:

setinfo name "Name"
but that is a protected client command.

red! 07-18-2008 19:54

Re: Uninamer (Unicode name changer)
 
yes, maybe. but that's something I would not mess around with - even if I could.

Lebson506th 07-18-2008 20:06

Re: Uninamer (Unicode name changer)
 
That's my point.

kom65 08-04-2008 04:15

Re: Uninamer (Unicode name changer)
 
In order for players with Russian names not touched the plug, what can be done?

red! 08-04-2008 05:32

Re: Uninamer (Unicode name changer)
 
use your windows codetable, find the number of highest allowed character and use it for un_characterthreshold. Maybe I could add support for specific ranges of characters but that would increase the plugins complexity significantly.

kom65 08-04-2008 09:27

Re: Uninamer (Unicode name changer)
 
Where can I find the number of highest allowed character?

red! 08-04-2008 12:37

Re: Uninamer (Unicode name changer)
 
you can chose one on your own. I don't know enough on russian to tell you which characters codes you need.

Zuko 08-04-2008 13:29

Re: Uninamer (Unicode name changer)
 
1 Attachment(s)
polish translation / polskie tłumaczenie

Chaos Llama 08-11-2008 02:21

Re: Uninamer (Unicode name changer)
 
A whitelist by steamid or clan tag would be really cool.

red! 08-11-2008 18:11

Re: Uninamer (Unicode name changer)
 
hmmm, I don't like my admins to behave worse than the players so I do not need such a feature, but I'll see what I can do when I have some spare time ..

Hollanda 10-24-2008 16:24

Re: Uninamer (Unicode name changer)
 
Where should I leave the cvars?

red! 10-24-2008 17:10

Re: Uninamer (Unicode name changer)
 
put them wherever you want. I put them into my server.cfg. I do not like to have an extra config for each little plugin.

Hollanda 10-29-2008 20:36

Re: Uninamer (Unicode name changer)
 
Would it be possible to change the plugin so you can set a minimum number of normal unicode signs?

Explanation: I dont mind people playing with unicode signs, but I do mind them not playing with any normal signs, so I can not kick/slay/slap/check rates them.

red! 10-30-2008 04:17

Re: Uninamer (Unicode name changer)
 
Quote:

Originally Posted by Hollanda (Post 707314)
Would it be possible to change the plugin so you can set a minimum number of normal unicode signs?

Explanation: I dont mind people playing with unicode signs, but I do mind them not playing with any normal signs, so I can not kick/slay/slap/check rates them.

Hmmm. You do not need just the amount of std-ascii char but a continous sequence of them, don't you? But as a matter of fact, of course I could.

Hollanda 10-30-2008 10:45

Re: Uninamer (Unicode name changer)
 
Yes that would be great!

red! 11-01-2008 11:11

Re: Uninamer (Unicode name changer)
 
Quote:

Originally Posted by Hollanda (Post 707314)
Would it be possible to change the plugin so you can set a minimum number of normal unicode signs?

Explanation: I dont mind people playing with unicode signs, but I do mind them not playing with any normal signs, so I can not kick/slay/slap/check rates them.

implemented that. see release in first post. the new variable un_mingoodcharsequence gives the minimum amount of allowed characters in a direct sequence. This will also punish people having a name what is shorter than this sequence even if there is no unicode in it at all. for the requested purpose that may fit best in my opinion. if it becomes anoying, feel free to discuss this here.

DrGamez 09-02-2009 15:30

Re: Uninamer (Unicode name changer)
 
Yeah wow this is one monster of a bump (over a year and a half!) But I was wondering if there was any way of having this plugin still work? I'm tired of having to parse garbage names through my logs and I'd like to just kick them.

Problem is the plugin doesn't seem to... work. It thinks all characters are bad now.

Code:

L 09/01/2009 - 23:47:59: "Henchman 24<7><STEAM_0:1:2767785><>" connected, address "96.240.116.103:27005"
Client "Henchman 24" connected (96.240.116.103:27005).
L 09/01/2009 - 23:47:59: "Henchman 24<7><STEAM_0:1:2767785><>" STEAM USERID validated
[Uninamer] kicking Henchman 24 (bad chars: 11>2)
L 09/01/2009 - 23:48:09: [uninamer.smx] kicking Henchman 24 (bad chars: 11>2)

L 09/01/2009 - 23:48:09: "Henchman 24<7><STEAM_0:1:2767785><>" entered the game
L 09/01/2009 - 23:48:09: [SM] Plugin encountered error 4: Invalid parameter or parameter type
L 09/01/2009 - 23:48:09: [SM] Native "KickClient" reported: Language phrase "unicode names not allowed here" not found
L 09/01/2009 - 23:48:09: [SM] Displaying call stack trace for plugin "uninamer.smx":
L 09/01/2009 - 23:48:09: [SM]  [0]  Line 231, /home/groups/alliedmodders/forums/files/3/1/0/0/5/22824.attach::OnTimedKick()

Like I said I know this is a very very old bump :(

red! 09-02-2009 18:15

Re: Uninamer (Unicode name changer)
 
First guess:

You set un_characterthreshold to an unsuitable value and obviously you did not install uninamer.phrases.txt to you translations-folder.

Shadymn 06-23-2011 10:56

Re: Uninamer (Unicode name changer)
 
mmm this plugin works in CS 1.6?

Visual77 06-23-2011 11:00

Re: Uninamer (Unicode name changer)
 
CS 1.6 = AMX. Not sourcemod.

StrikerMan780 11-08-2011 21:45

Re: Uninamer (Unicode name changer)
 
I loaded this onto my TF2 server, but it seems to not be renaming people with too many unicode characters whatsoever. I'm not getting any error logs either.

Bacardi 11-09-2011 01:19

Re: Uninamer (Unicode name changer)
 
Quote:

Originally Posted by StrikerMan780 (Post 1593064)
I loaded this onto my TF2 server, but it seems to not be renaming people with too many unicode characters whatsoever. I'm not getting any error logs either.

This is old plugin
Plugin ID: 252
Before orangebox games, players can rename easily.

But now player names are taken from steam, need rename different way.


All times are GMT -4. The time now is 09:15.

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