- Timestamp:
- Aug 26, 2014, 4:41:47 PM (10 years ago)
- Location:
- binary-improvements/7dtd-server-fixes/src/CustomCommands
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/CustomCommands/SetTimeReal.cs
r107 r130 1 1 using System; 2 2 3 public class SetTimeReal : ConsoleCommand 3 namespace AllocsFixes.CustomCommands 4 4 { 5 public SetTimeReal (ConsoleSdtd cons) : base(cons)5 public class SetTimeReal : ConsoleCommand 6 6 { 7 } 7 public SetTimeReal (ConsoleSdtd cons) : base(cons) 8 { 9 } 8 10 9 public override string Description ()10 {11 return "set current ingame time, params: <day> <hour> <min>";12 }11 public override string Description () 12 { 13 return "set current ingame time, params: <day> <hour> <min>"; 14 } 13 15 14 public override string[] Names ()15 {16 return new string[] { "settimereal", "str" };17 }16 public override string[] Names () 17 { 18 return new string[] { "settimereal", "str" }; 19 } 18 20 19 public override void Run (string[] _params) 20 { 21 try { 22 if (_params.Length != 3) { 23 m_Console.SendResult ("Usage: settimereal <day> <hour> <min>"); 24 return; 21 public override void Run (string[] _params) 22 { 23 try { 24 if (_params.Length != 3) { 25 m_Console.SendResult ("Usage: settimereal <day> <hour> <min>"); 26 return; 27 } 28 29 int day, hour, min; 30 if (!int.TryParse (_params [0], out day)) { 31 m_Console.SendResult ("Could not parse day number \"" + _params [0] + "\""); 32 return; 33 } 34 if (day < 1) { 35 m_Console.SendResult ("Day must be >= 1"); 36 return; 37 } 38 if (!int.TryParse (_params [1], out hour)) { 39 m_Console.SendResult ("Could not parse hour \"" + _params [1] + "\""); 40 return; 41 } 42 if (hour > 23) { 43 m_Console.SendResult ("Hour must be <= 23"); 44 return; 45 } 46 if (!int.TryParse (_params [2], out min)) { 47 m_Console.SendResult ("Could not parse minute \"" + _params [2] + "\""); 48 return; 49 } 50 if (min > 59) { 51 m_Console.SendResult ("Minute must be <= 59"); 52 return; 53 } 54 if ((day < 1) || (hour < 8 && day < 1)) { 55 m_Console.SendResult ("Time may not be prior to day 1, 8:00"); 56 return; 57 } 58 59 ulong time = ((ulong)(day - 1) * 24000) + ((ulong)hour * 1000) + ((ulong)min * 1000 / 60) - 8000; 60 m_Console.gameManager.World.gameTime = time; 61 m_Console.SendResult (String.Format ("Set time to Day {0}, {1:00}:{2:00} = {3}", day, hour, min, time)); 62 } catch (Exception e) { 63 Log.Out ("Error in SetTimeReal.Run: " + e); 25 64 } 26 27 int day, hour, min;28 if (!int.TryParse (_params [0], out day)) {29 m_Console.SendResult ("Could not parse day number \"" + _params [0] + "\"");30 return;31 }32 if (day < 1) {33 m_Console.SendResult ("Day must be >= 1");34 return;35 }36 if (!int.TryParse (_params [1], out hour)) {37 m_Console.SendResult ("Could not parse hour \"" + _params [1] + "\"");38 return;39 }40 if (hour > 23) {41 m_Console.SendResult ("Hour must be <= 23");42 return;43 }44 if (!int.TryParse (_params [2], out min)) {45 m_Console.SendResult ("Could not parse minute \"" + _params [2] + "\"");46 return;47 }48 if (min > 59) {49 m_Console.SendResult ("Minute must be <= 59");50 return;51 }52 if ((day < 1) || (hour < 8 && day < 1)) {53 m_Console.SendResult ("Time may not be prior to day 1, 8:00");54 return;55 }56 57 ulong time = ((ulong)(day - 1) * 24000) + ((ulong)hour * 1000) + ((ulong)min * 1000 / 60) - 8000;58 m_Console.gameManager.World.gameTime = time;59 m_Console.SendResult (String.Format ("Set time to Day {0}, {1:00}:{2:00} = {3}", day, hour, min, time));60 } catch (Exception e) {61 Log.Out ("Error in SetTimeReal.Run: " + e);62 65 } 63 66 } 64 67 } 65
Note:
See TracChangeset
for help on using the changeset viewer.