Block invalid character name and say?

Сообщения
31
Реакции
4
how can i block invalid character?

I want to block all ascii codes. "! ' ^ + # | ~ $ ? * / " except these.

20210719172548_1.jpg
 
Сообщения
36
Реакции
-3
I did it now, but I didn't test it, test it and tell me


PHP:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "CS Revo: Clear Name"
#define VERSION "1.0"
#define AUTHOR "Wilian M."

new const xSymbols[][] =
{
    "!",
    "/",
    "*",
    "+",
    "#",
    "|",
    "~",
    "$",
    "?",
    "^^",
    "'",
}

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_forward(FM_ClientUserInfoChanged, "xClientUserInfoChanged", false)
}

public client_putinserver(id) xClearName(id);

public xClientUserInfoChanged(id)
{
    if(!is_user_connected(id))
        return FMRES_IGNORED

    static xUserName[32]
    pev(id, pev_netname, xUserName, charsmax(xUserName))

    if(xUserName[0])
    {
        static name[] = "name"
        static xUserNewName[32]
        get_user_info(id, name, xUserNewName, charsmax(xUserNewName))

        if(!equal(xUserName, xUserNewName))
        {
            xClearName(id)
                
            return FMRES_HANDLED
        }
    }
    
    return FMRES_IGNORED
}

public xClearName(id)
{
    new i, replace, name[32]; get_user_name(id, name, charsmax(name))

    replace = 0

    for(i = 0; i < sizeof(xSymbols); i++)
    {
        replace = replace_string(name, charsmax(name), xSymbols[i], "")
    }

    if(replace)
        set_user_info(id, "name", name)
}
 
Сообщения
31
Реакции
4
I did it now, but I didn't test it, test it and tell me


PHP:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "CS Revo: Clear Name"
#define VERSION "1.0"
#define AUTHOR "Wilian M."

new const xSymbols[][] =
{
    "!",
    "/",
    "*",
    "+",
    "#",
    "|",
    "~",
    "$",
    "?",
    "^^",
    "'",
}

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_forward(FM_ClientUserInfoChanged, "xClientUserInfoChanged", false)
}

public client_putinserver(id) xClearName(id);

public xClientUserInfoChanged(id)
{
    if(!is_user_connected(id))
        return FMRES_IGNORED

    static xUserName[32]
    pev(id, pev_netname, xUserName, charsmax(xUserName))

    if(xUserName[0])
    {
        static name[] = "name"
        static xUserNewName[32]
        get_user_info(id, name, xUserNewName, charsmax(xUserNewName))

        if(!equal(xUserName, xUserNewName))
        {
            xClearName(id)
               
            return FMRES_HANDLED
        }
    }
   
    return FMRES_IGNORED
}

public xClearName(id)
{
    new i, replace, name[32]; get_user_name(id, name, charsmax(name))

    replace = 0

    for(i = 0; i < sizeof(xSymbols); i++)
    {
        replace = replace_string(name, charsmax(name), xSymbols[i], "")
    }

    if(replace)
        set_user_info(id, "name", name)
}
not working
 
Сообщения
36
Реакции
-3
if you have another plugin that handles chat, leave this one first in 'plugins.ini'

check:


PHP:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "CS Revo: Clear Name"
#define VERSION "1.0"
#define AUTHOR "Wilian M."

new const xSymbols[][] =
{
    "!",
    "/",
    "*",
    "+",
    "#",
    "#",
    "|",
    "~",
    "$",
    "?",
    "^^",
    "'",
    "%",
    "%",
    "-"
}

new xSayMessage[192], xUserNewName[32], xReplace

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_forward(FM_ClientUserInfoChanged, "xClientUserInfoChanged", false)

    register_clcmd("say", "xCheckSay")
    register_clcmd("say_team", "xCheckSay")
}

public client_connect(id)
{
    if(xClearName(id))
        return PLUGIN_CONTINUE
    
    return PLUGIN_CONTINUE
}

public xCheckSay(id)
{
    if(!is_user_connected(id))
        return PLUGIN_HANDLED

    read_args(xSayMessage, charsmax(xSayMessage))
    remove_quotes(xSayMessage)
    trim(xSayMessage)

    static i, xFind

    xFind = -1

    for(i = 0; i < sizeof(xSymbols); i++)
    {
        if(contain(xSayMessage, xSymbols[i]) != -1)
            xFind = true
        
        if(xFind != -1)
            break
    }

    if(xFind != -1)
    {
        client_print_color(id, print_team_default, "^4Special characters not allowed.")

        return PLUGIN_HANDLED
    }

    return PLUGIN_CONTINUE
}

public xClientUserInfoChanged(id)
{
    if(!is_user_connected(id))
        return FMRES_IGNORED

    static xUserName[32]
    pev(id, pev_netname, xUserName, charsmax(xUserName))

    if(xUserName[0])
    {
        get_user_info(id, "name", xUserNewName, charsmax(xUserNewName))

        if(!equal(xUserName, xUserNewName))
        {
            if(xClearName(id))
                return FMRES_HANDLED
        }
    }
    
    return FMRES_IGNORED
}

public xClearName(id)
{
    static i

    get_user_info(id, "name", xUserNewName, charsmax(xUserNewName))

    xReplace = 0

    for(i = 0; i < sizeof(xSymbols); i++)
        xReplace = replace_string(xUserNewName, charsmax(xUserNewName), xSymbols[i], "")

    if(xReplace)
    {
        trim(xUserNewName)
        set_user_info(id, "name", xUserNewName)

        return true
    }

    return false
}
 
Сообщения
31
Реакции
4
im not sure but its probably what you're looking for
if you have another plugin that handles chat, leave this one first in 'plugins.ini'

check:


PHP:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "CS Revo: Clear Name"
#define VERSION "1.0"
#define AUTHOR "Wilian M."

new const xSymbols[][] =
{
    "!",
    "/",
    "*",
    "+",
    "#",
    "#",
    "|",
    "~",
    "$",
    "?",
    "^^",
    "'",
    "%",
    "%",
    "-"
}

new xSayMessage[192], xUserNewName[32], xReplace

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_forward(FM_ClientUserInfoChanged, "xClientUserInfoChanged", false)

    register_clcmd("say", "xCheckSay")
    register_clcmd("say_team", "xCheckSay")
}

public client_connect(id)
{
    if(xClearName(id))
        return PLUGIN_CONTINUE
   
    return PLUGIN_CONTINUE
}

public xCheckSay(id)
{
    if(!is_user_connected(id))
        return PLUGIN_HANDLED

    read_args(xSayMessage, charsmax(xSayMessage))
    remove_quotes(xSayMessage)
    trim(xSayMessage)

    static i, xFind

    xFind = -1

    for(i = 0; i < sizeof(xSymbols); i++)
    {
        if(contain(xSayMessage, xSymbols[i]) != -1)
            xFind = true
       
        if(xFind != -1)
            break
    }

    if(xFind != -1)
    {
        client_print_color(id, print_team_default, "^4Special characters not allowed.")

        return PLUGIN_HANDLED
    }

    return PLUGIN_CONTINUE
}

public xClientUserInfoChanged(id)
{
    if(!is_user_connected(id))
        return FMRES_IGNORED

    static xUserName[32]
    pev(id, pev_netname, xUserName, charsmax(xUserName))

    if(xUserName[0])
    {
        get_user_info(id, "name", xUserNewName, charsmax(xUserNewName))

        if(!equal(xUserName, xUserNewName))
        {
            if(xClearName(id))
                return FMRES_HANDLED
        }
    }
   
    return FMRES_IGNORED
}

public xClearName(id)
{
    static i

    get_user_info(id, "name", xUserNewName, charsmax(xUserNewName))

    xReplace = 0

    for(i = 0; i < sizeof(xSymbols); i++)
        xReplace = replace_string(xUserNewName, charsmax(xUserNewName), xSymbols[i], "")

    if(xReplace)
    {
        trim(xUserNewName)
        set_user_info(id, "name", xUserNewName)

        return true
    }

    return false
}
This is not what I'm looking for unfortunately. I want to block ASCII characters in the list below. I also want to block arabic, russian, chinese, japanese characters.

bu.gif
 
Сообщения
50
Реакции
-1
This is not what I'm looking for unfortunately. I want to block ASCII characters in the list below. I also want to block arabic, russian, chinese, japanese characters.

Посмотреть вложение 27601
i think you should ask here

or if someone can make you for free
and in description maybe it's more easy way to allow specific characters and not block all language and a lot of characters

i mean like allow all abc... 123... !@#...
If there is no match, it will reject them

Good Luck!
 
Сообщения
36
Реакции
-3
Сообщения
31
Реакции
4
you already have the base, or you add all the characters you don't want to appear, or do it in another way where only 'abcd and 0-9' is allowed

I did something like this but it's not working. True and false values return together.

Код:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "CS Revo: Clear Name"
#define VERSION "1.0"
#define AUTHOR "Wilian M."

new const whitelist[][] =
{
"!",
".",
"=",
"<",
">",
"`",
";",
"/",
"*",
"+",
"#",
"}",
"{",
"[",
"]",
"-",
"|",
"~",
"$",
"?",
"'",
"%",
"%",
"_",
"@",
"q",
"w",
"e",
"r",
"t",
"y",
"u",
"o",
"p",
"a",
"s",
"d",
"f",
"g",
"h",
"j",
"k",
"l",
"z",
"x",
"c",
"v",
"b",
"n",
"m",
"i",
"I",

}


public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_ClientUserInfoChanged, "xClearName", false)

}

public client_putinserver(id)
{
if(xClearName(id))
    return PLUGIN_CONTINUE
   
return PLUGIN_CONTINUE
}


public xClearName(id)
{
    static name[128]
    get_user_info(id, "name", name, 121)
   
    remove_quotes(name)
    trim(name)
   
    static i, xFind
   
    xFind = -1
   
    for(i = 0; i < sizeof(whitelist); i++)
    {
        if(containi(name, whitelist[i]) != -1){
            xFind = true
        }
        if(xFind != -1)
            break
    }
   
    if(xFind != -1)
    {
        client_print_color(id, print_team_default, "^4Special characters not allowed.")
       
        return PLUGIN_HANDLED
    }
   
    return PLUGIN_CONTINUE
}
 
Последнее редактирование:

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу