Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "oban":
- {
- ev.Allow = false;
- if (args.Length < 5)
- {
- if (ServerExecutingCommand) Plugin.Info("USAGE: oban [UserID/IP] [TimeInMinutes or 0 for perm] [m/h/d/y] [Reason]");
- else ev.Sender.RAMessage("USAGE: oban [UserID/IP] [TimeInMinutes or 0 for perm] [Reason]");
- return;
- }
- string IssuingPlayer = "";
- if (ServerExecutingCommand) IssuingPlayer = "SERVER";
- else IssuingPlayer = Plugin.GetPlayer(ev.Sender.SenderId).name;
- string bannedUserID = args[1];
- int min;
- switch(args[3])
- {
- case "m":
- {
- min = (int.TryParse(args[2], out int x)) ? x : 0;
- break;
- }
- case "h":
- {
- min = (int.TryParse(args[2], out int x)) ? x*60 : 0;
- break;
- }
- case "d":
- {
- min = (int.TryParse(args[2], out int x)) ? x * 60 * 24 : 0;
- break;
- }
- case "y":
- {
- min = (int.TryParse(args[2], out int x)) ? x * 60 * 24 * 365 : 0;
- break;
- }
- }
- //int minutes = (int.TryParse(args[2], out int x)) ? x : 0;
- bool ipban = false;
- if (args[1].Contains("."))
- {
- if (args[1].Split('.').Length != 4 && args[1].Substring(args[1].Length - 1) != ".")
- {
- if (ServerExecutingCommand) Plugin.Info("Invalid IP Address");
- else ev.Sender.RAMessage("Invalid IP Address");
- return;
- }
- ipban = true;
- }
- else if (args[1].Trim().Length < 17 || args[1].Trim().Length > 18)
- {
- if (ServerExecutingCommand) Plugin.Info("Invalid UserID");
- else ev.Sender.RAMessage("Invalid UserID");
- return;
- }
- bool discord = false;
- string UserIDOrIP = "";
- if (!ipban)
- {
- discord = (args[1].Trim().Length > 17);
- UserIDOrIP = args[1] + (discord ? "@discord" : "@steam");
- }
- else
- {
- UserIDOrIP = args[1];
- }
- long banExpiryTime = TimeBehaviour.GetBanExpieryTime(26297438);
- if (args[2] != "0") banExpiryTime = TimeBehaviour.GetBanExpieryTime(Convert.ToUInt32(args[2]));
- BanDetails banDetails = new BanDetails();
- banDetails.Id = UserIDOrIP;
- banDetails.IssuanceTime = TimeBehaviour.CurrentTimestamp();
- banDetails.Expires = banExpiryTime;
- banDetails.Issuer = ev.Sender.Nickname;
- banDetails.OriginalName = "OfflinePlayer" + RandomGenerator.GetInt32(1, 9999);
- string reason = "";
- IEnumerable<string> reasons = args.Where(s => s != args[0] && s != args[1] && s != args[2] && s != args[3]);
- foreach (string st in reasons)
- reason += st;
- banDetails.Reason = reason;
- if (ipban) BanHandler.IssueBan(banDetails, BanHandler.BanType.IP);
- else BanHandler.IssueBan(banDetails, BanHandler.BanType.UserId);
- if (ServerExecutingCommand) Plugin.Info("Banned");
- else ev.Sender.RAMessage("Banned");
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement