/kill - Suicide or if admin, kill other people.

This commit is contained in:
Deathmax 2011-06-02 22:46:44 +08:00
parent eea8afdcf2
commit 00ce4ff2c4
2 changed files with 64 additions and 19 deletions

View file

@ -49,7 +49,10 @@ namespace TShockAPI
TShock.admincommandList.Add("maxspawns", new CommandDelegate(MaxSpawns));
TShock.admincommandList.Add("spawnrate", new CommandDelegate(SpawnRate));
TShock.admincommandList.Add("time", new CommandDelegate(Time));
TShock.admincommandList.Add("kill", new CommandDelegate(Kill));
TShock.admincommandList.Add("help", new CommandDelegate(Help));
TShock.commandList.Add("help", new CommandDelegate(Help));
TShock.commandList.Add("kill", new CommandDelegate(Kill));
}
#region Command Methods
public static void Kick(CommandArgs args)
@ -441,6 +444,26 @@ namespace TShockAPI
else
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /time <day/night>", new float[] { 255f, 0f, 0f });
}
public static void Kill(CommandArgs args)
{
bool isadmin = Tools.IsAdmin(args.PlayerID);
var msgargs = Regex.Split(args.Message, "(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
if (msgargs.Length == 2 && isadmin)
{
int player = -1;
player = Tools.FindPlayer((msgargs[1].TrimEnd('"')).TrimStart('"'));
//Main.player[player].KillMe(99999, 1);
Tools.SendMessage(args.PlayerID, "You just killed " + Tools.FindPlayer(player) + "!");
Tools.SendMessage(player, Tools.FindPlayer(args.PlayerID) + " just killed you!");
TShock.KillMe(player);
}
else
{
//Main.player[args.PlayerID].KillMe(99999, 1);
Tools.SendMessage(args.PlayerID, "You just suicided.");
TShock.KillMe(args.PlayerID);
}
}
#endregion
}
}