Time parameter in temp group command
This commit is contained in:
parent
d0a962bd0f
commit
2f2749c480
1 changed files with 19 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue