From c776f2c06eef689112884570e09430fbf949caea Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 21 Aug 2011 11:48:25 +0800 Subject: [PATCH] add time argument to /buff --- TShockAPI/Commands.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index fc83d3fe..17beedc8 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -2405,15 +2405,15 @@ namespace TShockAPI } } - //TODO: Add player and time arguments private static void Buff(CommandArgs args) { - if (args.Parameters.Count != 1) + if (args.Parameters.Count < 1 || args.Parameters.Count > 2) { - args.Player.SendMessage("Invalid syntax! Proper syntax: /buff ", Color.Red); + args.Player.SendMessage("Invalid syntax! Proper syntax: /buff ", Color.Red); return; } int id = 0; + int time = 3600; if (!int.TryParse(args.Parameters[0], out id)) { var found = Tools.GetBuffByName(args.Parameters[0]); @@ -2428,14 +2428,18 @@ namespace TShockAPI return; } id = found[0]; + if (args.Parameters.Count == 2) + int.TryParse(args.Parameters[1], out time); } if (id > 0 && id < Main.maxBuffs) { //args.TPlayer.AddBuff(id, 60); - args.Player.SetBuff(id); - args.Player.SendMessage(string.Format("You have just buffed yourself with {0} - {1}!", - Tools.GetBuffName(id), Tools.GetBuffDescription(id)), Color.Green); + args.Player.SetBuff(id, time); + args.Player.SendMessage(string.Format("You have buffed yourself with {0}({1}) for {2} seconds!", + Tools.GetBuffName(id), Tools.GetBuffDescription(id), Math.Round(((decimal)time / 60), 2)), Color.Green); } + else + args.Player.SendMessage("Invalid buff ID!", Color.Red); } #endregion Cheat Comamnds }