Support to amx_addban command

Here we can discuss suggestions and development of amxbans.
Nothing discussed in here are certain that it will be coded or added.
YamiKaitou
Amxbans Developer
Posts: 257
Joined: 17 Apr 2013, 14:09

Re: Support to amx_addban command

Postby YamiKaitou » 30 Jul 2013, 18:17

Sorry, but are you implying that there are basic optimizations missing from AMXBans (though I wouldn't doubt it, I have noticed some already in my local copy)

User avatar
SmileY
Posts: 8
Joined: 09 Jun 2013, 15:19
Location: Brazil
Contact:

Re: Support to amx_addban command

Postby SmileY » 31 Jul 2013, 13:28

YamiKaitou wrote:Sorry, but are you implying that there are basic optimizations missing from AMXBans (though I wouldn't doubt it, I have noticed some already in my local copy)


Ok i seems to wait for you version.
Hello world

YamiKaitou
Amxbans Developer
Posts: 257
Joined: 17 Apr 2013, 14:09

Re: Support to amx_addban command

Postby YamiKaitou » 31 Jul 2013, 18:15

SmileY wrote:
YamiKaitou wrote:Sorry, but are you implying that there are basic optimizations missing from AMXBans (though I wouldn't doubt it, I have noticed some already in my local copy)


Ok i seems to wait for you version.


Rather than waiting, start reporting what needs to be optimized. Optimization is not high on my priority list, working on reported issues is. So, if you see something that should be fixed, either report it on BitBucket or in the Bugs section

User avatar
SmileY
Posts: 8
Joined: 09 Jun 2013, 15:19
Location: Brazil
Contact:

Re: Support to amx_addban command

Postby SmileY » 31 Jul 2013, 22:11

For now is not to fix in current version, stable as rock :)

but a valid request its the friendly url, for advoid some problems its planning to ?-
Hello world

YamiKaitou
Amxbans Developer
Posts: 257
Joined: 17 Apr 2013, 14:09

Re: Support to amx_addban command

Postby YamiKaitou » 01 Aug 2013, 15:26

SmileY wrote:but a valid request its the friendly url, for advoid some problems its planning to ?-

Sorry, didn't understand this part

User avatar
SmileY
Posts: 8
Joined: 09 Jun 2013, 15:19
Location: Brazil
Contact:

Re: Support to amx_addban command

Postby SmileY » 01 Aug 2013, 21:10

YamiKaitou wrote:
SmileY wrote:but a valid request its the friendly url, for advoid some problems its planning to ?-

Sorry, didn't understand this part


Yeay, instead use

Code: Select all

http://forum.amxbans.net/posting.php?mode=quote&f=4&p=221


for example, replace with

Code: Select all

http://forum.amxbans.net/post/221


I do not know how to explain better this function, but i think its changed in .htaccess file and some php code.
Hello world

YamiKaitou
Amxbans Developer
Posts: 257
Joined: 17 Apr 2013, 14:09

Re: Support to amx_addban command

Postby YamiKaitou » 01 Aug 2013, 22:41

That is all handled by .htaccess file, there is nothing AMXBans can do to either enable or disable that ability

User avatar
SmileY
Posts: 8
Joined: 09 Jun 2013, 15:19
Location: Brazil
Contact:

Re: Support to amx_addban command

Postby SmileY » 02 Aug 2013, 04:56

YamiKaitou wrote:That is all handled by .htaccess file, there is nothing AMXBans can do to either enable or disable that ability



But will working normally on amx bans?
Hello world

YamiKaitou
Amxbans Developer
Posts: 257
Joined: 17 Apr 2013, 14:09

Re: Support to amx_addban command

Postby YamiKaitou » 02 Aug 2013, 13:38

If you configure it correctly, it should

zp_
Posts: 1
Joined: 17 Nov 2013, 17:53

Re: Support to amx_addban command

Postby zp_ » 17 Nov 2013, 18:22

Since I just could not get amx_ban to ban steamid's or ip's of disconnected players to work at all for me, I decided to quickly throw together an amx_addban function that doesn't check if the player is in the server.

in cmdBan.inl

Code: Select all

public cmdAddBan(id, level, cid)
{
    /* Checking if the admin has the right access */
    if (!cmd_access(id,level,cid,3))
        return PLUGIN_HANDLED

    new text[256]
    read_args(text, 255)

    enum _:PlayerData
    {
        iPlrID,
        szName[32],
        szIP[20],
        szAuthID[35]
    }
    new chData[PlayerData]

    // get player ident and bantime depending on the ban cmd format (old or new)
    new ban_length[50]
    new plr_name[32]
    new plr_ip[20]

    parse(text, g_ident, charsmax(g_ident), ban_length, charsmax(ban_length), g_choiceReason[id], charsmax(g_choiceReason[]), plr_name, charsmax(plr_name), plr_ip, charsmax(plr_ip))

    trim(g_ident)
    trim(ban_length)
    trim(g_choiceReason[id])
    remove_quotes(g_choiceReason[id])
    trim(plr_name)
    remove_quotes(plr_name)
    trim(plr_ip)

    // Check so the ban command has the right format
    if( !is_str_num(ban_length) || read_argc() < 3 )
    {
        client_print(id,print_console,"[AMXBans] %L",LANG_PLAYER,"AMX_BAN_SYNTAX_NEW")
        return PLUGIN_HANDLED
    }

    //if the reason is empty use the default ban reason from cvar
    if(!strlen(g_choiceReason[id])) {
        get_pcvar_string(pcvar_default_banreason,g_choiceReason[id],charsmax(g_choiceReason[]))
    }

    // if player name is empty , use unknown
    if (!strlen(plr_name))
        plr_name = "unknown"

    g_choiceTime[id] = abs(str_to_num(ban_length))
    new cTimeLength[128]
    if (g_choiceTime[id] > 0)
        get_time_length(id, g_choiceTime[id], timeunit_minutes, cTimeLength, 127)
    else
        format(cTimeLength, 127, "%L", LANG_PLAYER, "TIME_ELEMENT_PERMANENTLY")

    // This stops admins from banning perm in console if not adminflag n
    if(!(get_user_flags(id) & get_higher_ban_time_admin_flag()) && g_choiceTime[id] == 0)
    {
        client_print(id,print_console,"[AMXBans] %L",LANG_PLAYER,"NOT_BAN_PERMANENT")
        return PLUGIN_HANDLED
    }

    chData[iPlrID] = id
    copy(chData[szName], charsmax(chData[szName]), plr_name)

    new pquery[1024]

    if (equal(g_ident, "STEAM_", 6))
    {
        formatex(pquery, charsmax(pquery), "SELECT player_id FROM %s%s WHERE player_id='%s' AND expired=0", g_dbPrefix, tbl_bans, g_ident)

        copy(chData[szAuthID], charsmax(chData[szAuthID]), g_ident)
        copy(chData[szIP], charsmax(chData[szIP]), plr_ip)
        g_ban_type[id] = "S"
    }
    else
    {
        formatex(pquery, charsmax(pquery), "SELECT player_ip FROM %s%s WHERE player_ip='%s' AND expired=0", g_dbPrefix, tbl_bans, g_ident)

        copy(chData[szIP], charsmax(chData[szIP]), g_ident)
        g_ban_type[id] = "SI"
    }

    SQL_ThreadQuery(g_SqlX, "cmd_addban_", pquery, chData, sizeof(chData))

    return PLUGIN_HANDLED
}

public cmd_addban_(failstate, Handle:query, error[], errnum, data[], size)
{
    enum
    {
        iPlrID,
        szName[32],
        szIP[20],
        szAuthID[35]
    }

    new id = data[iPlrID]
    new plr_name[32]
    new plr_ip[20]
    new plr_id[35]

    copy(plr_name, charsmax(plr_name), data[szName])
    copy(plr_ip, charsmax(plr_ip), data[szIP])
    copy(plr_id, charsmax(plr_id), data[szAuthID])

    new bool:serverCmd = false
    /* Determine if this was a server command or a command issued by a player in the game */
    if ( id == 0 )
        serverCmd = true

    if (failstate)
    {
        new szQuery[256]
        SQL_GetQueryString(query,szQuery,255)
        MySqlX_ThreadError( szQuery, error, errnum, failstate, 6 )
    }
    else
    {
        if (!SQL_NumResults(query))
        {
            new admin_nick[100], admin_steamid[50], admin_ip[20]
            mysql_get_username_safe(id, admin_nick, 99)
            get_user_ip(id, admin_ip, 19, 1)

            if (!serverCmd)
            {
                get_user_authid(id, admin_steamid, 49)

                if ( get_pcvar_num(pcvar_debug) >= 1 )
                    log_amx("[AMXBans cmdBan] Adminsteamid: %s, Servercmd: %s", admin_steamid, (serverCmd)?"Yes":"No")
            }
            else
            {
                /* If the server does the ban you cant get any steam_ID or team */
                admin_steamid = ""

                /* This is so you can have a shorter name for the servers hostname.
                Some servers hostname can be very long b/c of sponsors and that will make the ban list on the web bad */
                new servernick[100]
                get_pcvar_string(pcvar_server_nick, servernick, 99)
                if (strlen(servernick))
                    copy(admin_nick,charsmax(admin_nick),servernick)
            }

            /* If HLGUARD ban, the admin nick will be set to [HLGUARD] */
            if ( contain(g_choiceReason[id], "[HLGUARD]") != -1 )
                copy(admin_nick,charsmax(admin_nick),"[HLGUARD]")

            /* If ATAC ban, the admin nick will be set to [ATAC] */
            if ( contain(g_choiceReason[id], "Max Team Kill Violation") != -1 )
                copy(admin_nick,charsmax(admin_nick),"[ATAC]")

            if ( get_pcvar_num(pcvar_debug) >= 1 )
                log_amx("[AMXBans cmdBan] Admin nick: %s, Admin userid: %d", admin_nick, get_user_userid(id))

            new server_name[200]
            mysql_get_servername_safe(server_name, charsmax(server_name))

            if ( get_pcvar_num(pcvar_add_mapname) ) {
                new mapname[32]//, pre[4],post[4]
                get_mapname(mapname,31)
                format(server_name,charsmax(server_name),"%s (%s)",server_name,mapname)
            }

            new player_nick[64]
            mysql_escape_string(g_choicePlayerName[id],player_nick,charsmax(player_nick))
            new admin_nick_safe[200]
            mysql_escape_string(admin_nick,admin_nick_safe,charsmax(admin_nick_safe))

            new pquery[1024]

            format(pquery, charsmax(pquery), "INSERT INTO `%s%s` \
                (player_id, player_ip, player_nick, admin_ip, admin_id, admin_nick, ban_type, ban_reason, ban_created, ban_length, server_name, server_ip, expired) \
                VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', UNIX_TIMESTAMP(NOW()), %d, '%s', '%s:%s', 0)", \
                g_dbPrefix, tbl_bans, plr_id, plr_ip, plr_name, admin_ip, admin_steamid, admin_nick, g_ban_type[id], \
                g_choiceReason[id], g_choiceTime[id], server_name, g_ip, g_port)

            new data[3]
            data[0] = id
            SQL_ThreadQuery(g_SqlX, "insert_bandetails", pquery, data, 3)
        }
    }

    return PLUGIN_HANDLED
}


and amxbans_main.sma

Code: Select all

register_concmd("amx_addban", "cmdAddBan", ADMIN_BAN, "<steamID or IP> <time in mins> <reason> <name> <ip>")
register_srvcmd("amx_addban", "cmdAddBan", -1, "<steamID or IP> <time in mins> <reason> <name> <ip>")


above

Code: Select all

register_concmd("amx_unban", "cmdUnban", ADMIN_BAN, "<steamID or IP>");


format is: amx_addban <steamid/ip> <time in minutes> <reason> <name> <ip>

<name> and <ip> are optional to set players name (name defaults to "unknown" if name argument is empty) and ip (ip will automatically fill in if it's an ip ban) ... initial testing suggests that it works, though the code could be more optimized (for example it still says "Player not found: SteamID/IP" in console when banning a steamid or ip address, even though it still goes through and shows up on the banlist)

There are also no checks for client immunity or anything of that sort... (i check this in my plugin that needs to directly ban a disconnected player's steamid or ip)


Return to “Development and Suggestions”

Who is online

Users browsing this forum: No registered users and 0 guests