Changeset 130 for binary-improvements/7dtd-server-fixes/src/CustomCommands
- Timestamp:
- Aug 26, 2014, 4:41:47 PM (10 years ago)
- Location:
- binary-improvements/7dtd-server-fixes/src/CustomCommands
- Files:
-
- 1 added
- 9 edited
- 6 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/CustomCommands/CreativeMenu.cs
r128 r130 2 2 using System.Collections.Generic; 3 3 4 public class CreativeMenu : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public CreativeMenu (ConsoleSdtd cons) : base(cons)6 public class CreativeMenu : ConsoleCommand 7 7 { 8 } 8 public CreativeMenu (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "enable/disable creative menu";13 }12 public override string Description () 13 { 14 return "enable/disable creative menu"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "creativemenu", "cm" };18 }17 public override string[] Names () 18 { 19 return new string[] { "creativemenu", "cm" }; 20 } 19 21 20 public override void Run (string[] _params) 21 { 22 try { 23 if (_params.Length != 1) { 24 m_Console.SendResult ("Usage: creativemenu <0/1>"); 25 return; 22 public override void Run (string[] _params) 23 { 24 try { 25 if (_params.Length != 1) { 26 m_Console.SendResult ("Usage: creativemenu <0/1>"); 27 return; 28 } 29 30 GameStats.Set (EnumGameStats.IsCreativeMenuEnabled, _params [0].Equals ("1")); 31 32 m_Console.SendResult ("Set creative menu to " + _params [0].Equals ("1")); 33 } catch (Exception e) { 34 Log.Out ("Error in CreativeMenu.Run: " + e); 26 35 } 27 28 GameStats.Set (EnumGameStats.IsCreativeMenuEnabled, _params [0].Equals ("1"));29 30 m_Console.SendResult ("Set creative menu to " + _params [0].Equals ("1"));31 } catch (Exception e) {32 Log.Out ("Error in CreativeMenu.Run: " + e);33 36 } 34 37 } 35 38 } 36 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/GetGamePrefs.cs
r107 r130 2 2 using System.Collections.Generic; 3 3 4 public class GetGamePrefs : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 private string[] forbiddenPrefs = new string[] { 6 public class GetGamePrefs : ConsoleCommand 7 { 8 private string[] forbiddenPrefs = new string[] { 7 9 "telnet", 8 10 "adminfilename", … … 14 16 }; 15 17 16 private bool prefAccessAllowed (EnumGamePrefs gp) 17 { 18 string gpName = gp.ToString ().ToLower (); 19 foreach (string s in forbiddenPrefs) { 20 if (gpName.Contains (s)) { 21 return false; 18 private bool prefAccessAllowed (EnumGamePrefs gp) 19 { 20 string gpName = gp.ToString ().ToLower (); 21 foreach (string s in forbiddenPrefs) { 22 if (gpName.Contains (s)) { 23 return false; 24 } 22 25 } 26 return true; 23 27 } 24 return true;25 }26 28 27 public GetGamePrefs (ConsoleSdtd cons) : base(cons)28 {29 }29 public GetGamePrefs (ConsoleSdtd cons) : base(cons) 30 { 31 } 30 32 31 public override string Description ()32 {33 return "gets a game pref";34 }33 public override string Description () 34 { 35 return "gets a game pref"; 36 } 35 37 36 public override string[] Names ()37 {38 return new string[]38 public override string[] Names () 39 { 40 return new string[] 39 41 { 40 42 "getgamepref", 41 43 "gg" 42 44 }; 43 }45 } 44 46 45 public override void Run (string[] _params)46 {47 try {48 EnumGamePrefs enumGamePrefs = EnumGamePrefs.Last;47 public override void Run (string[] _params) 48 { 49 try { 50 EnumGamePrefs enumGamePrefs = EnumGamePrefs.Last; 49 51 50 if (_params.Length > 0) { 51 try { 52 enumGamePrefs = (EnumGamePrefs)((int)Enum.Parse (typeof(EnumGamePrefs), _params [0])); 53 } catch (Exception) { 52 if (_params.Length > 0) { 53 try { 54 enumGamePrefs = (EnumGamePrefs)((int)Enum.Parse (typeof(EnumGamePrefs), _params [0])); 55 } catch (Exception) { 56 } 54 57 } 55 }56 58 57 if (enumGamePrefs == EnumGamePrefs.Last) { 58 SortedList<string, string> sortedList = new SortedList<string, string> (); 59 foreach (EnumGamePrefs gp in Enum.GetValues(typeof(EnumGamePrefs))) { 60 if ((_params.Length == 0) || (gp.ToString ().ToLower ().Contains (_params [0].ToLower ()))) { 61 if (prefAccessAllowed (gp)) { 62 sortedList.Add (gp.ToString (), string.Format ("{0} = {1}", gp.ToString (), GamePrefs.GetObject (gp))); 59 if (enumGamePrefs == EnumGamePrefs.Last) { 60 SortedList<string, string> sortedList = new SortedList<string, string> (); 61 foreach (EnumGamePrefs gp in Enum.GetValues(typeof(EnumGamePrefs))) { 62 if ((_params.Length == 0) || (gp.ToString ().ToLower ().Contains (_params [0].ToLower ()))) { 63 if (prefAccessAllowed (gp)) { 64 sortedList.Add (gp.ToString (), string.Format ("{0} = {1}", gp.ToString (), GamePrefs.GetObject (gp))); 65 } 63 66 } 64 67 } 68 foreach (string s in sortedList.Keys) { 69 m_Console.SendResult (sortedList [s]); 70 } 71 } else { 72 if (prefAccessAllowed (enumGamePrefs)) 73 m_Console.SendResult (string.Format ("{0} = {1}", enumGamePrefs, GamePrefs.GetObject (enumGamePrefs))); 74 else 75 m_Console.SendResult ("Access to requested preference is forbidden"); 65 76 } 66 foreach (string s in sortedList.Keys) { 67 m_Console.SendResult (sortedList [s]); 68 } 69 } else { 70 if (prefAccessAllowed (enumGamePrefs)) 71 m_Console.SendResult (string.Format ("{0} = {1}", enumGamePrefs, GamePrefs.GetObject (enumGamePrefs))); 72 else 73 m_Console.SendResult ("Access to requested preference is forbidden"); 77 } catch (Exception e) { 78 Log.Out ("Error in GetGamePrefs.Run: " + e); 74 79 } 75 } catch (Exception e) {76 Log.Out ("Error in GetGamePrefs.Run: " + e);77 80 } 78 81 } 79 82 } 80 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/GetTime.cs
r107 r130 1 1 using System; 2 2 3 public class GetTime : ConsoleCommand 3 namespace AllocsFixes.CustomCommands 4 4 { 5 public GetTime (ConsoleSdtd cons) : base(cons)5 public class GetTime : ConsoleCommand 6 6 { 7 } 7 public GetTime (ConsoleSdtd cons) : base(cons) 8 { 9 } 8 10 9 public override string Description ()10 {11 return "retrieves current ingame time";12 }11 public override string Description () 12 { 13 return "retrieves current ingame time"; 14 } 13 15 14 public override string[] Names ()15 {16 return new string[] { "gettime", "gt" };17 }16 public override string[] Names () 17 { 18 return new string[] { "gettime", "gt" }; 19 } 18 20 19 public override void Run (string[] _params) 20 { 21 try { 22 ulong time = this.m_Console.gameManager.World.gameTime; 23 int day = (int)(time / 24000) + 1; 24 int hour = (int)(time % 24000) / 1000 + 8; 25 if (hour > 23) { 26 day++; 27 hour -= 24; 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); 28 35 } 29 int min = (int)(time % 1000) * 60 / 1000;30 m_Console.SendResult (String.Format ("Day {0}, {1:00}:{2:00} ", day, hour, min));31 } catch (Exception e) {32 Log.Out ("Error in GetTime.Run: " + e);33 36 } 34 37 } 35 38 } 36 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/Give.cs
r128 r130 3 3 using UnityEngine; 4 4 5 public class Give : ConsoleCommand 5 namespace AllocsFixes.CustomCommands 6 6 { 7 public Give (ConsoleSdtd cons) : base(cons)7 public class Give : ConsoleCommand 8 8 { 9 } 9 public Give (ConsoleSdtd cons) : base(cons) 10 { 11 } 10 12 11 public override string Description ()12 {13 return "give an item to a player (entity id or name)";14 }13 public override string Description () 14 { 15 return "give an item to a player (entity id or name)"; 16 } 15 17 16 public override string[] Names ()17 {18 return new string[] { "give", string.Empty };19 }18 public override string[] Names () 19 { 20 return new string[] { "give", string.Empty }; 21 } 20 22 21 public override void Run (string[] _params) 22 { 23 try { 24 if (_params.Length != 3) { 25 m_Console.SendResult ("Usage: give <playername|entityid> <itemname> <amount>"); 26 return; 23 public override void Run (string[] _params) 24 { 25 try { 26 if (_params.Length != 3) { 27 m_Console.SendResult ("Usage: give <playername|entityid> <itemname> <amount>"); 28 return; 29 } 30 31 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromNameOrID (_params [0], false); 32 33 if (ci == null) { 34 m_Console.SendResult ("Playername or entity id not found."); 35 return; 36 } 37 38 ItemBase item = null; 39 40 foreach (ItemBase ib in ItemBase.list) { 41 if (ib.name != null && ib.name.ToLower ().Equals (_params [1].ToLower ())) { 42 item = ib; 43 break; 44 } 45 } 46 47 if (item == null) { 48 m_Console.SendResult ("Item not found."); 49 return; 50 } 51 52 int n = int.MinValue; 53 if (!int.TryParse (_params [2], out n) || n <= 0) { 54 m_Console.SendResult ("Amount is not an integer or not greater than zero."); 55 return; 56 } 57 58 EntityPlayer p = CommonMappingFunctions.GetEntityPlayer (ci); 59 CommonMappingFunctions.GetGameManager ().DropEntityItemServer (item.itemID, n, p.GetPosition (), Vector3.zero, Vector3.zero, 50, CommonMappingFunctions.GetEntityID (ci)); 60 61 m_Console.SendResult ("Dropped item"); 62 } catch (Exception e) { 63 Log.Out ("Error in Give.Run: " + e); 27 64 } 28 29 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromNameOrID (_params [0], false);30 31 if (ci == null) {32 m_Console.SendResult ("Playername or entity id not found.");33 return;34 }35 36 ItemBase item = null;37 38 foreach (ItemBase ib in ItemBase.list) {39 if (ib.name != null && ib.name.ToLower().Equals(_params[1].ToLower())) {40 item = ib;41 break;42 }43 }44 45 if (item == null) {46 m_Console.SendResult ("Item not found.");47 return;48 }49 50 int n = int.MinValue;51 if (!int.TryParse (_params [2], out n) || n <= 0) {52 m_Console.SendResult ("Amount is not an integer or not greater than zero.");53 return;54 }55 56 EntityPlayer p = CommonMappingFunctions.GetEntityPlayer (ci);57 CommonMappingFunctions.GetGameManager().DropEntityItemServer(item.itemID, n, p.GetPosition(), Vector3.zero, Vector3.zero, 50, CommonMappingFunctions.GetEntityID(ci));58 59 m_Console.SendResult ("Dropped item");60 } catch (Exception e) {61 Log.Out ("Error in Give.Run: " + e);62 65 } 63 66 } 64 67 } 65 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/Kill.cs
r117 r130 2 2 using System.Collections.Generic; 3 3 4 public class Kill : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public Kill (ConsoleSdtd cons) : base(cons)6 public class Kill : ConsoleCommand 7 7 { 8 } 8 public Kill (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "kill a given player (entity id or name)";13 }12 public override string Description () 13 { 14 return "kill a given player (entity id or name)"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "kill", string.Empty };18 }17 public override string[] Names () 18 { 19 return new string[] { "kill", string.Empty }; 20 } 19 21 20 public override void Run (string[] _params) 21 { 22 try { 23 if (_params.Length != 1) { 24 m_Console.SendResult ("Usage: kill <playername|entityid>"); 25 return; 22 public override void Run (string[] _params) 23 { 24 try { 25 if (_params.Length != 1) { 26 m_Console.SendResult ("Usage: kill <playername|entityid>"); 27 return; 28 } 29 30 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromNameOrID (_params [0], false); 31 32 if (ci == null) { 33 m_Console.SendResult ("Playername or entity id not found."); 34 return; 35 } 36 37 EntityPlayer p = CommonMappingFunctions.GetEntityPlayer (ci); 38 p.DamageEntity (new DamageSource (EnumDamageSourceType.Bullet), 9999); 39 m_Console.SendResult ("Killed player " + _params [0]); 40 } catch (Exception e) { 41 Log.Out ("Error in Kill.Run: " + e); 26 42 } 27 28 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromNameOrID (_params [0], false);29 30 if (ci == null) {31 m_Console.SendResult ("Playername or entity id not found.");32 return;33 }34 35 EntityPlayer p = CommonMappingFunctions.GetEntityPlayer (ci);36 p.DamageEntity(new DamageSource(EnumDamageSourceType.Bullet), 9999);37 m_Console.SendResult ("Killed player " + _params [0]);38 } catch (Exception e) {39 Log.Out ("Error in Kill.Run: " + e);40 43 } 41 44 } 42 45 } 43 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/ListItems.cs
r128 r130 2 2 using System.Collections.Generic; 3 3 4 public class ListItems : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public ListItems (ConsoleSdtd cons) : base(cons)6 public class ListItems : ConsoleCommand 7 7 { 8 } 8 public ListItems (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "lists all items that contain the given substring";13 }12 public override string Description () 13 { 14 return "lists all items that contain the given substring"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "listitems", "li" };18 }17 public override string[] Names () 18 { 19 return new string[] { "listitems", "li" }; 20 } 19 21 20 public override void Run (string[] _params) 21 { 22 try { 23 if (_params.Length != 1 || _params[0].Length == 0) { 24 m_Console.SendResult ("Usage: listitems <searchString>"); 25 return; 22 public override void Run (string[] _params) 23 { 24 try { 25 if (_params.Length != 1 || _params [0].Length == 0) { 26 m_Console.SendResult ("Usage: listitems <searchString>"); 27 return; 28 } 29 30 int n = 0; 31 foreach (ItemBase ib in ItemBase.list) { 32 if (ib.name != null && ib.name.ToLower ().Contains (_params [0].ToLower ())) { 33 m_Console.SendResult (" " + ib.name); 34 n++; 35 } 36 } 37 38 m_Console.SendResult ("Listed " + n + " matching items."); 39 } catch (Exception e) { 40 Log.Out ("Error in ListItems.Run: " + e); 26 41 } 27 28 int n = 0;29 foreach (ItemBase ib in ItemBase.list) {30 if (ib.name != null && ib.name.ToLower().Contains(_params[0].ToLower())) {31 m_Console.SendResult (" " + ib.name);32 n++;33 }34 }35 36 m_Console.SendResult ("Listed " + n + " matching items.");37 } catch (Exception e) {38 Log.Out ("Error in ListItems.Run: " + e);39 42 } 40 43 } 41 44 } 42 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/ListLandProtection.cs
r113 r130 2 2 using System.Collections.Generic; 3 3 4 public class ListLandProtection : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public ListLandProtection (ConsoleSdtd cons) : base(cons)6 public class ListLandProtection : ConsoleCommand 7 7 { 8 } 8 public ListLandProtection (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "lists all land protection blocks and owners";13 }12 public override string Description () 13 { 14 return "lists all land protection blocks and owners"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "listlandprotection", "llp" };18 }17 public override string[] Names () 18 { 19 return new string[] { "listlandprotection", "llp" }; 20 } 19 21 20 public override void Run (string[] _params)21 {22 try {23 World w = CommonMappingFunctions.GetGameManager ().World;24 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager().GetPersistentPlayerList();22 public override void Run (string[] _params) 23 { 24 try { 25 World w = CommonMappingFunctions.GetGameManager ().World; 26 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList (); 25 27 26 Dictionary<Vector3i, PersistentPlayerData> d = ppl.positionToLPBlockOwner; 27 if (d != null) { 28 Dictionary<PersistentPlayerData, List<Vector3i>> owners = new Dictionary<PersistentPlayerData, List<Vector3i>>(); 29 foreach (KeyValuePair<Vector3i, PersistentPlayerData> kvp in d) { 30 if (!owners.ContainsKey(kvp.Value)) { 31 owners.Add(kvp.Value, new List<Vector3i>()); 28 Dictionary<Vector3i, PersistentPlayerData> d = ppl.positionToLPBlockOwner; 29 if (d != null) { 30 Dictionary<PersistentPlayerData, List<Vector3i>> owners = new Dictionary<PersistentPlayerData, List<Vector3i>> (); 31 foreach (KeyValuePair<Vector3i, PersistentPlayerData> kvp in d) { 32 if (!owners.ContainsKey (kvp.Value)) { 33 owners.Add (kvp.Value, new List<Vector3i> ()); 34 } 35 owners [kvp.Value].Add (kvp.Key); 32 36 } 33 owners[kvp.Value].Add(kvp.Key); 37 38 foreach (KeyValuePair<PersistentPlayerData, List<Vector3i>> kvp in owners) { 39 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromEntityID (kvp.Key.EntityId); 40 string name = string.Empty; 41 if (ci != null) { 42 name = CommonMappingFunctions.GetPlayerName (ci); 43 } 44 name += " (" + kvp.Key.PlayerId + ")"; 45 46 m_Console.SendResult (String.Format ("Player \"{0}\" (protected: {1}, current hardness multiplier: {2}):", name, w.LandClaimIsActive (kvp.Key), w.LandClaimPower (kvp.Key))); 47 foreach (Vector3i v in kvp.Value) { 48 m_Console.SendResult (" (" + v.ToString () + ")"); 49 } 50 } 34 51 } 35 52 36 foreach (KeyValuePair<PersistentPlayerData, List<Vector3i>> kvp in owners) { 37 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromEntityID(kvp.Key.EntityId); 38 string name = string.Empty; 39 if (ci != null) { 40 name = CommonMappingFunctions.GetPlayerName(ci); 41 } 42 name += " (" + kvp.Key.PlayerId + ")"; 43 44 m_Console.SendResult (String.Format("Player \"{0}\" (protected: {1}, current hardness multiplier: {2}):", name, w.LandClaimIsActive(kvp.Key), w.LandClaimPower(kvp.Key))); 45 foreach (Vector3i v in kvp.Value) { 46 m_Console.SendResult(" (" + v.ToString() + ")"); 47 } 48 } 53 m_Console.SendResult ("Total of " + d.Count + " keystones in the game"); 54 } catch (Exception e) { 55 Log.Out ("Error in ListLandProtection.Run: " + e); 49 56 } 50 51 m_Console.SendResult ("Total of " + d.Count + " keystones in the game");52 } catch (Exception e) {53 Log.Out ("Error in ListLandProtection.Run: " + e);54 57 } 55 58 } -
binary-improvements/7dtd-server-fixes/src/CustomCommands/ListPlayersExtended.cs
r117 r130 2 2 using System.Collections.Generic; 3 3 4 public class ListPlayersExtended : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public ListPlayersExtended (ConsoleSdtd cons) : base(cons)6 public class ListPlayersExtended : ConsoleCommand 7 7 { 8 } 8 public ListPlayersExtended (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "lists all players with extended attributes";13 }12 public override string Description () 13 { 14 return "lists all players with extended attributes"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "listplayersextended", "lpe" };18 }17 public override string[] Names () 18 { 19 return new string[] { "listplayersextended", "lpe" }; 20 } 19 21 20 public override void Run (string[] _params)21 {22 try {23 World w = CommonMappingFunctions.GetGameManager ().World;24 int num = 0;25 foreach (KeyValuePair<int, EntityPlayer> current in w.playerEntities.dict) {26 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromEntityID (current.Key);27 string ip = string.Empty;28 if (ci != null) {29 ip = ci.networkPlayer.ipAddress;30 }31 m_Console.SendResult (string.Concat (new object[]22 public override void Run (string[] _params) 23 { 24 try { 25 World w = CommonMappingFunctions.GetGameManager ().World; 26 int num = 0; 27 foreach (KeyValuePair<int, EntityPlayer> current in w.playerEntities.dict) { 28 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromEntityID (current.Key); 29 string ip = string.Empty; 30 if (ci != null) { 31 ip = ci.networkPlayer.ipAddress; 32 } 33 m_Console.SendResult (string.Concat (new object[] 32 34 { 33 35 string.Empty, … … 60 62 current.Value.pingToServer 61 63 } 62 ) 63 ); 64 ) 65 ); 66 } 67 m_Console.SendResult ("Total of " + w.playerEntities.list.Count + " in the game"); 68 } catch (Exception e) { 69 Log.Out ("Error in ListPlayersExtended.Run: " + e); 64 70 } 65 m_Console.SendResult ("Total of " + w.playerEntities.list.Count + " in the game");66 } catch (Exception e) {67 Log.Out ("Error in ListPlayersExtended.Run: " + e);68 71 } 69 72 } 70 73 } 71 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/PrivateMassageConnections.cs
r112 r130 2 2 using System.Collections.Generic; 3 3 4 public class PrivateMassageConnections4 namespace AllocsFixes.CustomCommands 5 5 { 6 private static Dictionary<ClientInfo, ClientInfo> senderOfLastPM = new Dictionary<ClientInfo, ClientInfo>(); 6 public class PrivateMassageConnections 7 { 8 private static Dictionary<ClientInfo, ClientInfo> senderOfLastPM = new Dictionary<ClientInfo, ClientInfo> (); 7 9 8 public static void SetLastPMSender(ClientInfo _sender, ClientInfo _receiver) { 9 if (senderOfLastPM.ContainsKey(_receiver)) 10 senderOfLastPM[_receiver] = _sender; 11 else 12 senderOfLastPM.Add(_receiver, _sender); 13 } 10 public static void SetLastPMSender (ClientInfo _sender, ClientInfo _receiver) 11 { 12 if (senderOfLastPM.ContainsKey (_receiver)) 13 senderOfLastPM [_receiver] = _sender; 14 else 15 senderOfLastPM.Add (_receiver, _sender); 16 } 14 17 15 public static ClientInfo GetLastPMSenderForPlayer(ClientInfo _player) { 16 if (senderOfLastPM.ContainsKey(_player)) 17 return senderOfLastPM[_player]; 18 return null; 18 public static ClientInfo GetLastPMSenderForPlayer (ClientInfo _player) 19 { 20 if (senderOfLastPM.ContainsKey (_player)) 21 return senderOfLastPM [_player]; 22 return null; 23 } 19 24 } 20 25 } 21 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/RemoveLandProtection.cs
r123 r130 2 2 using System.Collections.Generic; 3 3 4 public class RemoveLandProtection : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public RemoveLandProtection (ConsoleSdtd cons) : base(cons)6 public class RemoveLandProtection : ConsoleCommand 7 7 { 8 } 8 public RemoveLandProtection (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "removes the association of a land protection block to the owner";13 }12 public override string Description () 13 { 14 return "removes the association of a land protection block to the owner"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "removelandprotection", "rlp" };18 }17 public override string[] Names () 18 { 19 return new string[] { "removelandprotection", "rlp" }; 20 } 19 21 20 private void removeById (string _id)21 {22 try {23 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList ();22 private void removeById (string _id) 23 { 24 try { 25 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList (); 24 26 25 if (_id.Length < 1 || !ppl.Players.ContainsKey(_id)) { 26 m_Console.SendResult ("Not a valid Steam ID or user has never logged on. Use \"listlandprotection\" to get a list of keystones."); 27 return; 27 if (_id.Length < 1 || !ppl.Players.ContainsKey (_id)) { 28 m_Console.SendResult ("Not a valid Steam ID or user has never logged on. Use \"listlandprotection\" to get a list of keystones."); 29 return; 30 } 31 if (ppl.Players [_id].LPBlocks == null || ppl.Players [_id].LPBlocks.Count == 0) { 32 m_Console.SendResult ("Player does not own any keystones. Use \"listlandprotection\" to get a list of keystones."); 33 return; 34 } 35 36 List<BlockChangeInfo> changes = new List<BlockChangeInfo> (); 37 foreach (Vector3i pos in ppl.Players[_id].LPBlocks) { 38 BlockChangeInfo bci = new BlockChangeInfo (pos, 0, true); 39 changes.Add (bci); 40 } 41 CommonMappingFunctions.GetGameManager ().SetBlocksRPC (changes); 42 43 m_Console.SendResult ("#" + changes.Count + " Land protection blocks for player \"" + _id + "\" removed"); 44 } catch (Exception e) { 45 Log.Out ("Error in RemoveLandProtection.removeById: " + e); 28 46 } 29 if (ppl.Players[_id].LPBlocks == null || ppl.Players[_id].LPBlocks.Count == 0) { 30 m_Console.SendResult ("Player does not own any keystones. Use \"listlandprotection\" to get a list of keystones."); 31 return; 47 } 48 49 private void removeByPosition (string[] _coords) 50 { 51 try { 52 int x = int.MinValue; 53 int.TryParse (_coords [0], out x); 54 int y = int.MinValue; 55 int.TryParse (_coords [1], out y); 56 int z = int.MinValue; 57 int.TryParse (_coords [2], out z); 58 59 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { 60 m_Console.SendResult ("At least one of the given coordinates is not a valid integer"); 61 return; 62 } 63 64 Vector3i v = new Vector3i (x, y, z); 65 66 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList (); 67 68 Dictionary<Vector3i, PersistentPlayerData> d = ppl.positionToLPBlockOwner; 69 if (d == null || !d.ContainsKey (v)) { 70 m_Console.SendResult ("No land protection block at the given position or not a valid position. Use \"listlandprotection\" to get a list of keystones."); 71 return; 72 } 73 74 BlockChangeInfo bci = new BlockChangeInfo (v, 0, true); 75 76 List<BlockChangeInfo> changes = new List<BlockChangeInfo> (); 77 changes.Add (bci); 78 79 CommonMappingFunctions.GetGameManager ().SetBlocksRPC (changes); 80 81 m_Console.SendResult ("Land protection block at (" + v.ToString () + ") removed"); 82 } catch (Exception e) { 83 Log.Out ("Error in RemoveLandProtection.removeByPosition: " + e); 32 84 } 85 } 33 86 34 List<BlockChangeInfo> changes = new List<BlockChangeInfo> (); 35 foreach (Vector3i pos in ppl.Players[_id].LPBlocks) { 36 BlockChangeInfo bci = new BlockChangeInfo (pos, 0, true); 37 changes.Add (bci); 87 public override void Run (string[] _params) 88 { 89 try { 90 if (_params.Length == 1) { 91 removeById (_params [0]); 92 } else if (_params.Length == 3) { 93 removeByPosition (_params); 94 } else { 95 m_Console.SendResult ("Usage: removelandprotection <x> <y> <z> OR removelandprotection <steamid>"); 96 } 97 } catch (Exception e) { 98 Log.Out ("Error in RemoveLandProtection.Run: " + e); 38 99 } 39 CommonMappingFunctions.GetGameManager ().SetBlocksRPC (changes);40 41 m_Console.SendResult ("#"+changes.Count + " Land protection blocks for player \"" + _id + "\" removed");42 } catch (Exception e) {43 Log.Out ("Error in RemoveLandProtection.removeById: " + e);44 }45 }46 47 private void removeByPosition (string[] _coords)48 {49 try {50 int x = int.MinValue;51 int.TryParse (_coords [0], out x);52 int y = int.MinValue;53 int.TryParse (_coords [1], out y);54 int z = int.MinValue;55 int.TryParse (_coords [2], out z);56 57 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) {58 m_Console.SendResult ("At least one of the given coordinates is not a valid integer");59 return;60 }61 62 Vector3i v = new Vector3i (x, y, z);63 64 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList ();65 66 Dictionary<Vector3i, PersistentPlayerData> d = ppl.positionToLPBlockOwner;67 if (d == null || !d.ContainsKey (v)) {68 m_Console.SendResult ("No land protection block at the given position or not a valid position. Use \"listlandprotection\" to get a list of keystones.");69 return;70 }71 72 BlockChangeInfo bci = new BlockChangeInfo (v, 0, true);73 74 List<BlockChangeInfo> changes = new List<BlockChangeInfo> ();75 changes.Add (bci);76 77 CommonMappingFunctions.GetGameManager ().SetBlocksRPC (changes);78 79 m_Console.SendResult ("Land protection block at (" + v.ToString () + ") removed");80 } catch (Exception e) {81 Log.Out ("Error in RemoveLandProtection.removeByPosition: " + e);82 }83 }84 85 public override void Run (string[] _params)86 {87 try {88 if (_params.Length == 1) {89 removeById (_params [0]);90 } else if (_params.Length == 3) {91 removeByPosition (_params);92 } else {93 m_Console.SendResult ("Usage: removelandprotection <x> <y> <z> OR removelandprotection <steamid>");94 }95 } catch (Exception e) {96 Log.Out ("Error in RemoveLandProtection.Run: " + e);97 100 } 98 101 } -
binary-improvements/7dtd-server-fixes/src/CustomCommands/Reply.cs
r112 r130 2 2 using System.Collections.Generic; 3 3 4 public class Reply : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public Reply (ConsoleSdtd cons) : base(cons)6 public class Reply : ConsoleCommand 7 7 { 8 } 8 public Reply (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "send a message to the player who last sent you a PM";13 }12 public override string Description () 13 { 14 return "send a message to the player who last sent you a PM"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "reply", "re" };18 }17 public override string[] Names () 18 { 19 return new string[] { "reply", "re" }; 20 } 19 21 20 private void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message)21 {22 PrivateMassageConnections.SetLastPMSender (_sender, _receiver);23 string senderName = CommonMappingFunctions.GetPlayerName (_sender);22 private void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message) 23 { 24 PrivateMassageConnections.SetLastPMSender (_sender, _receiver); 25 string senderName = CommonMappingFunctions.GetPlayerName (_sender); 24 26 25 CommonMappingFunctions.GetConnectionManager ().networkView.RPC ("RPC_ChatMessage", _receiver.networkPlayer,27 CommonMappingFunctions.GetConnectionManager ().networkView.RPC ("RPC_ChatMessage", _receiver.networkPlayer, 26 28 new object[] { 27 29 _message, … … 30 32 true 31 33 } 32 ); 33 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 34 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 35 } 36 37 private void RunInternal (ClientInfo _sender, string[] _params) 38 { 39 if (_params.Length < 1) { 40 m_Console.SendResult ("Usage: reply <message>"); 41 return; 34 ); 35 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 36 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 42 37 } 43 38 44 string message = _params [0]; 45 for (int i = 1; i < _params.Length; i++) { 46 message += " " + _params [i]; 39 private void RunInternal (ClientInfo _sender, string[] _params) 40 { 41 if (_params.Length < 1) { 42 m_Console.SendResult ("Usage: reply <message>"); 43 return; 44 } 45 46 string message = _params [0]; 47 for (int i = 1; i < _params.Length; i++) { 48 message += " " + _params [i]; 49 } 50 51 ClientInfo receiver = PrivateMassageConnections.GetLastPMSenderForPlayer (_sender); 52 if (receiver != null && CommonMappingFunctions.GetClientID (receiver) >= 0) { 53 SendMessage (receiver, _sender, message); 54 } else { 55 if (receiver != null) { 56 m_Console.SendResult ("The sender of the PM you last received is currently not online."); 57 } else { 58 m_Console.SendResult ("You have not received a PM so far."); 59 } 60 } 47 61 } 48 62 49 ClientInfo receiver = PrivateMassageConnections.GetLastPMSenderForPlayer (_sender);50 if (receiver != null && CommonMappingFunctions.GetClientID (receiver) >= 0){51 SendMessage (receiver, _sender, message);52 } else {53 if (receiver != null) {54 m_Console.SendResult ("The sender of the PM you last received is currently not online.");55 } else{56 m_Console.SendResult ("You have not received a PM so far.");63 public override void ExecuteRemote (string _sender, string[] _params) 64 { 65 try { 66 m_Console.SendResult (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 67 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 68 RunInternal (ci, _params); 69 } catch (Exception e) { 70 Log.Out ("Error in Reply.ExecuteRemote: " + e); 57 71 } 58 72 } 59 }60 73 61 public override void ExecuteRemote (string _sender, string[] _params) 62 { 63 try { 64 m_Console.SendResult (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 65 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 66 RunInternal (ci, _params); 67 } catch (Exception e) { 68 Log.Out ("Error in Reply.ExecuteRemote: " + e); 74 public override void Run (string[] _params) 75 { 76 Log.Out ("Command \"reply\" can only be used on clients!"); 69 77 } 70 78 } 71 72 public override void Run (string[] _params)73 {74 Log.Out ("Command \"reply\" can only be used on clients!");75 }76 79 } 77 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/SayToPlayer.cs
r111 r130 2 2 using System.Collections.Generic; 3 3 4 public class SayToPlayer : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public SayToPlayer (ConsoleSdtd cons) : base(cons)6 public class SayToPlayer : ConsoleCommand 7 7 { 8 } 8 public SayToPlayer (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "send a message to a single player";13 }12 public override string Description () 13 { 14 return "send a message to a single player"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "sayplayer", "pm" };18 }17 public override string[] Names () 18 { 19 return new string[] { "sayplayer", "pm" }; 20 } 19 21 20 private void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message)21 {22 string senderName;23 if (_sender != null) {24 PrivateMassageConnections.SetLastPMSender(_sender, _receiver);25 senderName = CommonMappingFunctions.GetPlayerName (_sender);26 } else {27 senderName = "Server";28 }29 CommonMappingFunctions.GetConnectionManager ().networkView.RPC ("RPC_ChatMessage", _receiver.networkPlayer,22 private void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message) 23 { 24 string senderName; 25 if (_sender != null) { 26 PrivateMassageConnections.SetLastPMSender (_sender, _receiver); 27 senderName = CommonMappingFunctions.GetPlayerName (_sender); 28 } else { 29 senderName = "Server"; 30 } 31 CommonMappingFunctions.GetConnectionManager ().networkView.RPC ("RPC_ChatMessage", _receiver.networkPlayer, 30 32 new object[] { 31 33 _message, … … 34 36 true 35 37 } 36 ); 37 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 38 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 39 } 40 41 private void RunInternal (ClientInfo _sender, string[] _params) 42 { 43 if (_params.Length < 2) { 44 m_Console.SendResult ("Usage: sayplayer <playername|entityid> <message>"); 45 return; 38 ); 39 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 40 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 46 41 } 47 42 48 string message = _params [1]; 49 for (int i = 2; i < _params.Length; i++) { 50 message += " " + _params [i]; 43 private void RunInternal (ClientInfo _sender, string[] _params) 44 { 45 if (_params.Length < 2) { 46 m_Console.SendResult ("Usage: sayplayer <playername|entityid> <message>"); 47 return; 48 } 49 50 string message = _params [1]; 51 for (int i = 2; i < _params.Length; i++) { 52 message += " " + _params [i]; 53 } 54 55 ClientInfo receiver = CommonMappingFunctions.GetClientInfoFromNameOrID (_params [0], true); 56 if (receiver != null) { 57 SendMessage (receiver, _sender, message); 58 } else { 59 m_Console.SendResult ("Playername or entity ID not found."); 60 } 51 61 } 52 62 53 ClientInfo receiver = CommonMappingFunctions.GetClientInfoFromNameOrID (_params [0], true); 54 if (receiver != null) { 55 SendMessage (receiver, _sender, message); 56 } else { 57 m_Console.SendResult ("Playername or entity ID not found."); 63 public override void ExecuteRemote (string _sender, string[] _params) 64 { 65 try { 66 this.m_Console.SendResult (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 67 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 68 RunInternal (ci, _params); 69 } catch (Exception e) { 70 Log.Out ("Error in SayToPlayer.ExecuteRemote: " + e); 71 } 58 72 } 59 }60 73 61 public override void ExecuteRemote (string _sender, string[] _params) 62 { 63 try { 64 this.m_Console.SendResult (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 65 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 66 RunInternal (ci, _params); 67 } catch (Exception e) { 68 Log.Out ("Error in SayToPlayer.ExecuteRemote: " + e); 69 } 70 } 71 72 public override void Run (string[] _params) 73 { 74 try { 75 RunInternal (null, _params); 76 } catch (Exception e) { 77 Log.Out ("Error in SayToPlayer.Run: " + e); 74 public override void Run (string[] _params) 75 { 76 try { 77 RunInternal (null, _params); 78 } catch (Exception e) { 79 Log.Out ("Error in SayToPlayer.Run: " + e); 80 } 78 81 } 79 82 } 80 83 } 81 -
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 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/ShowInventory.cs
r107 r130 2 2 using System.Collections.Generic; 3 3 4 public class ShowInventory : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 private GameManager manager; 6 public class ShowInventory : ConsoleCommand 7 { 8 private GameManager manager; 7 9 8 public ShowInventory (ConsoleSdtd cons) : base(cons)9 {10 manager = m_Console.gameManager;11 }10 public ShowInventory (ConsoleSdtd cons) : base(cons) 11 { 12 manager = m_Console.gameManager; 13 } 12 14 13 public override string Description ()14 {15 return "list inventory of a given player (entity id or name)";16 }15 public override string Description () 16 { 17 return "list inventory of a given player (entity id or name)"; 18 } 17 19 18 public override string[] Names ()19 {20 return new string[] { "showinventory", "si" };21 }20 public override string[] Names () 21 { 22 return new string[] { "showinventory", "si" }; 23 } 22 24 23 public override void Run (string[] _params)24 {25 try {26 if (_params.Length < 1) {27 m_Console.SendResult ("Usage: showinventory <playername|entityid>");28 return;29 }25 public override void Run (string[] _params) 26 { 27 try { 28 if (_params.Length < 1) { 29 m_Console.SendResult ("Usage: showinventory <playername|entityid>"); 30 return; 31 } 30 32 31 int entityId = -1;32 PlayerDataStuff.PlayerItems items = null;33 if (int.TryParse (_params [0], out entityId)) {34 items = PlayerDataStuff.GetPlayerItems (entityId);35 }33 int entityId = -1; 34 PlayerDataStuff.PlayerItems items = null; 35 if (int.TryParse (_params [0], out entityId)) { 36 items = PlayerDataStuff.GetPlayerItems (entityId); 37 } 36 38 37 if (items == null) { 38 string playerName = _params [0].ToLower (); 39 foreach (KeyValuePair<int, EntityPlayer> kvp in manager.World.playerEntities.dict) { 40 if (kvp.Value.EntityName.ToLower ().Equals (playerName)) { 41 entityId = kvp.Key; 42 break; 39 if (items == null) { 40 string playerName = _params [0].ToLower (); 41 foreach (KeyValuePair<int, EntityPlayer> kvp in manager.World.playerEntities.dict) { 42 if (kvp.Value.EntityName.ToLower ().Equals (playerName)) { 43 entityId = kvp.Key; 44 break; 45 } 43 46 } 44 47 } 48 items = PlayerDataStuff.GetPlayerItems (entityId); 49 50 if (items == null) { 51 m_Console.SendResult ("Playername or entity id not found or no inventory saved (first saved after a player has been online for 30s)."); 52 return; 53 } 54 55 m_Console.SendResult ("Belt of player:"); 56 foreach (KeyValuePair<string, int> kvp in items.belt) { 57 m_Console.SendResult (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key)); 58 } 59 m_Console.SendResult (string.Empty); 60 m_Console.SendResult ("Bagpack of player:"); 61 foreach (KeyValuePair<string, int> kvp in items.bag) { 62 m_Console.SendResult (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key)); 63 } 64 m_Console.SendResult (string.Empty); 65 } catch (Exception e) { 66 Log.Out ("Error in ShowInventory.Run: " + e); 45 67 } 46 items = PlayerDataStuff.GetPlayerItems (entityId);47 48 if (items == null) {49 m_Console.SendResult ("Playername or entity id not found or no inventory saved (first saved after a player has been online for 30s).");50 return;51 }52 53 m_Console.SendResult ("Belt of player:");54 foreach (KeyValuePair<string, int> kvp in items.belt) {55 m_Console.SendResult (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key));56 }57 m_Console.SendResult (string.Empty);58 m_Console.SendResult ("Bagpack of player:");59 foreach (KeyValuePair<string, int> kvp in items.bag) {60 m_Console.SendResult (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key));61 }62 m_Console.SendResult (string.Empty);63 } catch (Exception e) {64 Log.Out ("Error in ShowInventory.Run: " + e);65 68 } 66 69 } 67 70 } 68 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/Version.cs
r114 r130 3 3 using System.Reflection; 4 4 5 public class Version : ConsoleCommand 5 namespace AllocsFixes.CustomCommands 6 6 { 7 public Version (ConsoleSdtd cons) : base(cons)7 public class Version : ConsoleCommand 8 8 { 9 } 9 public Version (ConsoleSdtd cons) : base(cons) 10 { 11 } 10 12 11 public override string Description ()12 {13 return "get the currently running version of the server fixes";14 }13 public override string Description () 14 { 15 return "get the currently running version of the server fixes"; 16 } 15 17 16 public override string[] Names ()17 {18 return new string[] { "version", string.Empty };19 }18 public override string[] Names () 19 { 20 return new string[] { "version", string.Empty }; 21 } 20 22 21 public override void Run (string[] _params) 22 { 23 try { 24 m_Console.SendResult ("Server fixes version: " + Assembly.GetExecutingAssembly ().GetName ().Version); 25 } catch (Exception e) { 26 Log.Out ("Error in Version.Run: " + e); 23 public override void Run (string[] _params) 24 { 25 try { 26 m_Console.SendResult ("Server fixes version: " + Assembly.GetExecutingAssembly ().GetName ().Version); 27 } catch (Exception e) { 28 Log.Out ("Error in Version.Run: " + e); 29 } 27 30 } 28 31 } 29 32 } 30
Note:
See TracChangeset
for help on using the changeset viewer.