/tempjail PlayerName Seconds - Jails a player for the amount of seconds given, maximum seconds is 120..
Shortcut: /tj
- Code: Select all
//Made by ane200055
//Version v0.1
using System;
using System.Threading;
namespace MCDzienny
{
public class CmdTempjail : Command
{
public override string name { get { return "tempjail"; } }
public override string shortcut { get { return "tj"; } }
public override string type { get { return "mod"; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override void Use(Player p, string message)
{
if (message == "")
{
Help(p);
return;
}
if (p == null)
{
Player.SendMessage(p, "This command can only be used in-game, use /jail PlayerName instead.");
return;
}
var split = message.Split(' ');
Player who = Player.Find(split[0]);
if (who == null)
{
Player.SendMessage(p, "Couldn't find player.");
return;
}
if (p != null && who.group.Permission > p.group.Permission)
{
Player.SendMessage(p, "You cannot use this command someone ranked higher than you.");
return;
}
if (p == who)
{
Player.SendMessage(p, "You cannot use this command on yourself.");
return;
}
Command.all.Find("jail").Use(p, who.name);
int time = 120;
try
{
time = Convert.ToInt32(message.Split(' ')[1]);
}
catch
{
Player.SendMessage(p, "Invalid time given, the maximum amount of time is 120 seconds.");
}
Player.GlobalMessage(who.color + who.name + Server.DefaultColor + " has been %8jailed " + Server.DefaultColor + "for " + time + " seconds.");
Thread.Sleep(time * 1000);
Command.all.Find("jail").Use(p, who.name);
}
public override void Help(Player p)
{
Player.SendMessage(p, "%e/tempjail %bPlayerName Seconds %e- Jails a player for the amount seconds given.");
Player.SendMessage(p, "%eThis also works by doing /tj %bPlayerName%e.");
}
}
}