Raised This Month: $ Target: $400
 0% 

Amzbans ban cmd.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 10-16-2010 , 06:36   Amzbans ban cmd.
Reply With Quote #1

So I'm using the newest amxbans. And if I'm banning using command like that:
amx_ban player1 60 reason1

All works great, reson is exactly reson1

but if I'll ban with:
amx_ban "player1" "60" "reason1"

the reason will be:
60" "reason1".

This is code of command:
Code:
public cmdBan(id, level, cid)
{
    /* Checking if the admin has the right access */
    if (!cmd_access(id,level,cid,3))
        return PLUGIN_HANDLED

    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;
        
    g_menuban_type[id] = 0
    
    new text[128]
    read_args(text, 127)
    
    // get player ident and bantime depending on the ban cmd format (old or new)
    new ban_length[50]
    if(get_pcvar_num(pcvar_newbancmd))
        parse(text, g_ident, 49, ban_length, 49)
    else
        parse(text, ban_length, 49, g_ident, 49)
    
    trim(g_ident)
    trim(ban_length)
    
    // Check so the ban command has the right format
    if( !is_str_num(ban_length) || read_argc() < 3 )
    {
        if(get_pcvar_num(pcvar_newbancmd))
            client_print(id,print_console,"[AMXBans] %L",LANG_PLAYER,"AMX_BAN_SYNTAX_NEW")
        else
            client_print(id,print_console,"[AMXBans] %L",LANG_PLAYER,"AMX_BAN_SYNTAX")
        return PLUGIN_HANDLED
    }
    
    
    //new length1 = strlen(ban_length)
    //new length2 = strlen(g_ident)
    //new length = length1 + length2
    //length+=2
    new length = strlen(ban_length) + strlen(g_ident) + 2
    
    // get and format the ban reason
    new reason[128]
    read_args(reason,127)
    formatex(g_choiceReason[id], charsmax(g_choiceReason[]), "%s", reason[length])
    trim(g_choiceReason[id])
    remove_quotes(g_choiceReason[id])
    
    //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[]))
    }
    
    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
    }

    // Try to find the player that should be banned
    g_choicePlayerId[id] = locate_player(id, g_ident)

    // Player is a BOT or has immunity
    if (g_choicePlayerId[id] == -1)
        return PLUGIN_HANDLED
        
    if(g_being_banned[g_choicePlayerId[id]]) {
        if ( get_pcvar_num(pcvar_debug) >= 1 )
            log_amx("[AMXBans Blocking doubleban(g_being_banned)] Playerid: %d BanLenght: %s Reason: %s", g_choicePlayerId[id], g_choiceTime[id], g_choiceReason[id])
            
        return PLUGIN_HANDLED
    }
    
    g_being_banned[g_choicePlayerId[id]] = true
    
    if ( get_pcvar_num(pcvar_debug) >= 1 )
        log_amx("[AMXBans cmdBan function 1]Playerid: %d", g_choicePlayerId[id])

    if (g_choicePlayerId[id])
    {
        get_user_authid(g_choicePlayerId[id], g_choicePlayerAuthid[id], 49)
        get_user_ip(g_choicePlayerId[id], g_choicePlayerIp[id], 29, 1)
    }
    else
    {
        g_being_banned[0]=false
        
        if (serverCmd)
            server_print("[AMXBans] The Player %s was not found",g_ident)
        else
            console_print(id, "[AMXBans] The Player %s was not found",g_ident)

        if ( get_pcvar_num(pcvar_debug) >= 1 )
            log_amx("[AMXBans] Player %s could not be found",g_ident)
                
        return PLUGIN_HANDLED
    }

    if(!get_ban_type(g_ban_type[id],charsmax(g_ban_type[]),g_choicePlayerAuthid[id],g_choicePlayerIp[id])) {
        log_amx("[AMXBans ERROR cmdBan] Steamid / IP Invalid! Bantype: <%s> | Authid: <%s> | IP: <%s>",g_ban_type[id],g_choicePlayerAuthid[id],g_choicePlayerIp[id])
        g_being_banned[g_choicePlayerId[id]]=false
        return PLUGIN_HANDLED
    }
    
    if (equal(g_ban_type[id], "S"))
    {
        formatex(g_SqlX_Cache, charsmax(g_SqlX_Cache),"SELECT player_id FROM %s WHERE player_id='%s' AND expired=0", tbl_bans, g_choicePlayerAuthid[id])
        
        if ( get_pcvar_num(pcvar_debug) >= 1 )
            log_amx("[AMXBans cmdBan] Banned a player by SteamID: %s",g_choicePlayerAuthid[id])
    }
    else
    {
        formatex(g_SqlX_Cache, charsmax(g_SqlX_Cache),"SELECT player_ip FROM %s WHERE player_ip='%s' AND expired=0", tbl_bans, g_choicePlayerIp[id])
        
        if ( get_pcvar_num(pcvar_debug) >= 1 )
            log_amx("[AMXBans cmdBan] Banned a player by IP/steamID: %s",g_choicePlayerIp[id])
    }
    new pquery[1024]
    prepare_prefix(g_SqlX_Cache,pquery,charsmax(pquery))
    
    new data[1]
    data[0] = id
    SQL_ThreadQuery(g_SqlX, "cmd_ban_", pquery, data, 1)
    
    return PLUGIN_HANDLED
}
Anyone knows how to fix that?-.-
FiFiX is offline
Send a message via Skype™ to FiFiX
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-16-2010 , 11:34   Re: Amzbans ban cmd.
Reply With Quote #2

PHP Code:
--- Revision 89
+++ Revision 121
@@ -131,12 +131,14 @@
     
// get player ident and bantime depending on the ban cmd format (old or new)
     
new ban_length[50]
     if(
get_pcvar_num(pcvar_newbancmd))
-        
parse(textg_ident49ban_length49)
+        
parse(textg_ident49ban_length49g_choiceReason[id], charsmax(g_choiceReason[]))
     else
-        
parse(textban_length49g_ident49)
+        
parse(textban_length49g_ident49g_choiceReason[id], charsmax(g_choiceReason[]))
     
     
trim(g_ident)
     
trim(ban_length)
+    
trim(g_choiceReason[id])
+    
remove_quotes(g_choiceReason[id])
     
     
// Check so the ban command has the right format
     
if( !is_str_num(ban_length) || read_argc() < )
@@ -
148,+150,@@
         return 
PLUGIN_HANDLED
     
}
     
-    
+
/*    
     //new length1 = strlen(ban_length)
     //new length2 = strlen(g_ident)
     //new length = length1 + length2
@@ -161,7 +163,7 @@
     formatex(g_choiceReason[id], charsmax(g_choiceReason[]), "%s", reason[length])
     trim(g_choiceReason[id])
     remove_quotes(g_choiceReason[id])
-    
+*/    
     //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[])) 
Here is the diff for this bug. Revision 121 is the fixed version, Revision 89 is the original version.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 10-16-2010 , 12:22   Re: Amzbans ban cmd.
Reply With Quote #3

Not better is to use
remove_quotes(text)
few lines before?
than
remove_quotes(g_choiceReason[id])later?
FiFiX is offline
Send a message via Skype™ to FiFiX
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-16-2010 , 12:30   Re: Amzbans ban cmd.
Reply With Quote #4

No as the quotes separate the parameters. If you have a space in a players name and you remove the quotes before you parse the text, your results will be incorrect.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 10-16-2010 , 12:35   Re: Amzbans ban cmd.
Reply With Quote #5

Ahh, thank You Yami(like Tami from gummy bears )
btw. I'm fifka from amxbans.de ;]
FiFiX is offline
Send a message via Skype™ to FiFiX
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:29.


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