MuhammadZeeshan

as s g asdfg sdfgh sdfag

Dec 22nd, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. else if ( cmd == "tempban" )
  2. {
  3. if ( GetLevel(player) < 5 ) MessagePlayer (" [#4682B4][Error][#FFFFFF]You must need atleast level 5 to access the command",player );
  4. else if( !text ) MessagePlayer("[#4682B4][Syntax][#FFFFFF]/tempban <player> <day:hour:min> <reason>", player);
  5. else{
  6. local args = split( text, " " );
  7. local plr = GetPlayer(args[0]), expire = args[1], reason = GetTok( text, " ", 3, NumTok( text, " " ) );
  8. if (!expire) MessagePlayer( "Syntax: /" + cmd + " <playername> <day:hour:min> <Reason> ", player );
  9. else if(!reason) MessagePlayer( "Syntax: /" + cmd + " <playername> <day:hour:min> <Reason> ", player );
  10. else
  11. {
  12. if ( plr ) AddBan( player.Name, plr.Name, expire, reason, ip, uid, "on" );
  13. else
  14. {
  15. plr = args[0];
  16. local check = QuerySQL( db, "SELECT * FROM Banned WHERE Name='" + plr.Name + "'" );
  17. if ( GetSQLColumnData( check, 0 ) == null )
  18. {
  19. local q = QuerySQL( db, "SELECT * FROM Alias WHERE Name='" + plr.Name + "'" );
  20. if ( GetSQLColumnData( q, 1 ) && GetSQLColumnData( q, 0 ) != null )
  21. {
  22. local ip = GetSQLColumnData( q, 1 ) , uid = GetSQLColumnData( q, 2 );
  23. AddBan( player.Name, plr.Name, expire, reason, ip, uid, "off" );
  24. {
  25. else MessagePlayer( "> "+plr.Name+"'s UID cannot be found.", player );
  26. FreeSQLQuery( q );
  27. }
  28. else MessagePlayer( "> " +plr.Name+ " is already banned.", player );
  29. FreeSQLQuery( check );
  30. }
  31. }
  32. }
  33. }
  34. }
  35. }
  36.  
  37. function AddBan( admin, player, expire, reason = "Not Specified", ip, uid, type )
  38. {
  39. //Equation = (DAYS*24*60*60) + (HOUR*60*60) + (MIN*60)
  40. local ban_Expire = split( expire, ":" ); //days:hours:minutes
  41. if( NumTok( expire, ":" ) == 3 )
  42. {
  43. if( IsNum( ban_Expire[ 0 ] ) && IsNum( ban_Expire[ 1 ] ) && IsNum( ban_Expire[ 2 ] ) )
  44. {
  45. if( ban_Expire[ 0 ].tointeger() <= 31 && ban_Expire[ 1 ].tointeger() <= 24 && ban_Expire[ 2 ].tointeger() <= 60 )
  46. {
  47. local ban_Expires = ( (ban_Expire[ 0 ].tointeger()*24*60*60) + (ban_Expire[ 1 ].tointeger()*60*60) + (ban_Expire[ 2 ].tointeger()*60) ),
  48. Calc = ban_Expire[ 0 ] + " Day(s), " + ban_Expire[ 1 ] + " Hour(s), " + ban_Expire[ 2 ] + " Minute(s).",
  49. 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() +"')");
  50. FreeSQLQuery( query );
  51. MessagePlayer("[INFO] You have been temporarily banned by " + admin.Name, player);
  52. MessagePlayer("[INFO] Your ban is set to expire in: " + Calc, player);
  53. if ( type == "on" ) KickPlayer( player );
  54. }
  55. }
  56. else MessagePlayer("[INFO] Time should be numeric (day:hour:min)", admin );
  57. }
  58. else MessagePlayer("[INFO] Wrong format, day:hour:min (Numeric)", admin );
  59. }
Add Comment
Please, Sign In to add comment