Remove clan tags from player.name

Started by Mötley, Oct 20, 2016, 07:44 PM

Previous topic - Next topic

Mötley

I would like to request for a snippet to remove a clans bracket from 'player.Name, Then set the name.
Example: '[MC]Motley' to 'Motley'

I would also need to be capable of adding more characters as players will find ways to bypass " { }, | |, II" etc.

My scripting is not the greatest and something like this is very complicating, This would be very vital in my server build.

redax

#1
i will put code here when done!(maybe)

KAKAN

Quote from: redax on Nov 24, 2016, 12:56 PMfunction AdminCmds( player, cmd, text ){

if ( cmd == "nametags" ){
        if (!text) MessagePlayer("Wrong Syntax! /"+ cmd + "on/off", player );
        else if ( text == "on" ){SetShowNametags( true );}
        else if ( text == "off"){SetShowNametags( false );}
        else return 0;
    }

You didn't read whats inside the topic, did you?
oh no

EK.IceFlake

Quote from: redax on Nov 24, 2016, 12:56 PMfunction AdminCmds( player, cmd, text ){

if ( cmd == "nametags" ){
        if (!text) MessagePlayer("Wrong Syntax! /"+ cmd + "on/off", player );
        else if ( text == "on" ){SetShowNametags( true );}
        else if ( text == "off"){SetShowNametags( false );}
        else return 0;
    }
Are you a robot? There is no callback 'AdminCmds'. This is also a month old topic. SetShowNametags is not even remotely related to clan tags. This is a ridiculous copy-paste.

redax

Quote from: KAKAN on Nov 24, 2016, 01:22 PM
Quote from: redax on Nov 24, 2016, 12:56 PMfunction AdminCmds( player, cmd, text ){

if ( cmd == "nametags" ){
        if (!text) MessagePlayer("Wrong Syntax! /"+ cmd + "on/off", player );
        else if ( text == "on" ){SetShowNametags( true );}
        else if ( text == "off"){SetShowNametags( false );}
        else return 0;
    }

You didn't read whats inside the topic, did you?


Oops....sorry!

Rhytz

Did you ever figure this out Motley?

.

#6
__RexNameTag__ <- ::regexp(@"^([\[\(\{]\w*[\]\)\}]){1}(.+)");

function GetTagWithoutName(name)
{
    local seg = __RexNameTag__.capture(name);
    if (seg != null && seg.len() > 1)
        return name.slice(seg[1].begin, seg[1].end);
    return name;
};

function GetNameWithoutTag(name)
{
    local seg = __RexNameTag__.capture(name);
    if (seg != null && seg.len() > 2)
        return name.slice(seg[2].begin, seg[2].end-1);
    return name;
};

local names = [
    // empty tag
    "[]",
    "()",
    "{}",
    // just tag
    "[xyz]",
    "(xyz)",
    "{xyz}",
    // no tag and confusing name
    "n](a)[m[e]",
    "na{me}(2",
    ")n[am)e{",
    // empty tag and confusing name
    "[]n](a)[m[e]",
    "()na{me}(2",
    "{})n[am)e{",
    // one number and confusing name
    "[1]n](a)[m[e]",
    "(1)na{me}(2",
    "{1})n[am)e{",
    // valid tag and confusing name
    "[xyz]n](a)[m[e]",
    "(xyz)na{me}(2",
    "{xyz})n[am)e{",
    // empty string
    ""
];

foreach (name in names)
{
    print("--> '" + name + "'");
    print(GetTagWithoutName(name));
    print(GetNameWithoutTag(name));
}

Do I really have to do everything here?
.

Mötley

#7
Quote from: Rhytz on Nov 24, 2016, 03:42 PMDid you ever figure this out Motley?


KAKAN helped me with a really basic version, It worked just fine, I wanted to keep the topic open in case someone like S.L.C replied and he did.

Thank you S.L.C for the learning material :), You really went technically with this, I really like this code.  :)

I will run a character detect encase someone does this

[Motley] as a username.. LOL