source: binary-improvements/7dtd-server-fixes/src/CustomCommands/GetTime.cs@ 219

Last change on this file since 219 was 130, checked in by alloc, 10 years ago

Fixes

File size: 813 bytes
RevLine 
[75]1using System;
2
[130]3namespace AllocsFixes.CustomCommands
[75]4{
[130]5 public class GetTime : ConsoleCommand
[75]6 {
[130]7 public GetTime (ConsoleSdtd cons) : base(cons)
8 {
9 }
[75]10
[130]11 public override string Description ()
12 {
13 return "retrieves current ingame time";
14 }
[75]15
[130]16 public override string[] Names ()
17 {
18 return new string[] { "gettime", "gt" };
19 }
[75]20
[130]21 public override void Run (string[] _params)
22 {
23 try {
24 ulong time = this.m_Console.gameManager.World.gameTime;
25 int day = (int)(time / 24000) + 1;
26 int hour = (int)(time % 24000) / 1000 + 8;
27 if (hour > 23) {
28 day++;
29 hour -= 24;
30 }
31 int min = (int)(time % 1000) * 60 / 1000;
32 m_Console.SendResult (String.Format ("Day {0}, {1:00}:{2:00} ", day, hour, min));
33 } catch (Exception e) {
34 Log.Out ("Error in GetTime.Run: " + e);
[103]35 }
[75]36 }
37 }
38}
Note: See TracBrowser for help on using the repository browser.