Well i give proper command but the function said "Wrong format, day:hour:min (Numeric)"
What's wrong ?
(https://s17.postimg.org/csosnuk73/temp.png)
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() + "', '"+ nick.tostring() +"', '"+ reason.tostring() +"')");
Message( "Admin " + nick + " has tempbanned " + player.Name + " Reason: " + reason + " for " + Calc + "" );
StaffMessage( user, ICOL_RED + "You have tempbanned " + player.Name + " successfully!" );
StaffMessage( ICOL_RED + "[" + player.ID + "] " + player.Name + " left the Server. (Kicked)." );
KickPlayer( player );
}
}
else StaffMessage( ICOL_RED + "Time should be numeric (day:hour:min)" );
}
else StaffMessage( ICOL_RED + "Wrong format, day:hour:min (Numeric)" );
}
catch(e) print( "Tempban function Error: " + e );
}
and command
else if ( cmd == "tempban" )
{
try{
local txt_Split;
if ( FindLevel( nick, false )== "User" ) StaffMessage( ICOL_RED + "You have to be admin to use this command." );
else if( text == "" ) {
StaffMessage( ICOL_RED + "Syntax, !tempban <player/ID> <day:hour:min> <reason>");
return;
}else
{
if( NumTok( text, " " ) == 2 )
{
txt_Split = split( text, " " );
local plr = GetPlayer( txt_Split[ 0 ] ), expire = txt_Split[ 1 ];
if( plr ) IRCAddBan( nick, plr, expire );
else StaffMessage( ICOL_RED + "Error: Invalid player." );
}
else if( NumTok( text, " " ) >= 3 )
{
txt_Split = split( text, " " );
local plr = GetPlayer( txt_Split[ 0 ] ), expire = txt_Split[ 1 ], reason = txt_Split[ 2 ];
if( plr ) IRCAddBan( nick, plr, expire, reason );
else StaffMessage( ICOL_RED + "Error: Invalid player." );
}
else StaffMessage( ICOL_RED + "Syntax, !tempban <player/ID> <day:hour:min> <reason>");
}
}
catch(e) print( "Tempban error: " + e );
}
P.S
i use
else if( text == "" )
instead of
[code]if( !text )
hello any 1