Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if ( cmd == "tempban" )
- {
- if ( GetLevel(player) < 5 ) MessagePlayer (" [#4682B4][Error][#FFFFFF]You must need atleast level 5 to access the command",player );
- else if( !text ) MessagePlayer("[#4682B4][Syntax][#FFFFFF]/tempban <player> <day:hour:min> <reason>", player);
- else{
- local args = split( text, " " );
- local plr = GetPlayer(args[0]), expire = args[1], reason = GetTok( text, " ", 3, NumTok( text, " " ) );
- if (!expire) MessagePlayer( "Syntax: /" + cmd + " <playername> <day:hour:min> <Reason> ", player );
- else if(!reason) MessagePlayer( "Syntax: /" + cmd + " <playername> <day:hour:min> <Reason> ", player );
- else
- {
- if ( plr ) AddBan( player.Name, plr.Name, expire, reason, ip, uid, "on" );
- else
- {
- plr = args[0];
- local check = QuerySQL( db, "SELECT * FROM Banned WHERE Name='" + plr.Name + "'" );
- if ( GetSQLColumnData( check, 0 ) == null )
- {
- local q = QuerySQL( db, "SELECT * FROM Alias WHERE Name='" + plr.Name + "'" );
- if ( GetSQLColumnData( q, 1 ) && GetSQLColumnData( q, 0 ) != null )
- {
- local ip = GetSQLColumnData( q, 1 ) , uid = GetSQLColumnData( q, 2 );
- AddBan( player.Name, plr.Name, expire, reason, ip, uid, "off" );
- {
- else MessagePlayer( "> "+plr.Name+"'s UID cannot be found.", player );
- FreeSQLQuery( q );
- }
- else MessagePlayer( "> " +plr.Name+ " is already banned.", player );
- FreeSQLQuery( check );
- }
- }
- }
- }
- }
- }
- function AddBan( admin, player, expire, reason = "Not Specified", ip, uid, type )
- {
- //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 ] + " Day(s), " + ban_Expire[ 1 ] + " Hour(s), " + ban_Expire[ 2 ] + " Minute(s).",
- query = QuerySQL( sqliteDB, "INSERT INTO Banned( ban_nick, ban_ip, ban_time, ban_expire, ban_expireratio, ban_admin, ban_reason, ban_uid, ban_uid2 ) VALUES ( '"+ player.Name.tostring() +"','"+ player.IP.tostring() +"','"+ time().tostring() +"', '"+ ban_Expires.tostring() +"', '" + expire.tostring() + "', '"+ admin.Name.tostring() +"', '"+ reason.tostring() +"', '"+ player.UID.tostring() +"', '"+ player.UID2.tostring() +"')");
- FreeSQLQuery( query );
- MessagePlayer("[INFO] You have been temporarily banned by " + admin.Name, player);
- MessagePlayer("[INFO] Your ban is set to expire in: " + Calc, player);
- if ( type == "on" ) KickPlayer( player );
- }
- }
- else MessagePlayer("[INFO] Time should be numeric (day:hour:min)", admin );
- }
- else MessagePlayer("[INFO] Wrong format, day:hour:min (Numeric)", admin );
- }
Add Comment
Please, Sign In to add comment