Пример #1
0
 internal static void DoBanIP(CommandArgs args)
 {
     if (args.Parameters.Count > 1)
     {
         if (!EBUtils.IsValidIP(args.Parameters[0]))
         {
             args.Player.SendMessage("This is not valid IP!", Color.Red);
             return;
         }
         string[] ban = EBUtils.IPBanInfo(args.Parameters[0]);
         if (ban[0] == "banned")
         {
             args.Player.SendMessage("IP mask is already banned.", Color.Red);
             return;
         }
         string   IP        = args.Parameters[0];
         int      BanDate   = EBUtils.UnixTimestamp();
         bool     permanent = false;
         int      UnbanDate;
         TimeSpan t = EBUtils.ParseTimeSpan(args.Parameters[1]);
         if (t.TotalSeconds > 0)
         {
             UnbanDate = BanDate + (int)t.TotalSeconds;
         }
         else
         {
             UnbanDate = 0;
             permanent = true;
         }
         string BannedBy = args.Player.Name;
         string Reason   = EBUtils.JoinArgs(args, (permanent) ? 1 : 2);
         if (String.IsNullOrEmpty(Reason))
         {
             Reason = "No reason.";
         }
         if (EBConfig.UseMysql)
         {
             EBData.DBMysql.Query("INSERT INTO BannedIP (IP, BanDate, UnbanDate, BannedBy, Reason) VALUES (@0, @1, @2, @3, @4)", IP, BanDate, UnbanDate, BannedBy, Reason);
         }
         else
         {
             EBData.DBSqlite.Query("INSERT INTO BannedIP (IP, BanDate, UnbanDate, BannedBy, Reason) VALUES (@0, @1, @2, @3, @4)", IP, BanDate, UnbanDate, BannedBy, Reason);
         }
         List <EBPlayer> plrs = EBPlayer.GetPlayersByIPMask(IP);
         foreach (EBPlayer plr in plrs)
         {
             TShock.Utils.Kick(plr.TSPlayer, "You have been banned: " + Reason, false, false, args.Player.Name, true);
         }
         args.Player.SendMessage(IP + " has been banned!.", Color.Yellow);
     }
     else
     {
         args.Player.SendMessage("Extended bans:", Color.Yellow);
         args.Player.SendMessage("/xban <player> [time] <reason>", Color.Yellow);
         args.Player.SendMessage("/xbanip <ip> [time] <reason>", Color.Yellow);
         args.Player.SendMessage("/xunbanip <ip>", Color.Yellow);
         args.Player.SendMessage("/xunban <player>", Color.Yellow);
     }
 }
Пример #2
0
 internal static void UnMute(CommandArgs args)
 {
     if (args.Parameters.Count > 0)
     {
         string          Player = args.Parameters[0];
         List <EBPlayer> plrs   = EBPlayer.GetPlayersByName(Player);
         if (plrs.Count > 1)
         {
             args.Player.SendMessage("There are 2 or more players matching to " + Player, Color.Orange);
             return;
         }
         else if (plrs.Count == 1)
         {
             foreach (EBPlayer plr in plrs)
             {
                 Player = plr.TSPlayer.Name;
             }
         }
         if (!EBUtils.IsPlayerMuted(Player))
         {
             args.Player.SendMessage("Player is not muted!", Color.Red);
             return;
         }
         int now = EBUtils.UnixTimestamp();
         if (EBConfig.UseMysql)
         {
             EBData.DBMysql.Query("UPDATE MutedPlayer SET UnmuteDate = @0 WHERE LOWER(Player) = @1 AND (UnmuteDate>@0 OR UnmuteDate = 0)", now, Player.ToLower());
         }
         else
         {
             EBData.DBSqlite.Query("UPDATE MutedPlayer SET UnmuteDate = @0 WHERE LOWER(Player) = @1 AND (UnmuteDate>@0 OR UnmuteDate = 0)", now, Player.ToLower());
         }
         if (plrs.Count > 0)
         {
             plrs[0].TSPlayer.SendMessage("You have been unmuted.", Color.Yellow);
         }
         args.Player.SendMessage(Player + " has been unmuted.", Color.Yellow);
     }
     else
     {
         args.Player.SendMessage("Extended mute:", Color.Yellow);
         args.Player.SendMessage("/xmute <player> [time] <reason>", Color.Yellow);
         args.Player.SendMessage("/xunmute <player>", Color.Yellow);
     }
 }
Пример #3
0
 internal static void DoBanPlayer(CommandArgs args)
 {
     if (args.Parameters.Count > 1)
     {
         string          Player = args.Parameters[0];
         List <EBPlayer> plrs   = EBPlayer.GetPlayersByName(Player);
         if (plrs.Count > 1)
         {
             args.Player.SendMessage("There are 2 or more players matching to " + Player, Color.Orange);
             return;
         }
         else if (plrs.Count == 1)
         {
             foreach (EBPlayer plr in plrs)
             {
                 Player = plr.TSPlayer.Name;
             }
         }
         if (EBUtils.IsPlayerBanned(args.Parameters[0]))
         {
             args.Player.SendMessage("Player is already banned.", Color.Red);
             return;
         }
         int      BanDate   = EBUtils.UnixTimestamp();
         bool     permanent = false;
         int      UnbanDate;
         TimeSpan t = EBUtils.ParseTimeSpan(args.Parameters[1]);
         if (t.TotalSeconds > 0)
         {
             UnbanDate = BanDate + (int)t.TotalSeconds;
         }
         else
         {
             UnbanDate = 0;
             permanent = true;
         }
         string BannedBy = args.Player.Name;
         string Reason   = EBUtils.JoinArgs(args, (permanent) ? 1 : 2);
         if (String.IsNullOrEmpty(Reason))
         {
             Reason = "No reason.";
         }
         if (EBConfig.UseMysql)
         {
             EBData.DBMysql.Query("INSERT INTO BannedPlayer (Player, BanDate, UnbanDate, BannedBy, Reason) VALUES (@0, @1, @2, @3, @4)", Player, BanDate, UnbanDate, BannedBy, Reason);
         }
         else
         {
             EBData.DBSqlite.Query("INSERT INTO BannedPlayer (Player, BanDate, UnbanDate, BannedBy, Reason) VALUES (@0, @1, @2, @3, @4)", Player, BanDate, UnbanDate, BannedBy, Reason);
         }
         if (plrs.Count > 0)
         {
             TShock.Utils.Kick(plrs[0].TSPlayer, "You have been banned: " + Reason, false, false, args.Player.Name, true);
         }
         args.Player.SendMessage(Player + " has been banned!", Color.Yellow);
     }
     else
     {
         args.Player.SendMessage("Extended bans:", Color.Yellow);
         args.Player.SendMessage("/xban <player> [time] <reason>", Color.Yellow);
         args.Player.SendMessage("/xbanip <ip> [time] <reason>", Color.Yellow);
         args.Player.SendMessage("/xunbanip <ip>", Color.Yellow);
         args.Player.SendMessage("/xunban <player>", Color.Yellow);
     }
 }