tempban problem wrong format error

Started by Nihongo^, Dec 23, 2018, 08:04 AM

Previous topic - Next topic

Nihongo^

Well i give proper command but the function said  "Wrong format, day:hour:min (Numeric)"
What's wrong ?



function IRCAddBan( nick, player, expire, reason = "No Reason" )

{
try{
     //Equation = (DAYS*24*60*60) + (HOUR*60*60) + (MIN*60)
     local ban_Expire = split( expire, ":" ); //days:hours:minutes
if( NumTok( expire, ":" ) == 3 )
{
if( !IsNum( ban_Expire[ 0 ] ) &&  !IsNum( ban_Expire[ 1 ] ) && !IsNum( ban_Expire[ 2 ] ) )
{
         if( ban_Expire[ 0 ].tointeger() <= 31 && ban_Expire[ 1 ].tointeger() <= 24 && ban_Expire[ 2 ].tointeger() <= 60 )
{
        local ban_Expires = ( (ban_Expire[ 0 ].tointeger()*24*60*60) + (ban_Expire[ 1 ].tointeger()*60*60) + (ban_Expire[ 2 ].tointeger()*60) ), 
                    Calc = ban_Expire[ 0 ] + " days " + ban_Expire[ 1 ] + " hours " + ban_Expire[ 2 ] + " minutes.",
                    query = QuerySQL( db, "INSERT INTO Tempban( ban_nick, ban_ip, ban_time, ban_expire, ban_expireratio, ban_admin, ban_reason ) VALUES ( '"+ player.Name.tostring() +"','"+ player.IP.tostring() +"','"+ time().tostring() +"', '"+ ban_Expires.tostring() +"', '" + expire.tostring() + "', '"+ user.tostring() +"', '"+ reason.tostring() +"')");
Message( "Admin " + nick + " has tempbanned " + player.Name + " Reason: " + reason + " for " + Calc + "" );
Staff(  ICOL_RED +"You have tempbanned " + player.Name + " successfully!" );
EchoMessage( ICOL_RED + "[" + player.ID + "] " + player.Name + " left the Server. (Kicked)." );
KickPlayer( player );
}
}
else Staff(  ICOL_RED + "Time should be numeric (day:hour:min)" );
}
else Staff(  ICOL_RED + "Wrong format, day:hour:min (Numeric)" );
}
catch(e) print( "Tempban function Error: " + e );
}


DizzasTeR

if( NumTok( expire, ":" ) == 3 )
Shouldn't this be a check of 2? Since: Day:Hour:Min has 2 `:`s so that if will never get executed