AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   CS 1.6 Ban Name Plugin Modification (https://forums.alliedmods.net/showthread.php?t=307604)

hasanalizxc 05-17-2018 14:08

CS 1.6 Ban Name Plugin Modification
 
1 Attachment(s)
Hi All,

Hope you are well. The Ban Name plugin allows you to ban nicks that you do not want the server to enter. You type the nicks that you want to block in the names_banned.ini file.

I am asking you for help, the plugin can not detect if there is a gap (space) in nick. I added kingplayer text to the names_banned.ini file and tested it worked. But it didn't work with king player nick. For example:

Plugin detects this nick: kingplayer
Plugin cannot detect this nick: king player

Would you please help me with this?

You can find the plugin in this link and in the attachment zip file.

Code:

#include <amxmodx>
#include <amxmisc>


#define PLUGIN "Ban Name"
#define VERSION "1.0"
#define AUTHOR "i dont know who"

#define FILE "names_banned.ini"

new Array:a_ban_names,
        array_size,
        look_file,
        g_cfg[64];

public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR);

        register_concmd("amx_ban_name", "fnBanName", ADMIN_BAN, "<#userid, AuthID or nick>");
        register_concmd("amx_addnick", "fnBanName", ADMIN_BAN, "<nick>");

        set_task(1.5, "load_names");
}

public load_names() {
        get_configsdir(g_cfg, charsmax(g_cfg));
        formatex(g_cfg, charsmax(g_cfg), "%s/%s", g_cfg, FILE);

        if(a_ban_names) ArrayDestroy(a_ban_names);
        a_ban_names = ArrayCreate(48, 16);

        new File = fopen(g_cfg, "rt");

        if(File) {
                new Name[48];
                while(!feof(File)) {
                        fgets(File, Name, charsmax(Name));

                        trim(Name);

                        if(!Name[0])
                                continue;

                        ArrayPushString(a_ban_names, Name);
                }

                array_size = ArraySize(a_ban_names);

                fclose(File);
                look_file = 1;
        }
        else {
                look_file = 2;
                log_amx("Brak '%s' na serwerze", g_cfg);
        }
}

public fnBanName(id, level, cid) {
        if(!cmd_access(id, level, cid, 2) || look_file == 0)
                return PLUGIN_HANDLED;

        new param[48], target;
        read_argv(0, param, charsmax(param));
        new bool:isBan = equali(param, "amx_ban_name") ? true : false;
        read_argv(1, param, charsmax(param));
        if(isBan) {
                target = cmd_target(id, param);
                if(!target)
                        return PLUGIN_HANDLED;

                get_user_name(target, param, charsmax(param));
        }
        if(checkName(param)) {
                console_print(id, "Juz zbanowany");
                return PLUGIN_HANDLED;
        }
        write_file(g_cfg, param);
        console_print(id, "Zbanowano!");

        ArrayPushString(a_ban_names, param);
        array_size = ArraySize(a_ban_names);

        if(isBan)
                server_cmd("amx_kick #%d ^"Banned in Name!^"", get_user_userid(target));

        return PLUGIN_HANDLED;
}

bool:checkName(name[]) {
        new szName[48], bool:check, i;

        for(i=0; i<array_size; i++) {
                ArrayGetString(a_ban_names, i, szName, charsmax(szName));

                if(equali(name, szName)) {
                        check = true;

                        break;
                }
        }

        return check;
}

public client_putinserver(id) {
        if(is_user_bot(id))
                return PLUGIN_CONTINUE;

        if(array_size) {
                new name[48];
                get_user_name(id, name, charsmax(name));
                if(checkName(name))
                        server_cmd("amx_kick #%d ^"Banned in Name!^"", get_user_userid(id));
        }
        else if(look_file != 2)
                set_task(2.0, "client_putinserver", id);

        return PLUGIN_CONTINUE;
}

public client_infochanged(id) {
        if(is_user_bot(id))
                return PLUGIN_CONTINUE;

        new newName[48], oldName[48];
        get_user_info(id, "name", newName, charsmax(newName));
        get_user_name(id, oldName, charsmax(oldName));

        if(!equali(newName, oldName) && checkName(newName))
                server_cmd("amx_kick #%d ^"Banned in Name!^"", get_user_userid(id));

        return PLUGIN_CONTINUE;
}


CrAzY MaN 05-17-2018 14:31

Re: CS 1.6 Ban Name Plugin Modification
 
Search for "Restrict Names"

hasanalizxc 05-17-2018 14:39

Re: CS 1.6 Ban Name Plugin Modification
 
Quote:

Originally Posted by CrAzY MaN (Post 2592581)
Search for "Restrict Names"

restrict names plugin is very sophisticated i couldnt understand .ini file. my plugin is too simple.

tarsisd2 05-17-2018 18:02

Re: CS 1.6 Ban Name Plugin Modification
 
Quote:

Originally Posted by hasanalizxc (Post 2592583)
restrict names plugin is very sophisticated i couldnt understand .ini file. my plugin is too simple.

nonsense, that plugin does exactly what you want and better

in cvar you can put like
restnames_default_name "Nick Not Allowed"

in restrictnames.ini

whatevernick "change your nick" 0
secondnick "change your nick" 0

that means that whoever has those nicks, will receive a msg "change your nick" and it will be changed to "Nick Not Allowed"

you can set everything as you desire, can't be hard to understand

hasanalizxc 05-17-2018 18:26

Re: CS 1.6 Ban Name Plugin Modification
 
Quote:

Originally Posted by tarsisd2 (Post 2592601)
nonsense, that plugin does exactly what you want and better

in cvar you can put like
restnames_default_name "Nick Not Allowed"

in restrictnames.ini

whatevernick "change your nick" 0
secondnick "change your nick" 0

that means that whoever has those nicks, will receive a msg "change your nick" and it will be changed to "Nick Not Allowed"

you can set everything as you desire, can't be hard to understand


For example i have a blacklist and could you please show me how can i add these? I couldnt understand regex logic. Please update .ini file and reupload with these nicks.

No Name ^ . ^
Hades Underwold ; CS
Ccash ! Ccomedy
[Anti]'Biyotik

And i have a question can plugin detect nicks with spaces (gap) between them like above?

tarsisd2 05-17-2018 21:22

Re: CS 1.6 Ban Name Plugin Modification
 
Quote:

Originally Posted by hasanalizxc (Post 2592606)
For example i have a blacklist and could you please show me how can i add these? I couldnt understand regex logic. Please update .ini file and reupload with these nicks.

No Name ^ . ^
Hades Underwold ; CS
Ccash ! Ccomedy
[Anti]'Biyotik

And i have a question can plugin detect nicks with spaces (gap) between them like above?

should be simple, like this

"No Name ^ . ^" "change your nick" 0
"Hades Underwold ; CS" "change your nick" 0
"Ccash ! Ccomedy" "change your nick" 0
[Anti]'Biyotik "change your nick" 0


can't be easier than that!

hasanalizxc 05-17-2018 22:11

Re: CS 1.6 Ban Name Plugin Modification
 
Quote:

Originally Posted by tarsisd2 (Post 2592619)
should be simple, like this

"No Name ^ . ^" "change your nick" 0
"Hades Underwold ; CS" "change your nick" 0
"Ccash ! Ccomedy" "change your nick" 0
[Anti]'Biyotik "change your nick" 0


can't be easier than that!

i did but it didnt worked for me.

I am asking you for help, the plugin can not detect if there is a gap (space) in nick. I added kingplayer text to the names_banned.ini file and tested it worked. But it didn't work with king player nick. For example:

Plugin detects this nick: kingplayer
Plugin cannot detect this nick: king player

Would you please help me with this?

CrAzY MaN 05-17-2018 22:26

Re: CS 1.6 Ban Name Plugin Modification
 
[Use "king player"
Put double quotes!

hasanalizxc 05-18-2018 06:57

Re: CS 1.6 Ban Name Plugin Modification
 
Quote:

Originally Posted by CrAzY MaN (Post 2592625)
[Use "king player"
Put double quotes!

i tested but doesnt work. i want to simple modification to the first share. is it too hard for alliedmods members?

Natsheh 05-18-2018 12:45

Re: CS 1.6 Ban Name Plugin Modification
 
Just remove trim from the script


All times are GMT -4. The time now is 19:34.

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