From 2f2749c480176e3ee90b1267eb9a1dfa9cab5a81 Mon Sep 17 00:00:00 2001 From: White Date: Sun, 5 Apr 2015 22:42:57 -0400 Subject: [PATCH] Time parameter in temp group command --- TShockAPI/Commands.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 21754931..2b277185 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -870,6 +870,10 @@ namespace TShockAPI args.Player.PlayerData = new PlayerData(args.Player); args.Player.Group = TShock.Groups.GetGroupByName(TShock.Config.DefaultGuestGroupName); args.Player.tempGroup = null; + if (args.Player.tempGroupTimer != null) + { + args.Player.tempGroupTimer.Stop(); + } args.Player.UserAccountName = null; args.Player.UserID = -1; args.Player.IsLoggedIn = false; @@ -1630,6 +1634,21 @@ namespace TShockAPI return; } + if (args.Parameters.Count > 2) + { + int time; + if (!TShock.Utils.TryParseTime(args.Parameters[2], out time)) + { + args.Player.SendErrorMessage("Invalid time string! Proper format: _d_h_m_s, with at least one time specifier."); + args.Player.SendErrorMessage("For example, 1d and 10h-30m+2m are both valid time strings, but 2 is not."); + return; + } + + ply[0].tempGroupTimer = new System.Timers.Timer(time*1000); + ply[0].tempGroupTimer.Elapsed += ply[0].TempGroupTimerElapsed; + ply[0].tempGroupTimer.Start(); + } + Group g = TShock.Utils.GetGroup(args.Parameters[1]); ply[0].tempGroup = g;