AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [H3LP] Show Banned Users (https://forums.alliedmods.net/showthread.php?t=296216)

DarthMan 04-15-2017 05:01

[H3LP] Show Banned Users
 
Hello. I've been working on a ban plug-in, and I have an issue with showing banned users in console.
Everything else works fine.

Code:

public cmdShowBans(id, level, cid)
{
        if (!cmd_access(id, level, cid, 1))
                return PLUGIN_HANDLED;
       
        new flags = get_user_flags(id);
       
        if ((is_user_connected(id)) && (!(flags & ADMIN_BAN)))
        {
                client_print(id,print_console,"You do not have access to use this command.");
        }
        new readdata[256]
        new cfgdir[256]
        new cfgpath[256]
        new max_bans
       
        new parsedid[33], parsedname[64], parsedadmin[64];

        get_configsdir(cfgdir, 256-1)

        format(cfgpath, charsmax(cfgpath), "%s/bans.ini", cfgdir)
        new f;
        if (!file_exists(cfgpath))
        {
                        client_print(id, print_console, "Ban file is missing")
                        return 0;
        }
        f=fopen(cfgpath, "rt")
        parse(readdata, parsedid, charsmax(parsedid), parsedname, charsmax(parsedname), parsedadmin, charsmax(parsedadmin));
        if (!fgets(f,readdata,sizeof(readdata)))
        {
                client_print(id, print_console, "No clients are banned.");
                return PLUGIN_HANDLED;
        }
        else while(fgets(f,readdata,sizeof(readdata)))
        {
                trim(readdata)
                if( !readdata[0] || readdata[0] == ';' || readdata[0] == '/' ) continue;
                if (contain(readdata,parsedname))
                {
                        max_bans++;
                        client_print(id, print_console, "%d. %s", max_bans, readdata)
                }
                else
                {
                        max_bans++;
                        client_print(id, print_console, "%d. No client name found on line %d!", max_bans,  max_bans)
                }
               
        }
        fclose(f)
        return PLUGIN_HANDLED;
}


Natsheh 04-15-2017 08:16

Re: [H3LP] Show Banned Users
 
Use console_print, and its max string characters are 256. So u need to triple use it or double use it or more


Remove this check its useless, u can add the access flag when you are registering the concmd
PHP Code:

    new flags get_user_flags(id);
    
    if ((
is_user_connected(id)) && (!(flags ADMIN_BAN)))
    {
        
client_print(id,print_console,"You do not have access to use this command.");
    } 


DarthMan 04-15-2017 08:43

Re: [H3LP] Show Banned Users
 
Quote:

Originally Posted by Natsheh (Post 2512367)
Use console_print, and its max string characters are 256. So u need to triple use it or double use it or more


Remove this check its useless, u can add the access flag when you are registering the concmd
PHP Code:

    new flags get_user_flags(id);
    
    if ((
is_user_connected(id)) && (!(flags ADMIN_BAN)))
    {
        
client_print(id,print_console,"You do not have access to use this command.");
    } 


Works, ty :)

edon1337 04-15-2017 08:51

Re: [H3LP] Show Banned Users
 
Quote:

Originally Posted by Natsheh (Post 2512367)
max string characters are 256.

255* We use 256 because of the last char that is ^0.


All times are GMT -4. The time now is 17:50.

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