Changeset 325 for binary-improvements/AllocsCommands
- Timestamp:
- Sep 4, 2018, 1:00:48 PM (6 years ago)
- Location:
- binary-improvements/AllocsCommands
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/AssemblyInfo.cs
r232 r325 1 1 using System.Reflection; 2 using System.Runtime.CompilerServices;3 2 4 3 // Information about this assembly is defined by the following attributes. 5 4 // Change them to the values specific to your project. 6 5 7 [assembly: AssemblyTitle ("AllocsCommands")]8 [assembly: AssemblyDescription ("")]9 [assembly: AssemblyConfiguration ("")]10 [assembly: AssemblyCompany ("")]11 [assembly: AssemblyProduct ("")]12 [assembly: AssemblyCopyright ("ci")]13 [assembly: AssemblyTrademark ("")]14 [assembly: AssemblyCulture ("")]6 [assembly: AssemblyTitle ("AllocsCommands")] 7 [assembly: AssemblyDescription ("")] 8 [assembly: AssemblyConfiguration ("")] 9 [assembly: AssemblyCompany ("")] 10 [assembly: AssemblyProduct ("")] 11 [assembly: AssemblyCopyright ("ci")] 12 [assembly: AssemblyTrademark ("")] 13 [assembly: AssemblyCulture ("")] 15 14 16 15 // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". … … 18 17 // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 18 20 [assembly: AssemblyVersion ("0.0.0.0")]19 [assembly: AssemblyVersion ("0.0.0.0")] 21 20 22 21 // The following attributes are used to specify the signing key for the assembly, … … 25 24 //[assembly: AssemblyDelaySign(false)] 26 25 //[assembly: AssemblyKeyFile("")] 27 -
binary-improvements/AllocsCommands/Chat.cs
r267 r325 1 using System; 2 3 namespace AllocsFixes.CustomCommands 4 { 1 namespace AllocsFixes.CustomCommands { 5 2 public class Chat { 6 7 3 public static void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message) { 8 4 string senderName; … … 13 9 senderName = "Server"; 14 10 } 15 _receiver.SendPackage (new NetPackageGameMessage (EnumGameMessages.Chat, _message, senderName + " (PM)", false, "", false)); 11 12 _receiver.SendPackage (new NetPackageGameMessage (EnumGameMessages.Chat, _message, senderName + " (PM)", 13 false, "", false)); 16 14 string receiverName = _receiver.playerName; 17 SdtdConsole.Instance.Output ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 15 SdtdConsole.Instance.Output ("Message to player " + 16 (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + 17 " sent with sender \"" + senderName + "\""); 18 18 } 19 20 21 19 } 22 20 } 23 -
binary-improvements/AllocsCommands/Commands/Give.cs
r324 r325 3 3 using UnityEngine; 4 4 5 namespace AllocsFixes.CustomCommands 6 { 5 namespace AllocsFixes.CustomCommands { 7 6 public class Give : ConsoleCmdAbstract { 8 7 public override string GetDescription () { … … 12 11 public override string GetHelp () { 13 12 return "Give an item to a player by dropping it in front of that player\n" + 14 15 16 17 18 19 20 13 "Usage:\n" + 14 " give <name / entity id> <item name> <amount>\n" + 15 " give <name / entity id> <item name> <amount> <quality>\n" + 16 "Either pass the full name of a player or his entity id (given by e.g. \"lpi\").\n" + 17 "Item name has to be the exact name of an item as listed by \"listitems\".\n" + 18 "Amount is the number of instances of this item to drop (as a single stack).\n" + 19 "Quality is the quality of the dropped items for items that have a quality."; 21 20 } 22 21 23 22 public override string[] GetCommands () { 24 return new string[] { "give", string.Empty};23 return new[] {"give", string.Empty}; 25 24 } 26 25 … … 28 27 try { 29 28 if (_params.Count != 3 && _params.Count != 4) { 30 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 3 or 4, found " + _params.Count + "."); 29 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 3 or 4, found " + _params.Count + 30 "."); 31 31 return; 32 32 } … … 56 56 57 57 if (_params.Count == 4) { 58 if (!int.TryParse(_params [1], out quality) || quality <= 0) {58 if (!int.TryParse (_params [1], out quality) || quality <= 0) { 59 59 SdtdConsole.Instance.Output ("Quality is not an integer or not greater than zero."); 60 60 return; … … 64 64 if (ItemClass.list [iv.type].HasSubItems) { 65 65 for (int i = 0; i < iv.Modifications.Length; i++) { 66 ItemValue tmp = iv.Modifications [i];66 ItemValue tmp = iv.Modifications [i]; 67 67 tmp.Quality = quality; 68 iv.Modifications [i] = tmp;68 iv.Modifications [i] = tmp; 69 69 } 70 70 } else if (ItemClass.list [iv.type].HasQuality) { -
binary-improvements/AllocsCommands/Commands/ListItems.cs
r306 r325 2 2 using System.Collections.Generic; 3 3 4 namespace AllocsFixes.CustomCommands 5 { 6 public class ListItems : ConsoleCmdAbstract 7 { 8 public override string GetDescription () 9 { 4 namespace AllocsFixes.CustomCommands { 5 public class ListItems : ConsoleCmdAbstract { 6 public override string GetDescription () { 10 7 return "lists all items that contain the given substring"; 11 8 } 12 9 13 public override string[] GetCommands () 14 { 15 return new string[] { "listitems", "li" }; 10 public override string[] GetCommands () { 11 return new[] {"listitems", "li"}; 16 12 } 17 13 18 14 public override string GetHelp () { 19 15 return "List all available item names\n" + 20 21 22 23 24 16 "Usage:\n" + 17 " 1. listitems <searchString>\n" + 18 " 2. listitems *\n" + 19 "1. List only names that contain the given string.\n" + 20 "2. List all names."; 25 21 } 26 22 27 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 28 { 23 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 29 24 try { 30 25 if (_params.Count != 1 || _params [0].Length == 0) { … … 34 29 35 30 int count = ItemClass.ItemNames.Count; 36 bool showAll = _params [0].Trim().Equals("*");31 bool showAll = _params [0].Trim ().Equals ("*"); 37 32 38 33 int listed = 0; -
binary-improvements/AllocsCommands/Commands/ListKnownPlayers.cs
r284 r325 1 using AllocsFixes.PersistentData;2 1 using System; 3 2 using System.Collections.Generic; 3 using AllocsFixes.PersistentData; 4 4 5 namespace AllocsFixes.CustomCommands 6 { 7 public class ListKnownPlayers : ConsoleCmdAbstract 8 { 9 public override string GetDescription () 10 { 5 namespace AllocsFixes.CustomCommands { 6 public class ListKnownPlayers : ConsoleCmdAbstract { 7 public override string GetDescription () { 11 8 return "lists all players that were ever online"; 12 9 } … … 14 11 public override string GetHelp () { 15 12 return "Usage:\n" + 16 17 18 19 20 21 22 23 13 " 1. listknownplayers\n" + 14 " 2. listknownplayers -online\n" + 15 " 3. listknownplayers -notbanned\n" + 16 " 4. listknownplayers <player name / steamid>\n" + 17 "1. Lists all players that have ever been online\n" + 18 "2. Lists only the players that are currently online\n" + 19 "3. Lists only the players that are not banned\n" + 20 "4. Lists all players whose name contains the given string or matches the given SteamID"; 24 21 } 25 22 26 public override string[] GetCommands () 27 { 28 return new string[] { "listknownplayers", "lkp" }; 23 public override string[] GetCommands () { 24 return new[] {"listknownplayers", "lkp"}; 29 25 } 30 26 31 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 32 { 27 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 33 28 try { 34 29 AdminTools admTools = GameManager.Instance.adminTools; … … 56 51 57 52 if (p != null) { 58 SdtdConsole.Instance.Output (String.Format ("{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}", 53 SdtdConsole.Instance.Output (string.Format ( 54 "{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}", 59 55 0, p.Name, p.EntityID, nameFilter, p.IsOnline, p.IP, 60 56 p.TotalPlayTime / 60, … … 62 58 ); 63 59 } else { 64 SdtdConsole.Instance.Output ( String.Format ("SteamID {0} unknown!", nameFilter));60 SdtdConsole.Instance.Output (string.Format ("SteamID {0} unknown!", nameFilter)); 65 61 } 66 62 } else { … … 74 70 && (nameFilter.Length == 0 || p.Name.ToLower ().Contains (nameFilter)) 75 71 ) { 76 SdtdConsole.Instance.Output (String.Format ("{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}", 77 ++num, p.Name, p.EntityID, sid, p.IsOnline, p.IP, 78 p.TotalPlayTime / 60, 79 p.LastOnline.ToString ("yyyy-MM-dd HH:mm")) 72 SdtdConsole.Instance.Output (string.Format ( 73 "{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}", 74 ++num, p.Name, p.EntityID, sid, p.IsOnline, p.IP, 75 p.TotalPlayTime / 60, 76 p.LastOnline.ToString ("yyyy-MM-dd HH:mm")) 80 77 ); 81 78 } 82 79 } 80 83 81 SdtdConsole.Instance.Output ("Total of " + PersistentContainer.Instance.Players.Count + " known"); 84 82 } -
binary-improvements/AllocsCommands/Commands/ListLandProtection.cs
r273 r325 1 1 using System; 2 2 using System.Collections.Generic; 3 using AllocsFixes.PersistentData; 3 4 4 namespace AllocsFixes.CustomCommands 5 { 6 public class ListLandProtection : ConsoleCmdAbstract 7 { 8 public override string GetDescription () 9 { 5 namespace AllocsFixes.CustomCommands { 6 public class ListLandProtection : ConsoleCmdAbstract { 7 public override string GetDescription () { 10 8 return "lists all land protection blocks and owners"; 11 9 } … … 13 11 public override string GetHelp () { 14 12 return "Usage:\n" + 15 " 1. listlandprotection summary\n" +16 " 2. listlandprotection <steam id / player name / entity id> [parseable]\n" +17 " 3. listlandprotection nearby [length]\n" +18 "1. Lists only players that own claimstones, the number they own and the protection status\n" +19 "2. Lists only the claims of the player given by his SteamID / entity id / playername, including the individual claim positions.\n" +20 " If \"parseable\" is specified the output of the individual claims will be in a format better suited for programmatical readout.\n" +21 "3. Lists claims in a square with edge length of 64 (or the optionally specified size) around the executing player\n";13 " 1. listlandprotection summary\n" + 14 " 2. listlandprotection <steam id / player name / entity id> [parseable]\n" + 15 " 3. listlandprotection nearby [length]\n" + 16 "1. Lists only players that own claimstones, the number they own and the protection status\n" + 17 "2. Lists only the claims of the player given by his SteamID / entity id / playername, including the individual claim positions.\n" + 18 " If \"parseable\" is specified the output of the individual claims will be in a format better suited for programmatical readout.\n" + 19 "3. Lists claims in a square with edge length of 64 (or the optionally specified size) around the executing player\n"; 22 20 } 23 21 24 public override string[] GetCommands () 25 { 26 return new string[] { "listlandprotection", "llp" }; 22 public override string[] GetCommands () { 23 return new[] {"listlandprotection", "llp"}; 27 24 } 28 25 29 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 30 { 26 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 31 27 try { 32 28 if (_senderInfo.RemoteClientInfo != null) { … … 41 37 bool summaryOnly = false; 42 38 string steamIdFilter = string.Empty; 43 Vector3i closeTo = default (Vector3i);39 Vector3i closeTo = default (Vector3i); 44 40 bool onlyCloseToPlayer = false; 45 41 int closeToDistance = 32; … … 71 67 try { 72 68 if (_params.Count == 3) { 73 if (!int.TryParse (_params [1], out closeToDistance)) {69 if (!int.TryParse (_params [1], out closeToDistance)) { 74 70 SdtdConsole.Instance.Output ("Given length is not an integer!"); 75 71 return; 76 72 } 73 77 74 closeToDistance /= 2; 78 75 } 76 79 77 ClientInfo ci = ConsoleHelper.ParseParamSteamIdOnline (_params [_params.Count - 1]); 80 78 EntityPlayer ep = w.Players.dict [ci.entityId]; … … 95 93 LandClaimList.OwnerFilter[] ownerFilters = null; 96 94 if (!string.IsNullOrEmpty (steamIdFilter)) { 97 ownerFilters = new LandClaimList.OwnerFilter[] { LandClaimList.SteamIdFilter (steamIdFilter)};95 ownerFilters = new[] {LandClaimList.SteamIdFilter (steamIdFilter)}; 98 96 } 97 99 98 LandClaimList.PositionFilter[] posFilters = null; 100 99 if (onlyCloseToPlayer) { 101 posFilters = new LandClaimList.PositionFilter[] { LandClaimList.CloseToFilter2dRect (closeTo, closeToDistance)};100 posFilters = new[] {LandClaimList.CloseToFilter2dRect (closeTo, closeToDistance)}; 102 101 } 103 102 104 Dictionary<P ersistentData.Player, List<Vector3i>> claims = LandClaimList.GetLandClaims (ownerFilters, posFilters);103 Dictionary<Player, List<Vector3i>> claims = LandClaimList.GetLandClaims (ownerFilters, posFilters); 105 104 106 foreach (KeyValuePair<P ersistentData.Player, List<Vector3i>> kvp in claims) {107 SdtdConsole.Instance.Output ( String.Format (105 foreach (KeyValuePair<Player, List<Vector3i>> kvp in claims) { 106 SdtdConsole.Instance.Output (string.Format ( 108 107 "Player \"{0} ({1})\" owns {4} keystones (protected: {2}, current hardness multiplier: {3})", 109 108 kvp.Key.Name, … … 115 114 foreach (Vector3i v in kvp.Value) { 116 115 if (parseableOutput) { 117 SdtdConsole.Instance.Output ("LandProtectionOf: id=" + kvp.Key.SteamID + ", playerName=" + kvp.Key.Name + ", location=" + v.ToString ()); 116 SdtdConsole.Instance.Output ("LandProtectionOf: id=" + kvp.Key.SteamID + 117 ", playerName=" + kvp.Key.Name + ", location=" + v); 118 118 } else { 119 SdtdConsole.Instance.Output (" (" + v .ToString ()+ ")");119 SdtdConsole.Instance.Output (" (" + v + ")"); 120 120 } 121 121 } … … 123 123 } 124 124 125 if (steamIdFilter.Length == 0) 125 if (steamIdFilter.Length == 0) { 126 126 SdtdConsole.Instance.Output ("Total of " + ppl.m_lpBlockMap.Count + " keystones in the game"); 127 } 127 128 } catch (Exception e) { 128 129 Log.Out ("Error in ListLandProtection.Run: " + e); -
binary-improvements/AllocsCommands/Commands/RemoveLandProtection.cs
r306 r325 1 1 using System; 2 2 using System.Collections.Generic; 3 using AllocsFixes.PersistentData; 3 4 4 namespace AllocsFixes.CustomCommands 5 { 6 public class RemoveLandProtection : ConsoleCmdAbstract 7 { 8 public override string GetDescription () 9 { 5 namespace AllocsFixes.CustomCommands { 6 public class RemoveLandProtection : ConsoleCmdAbstract { 7 public override string GetDescription () { 10 8 return "removes the association of a land protection block to the owner"; 11 9 } … … 13 11 public override string GetHelp () { 14 12 return "Usage:" + 15 16 17 18 19 20 13 " 1. removelandprotection <steamid>\n" + 14 " 2. removelandprotection <x> <y> <z>\n" + 15 " 3. removelandprotection nearby [length]\n" + 16 "1. Remove all land claims owned by the user with the given SteamID\n" + 17 "2. Remove only the claim block on the exactly given block position\n" + 18 "3. Remove all claims in a square with edge length of 64 (or the optionally specified size) around the executing player"; 21 19 } 22 20 23 public override string[] GetCommands () 24 { 25 return new string[] { "removelandprotection", "rlp" }; 21 public override string[] GetCommands () { 22 return new[] {"removelandprotection", "rlp"}; 26 23 } 27 24 28 private void removeById (string _id) 29 { 25 private void removeById (string _id) { 30 26 try { 31 27 PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList (); 32 28 33 29 if (_id.Length < 1 || !ppl.Players.ContainsKey (_id)) { 34 SdtdConsole.Instance.Output ("Not a valid Steam ID or user has never logged on. Use \"listlandprotection\" to get a list of keystones."); 30 SdtdConsole.Instance.Output ( 31 "Not a valid Steam ID or user has never logged on. Use \"listlandprotection\" to get a list of keystones."); 35 32 return; 36 33 } 34 37 35 if (ppl.Players [_id].LPBlocks == null || ppl.Players [_id].LPBlocks.Count == 0) { 38 SdtdConsole.Instance.Output ("Player does not own any keystones. Use \"listlandprotection\" to get a list of keystones."); 36 SdtdConsole.Instance.Output ( 37 "Player does not own any keystones. Use \"listlandprotection\" to get a list of keystones."); 39 38 return; 40 39 } 41 40 42 41 List<BlockChangeInfo> changes = new List<BlockChangeInfo> (); 43 foreach (Vector3i pos in ppl.Players [_id].LPBlocks) {42 foreach (Vector3i pos in ppl.Players [_id].LPBlocks) { 44 43 BlockChangeInfo bci = new BlockChangeInfo (pos, new BlockValue (0), true, false); 45 44 changes.Add (bci); 46 45 } 46 47 47 GameManager.Instance.SetBlocksRPC (changes); 48 48 49 SdtdConsole.Instance.Output ("Tried to remove #" + changes.Count + " land protection blocks for player \"" + _id + "\". Note "+ 50 "that only blocks in chunks that are currently loaded (close to any player) could be removed. "+ 51 "Please check for remaining blocks by running:"); 52 SdtdConsole.Instance.Output(" listlandprotection " + _id); 49 SdtdConsole.Instance.Output ("Tried to remove #" + changes.Count + 50 " land protection blocks for player \"" + _id + "\". Note " + 51 "that only blocks in chunks that are currently loaded (close to any player) could be removed. " + 52 "Please check for remaining blocks by running:"); 53 SdtdConsole.Instance.Output (" listlandprotection " + _id); 53 54 } catch (Exception e) { 54 55 Log.Out ("Error in RemoveLandProtection.removeById: " + e); … … 56 57 } 57 58 58 private void removeByPosition (List<string> _coords) 59 { 59 private void removeByPosition (List<string> _coords) { 60 60 try { 61 61 int x = int.MinValue; … … 77 77 Dictionary<Vector3i, PersistentPlayerData> d = ppl.m_lpBlockMap; 78 78 if (d == null || !d.ContainsKey (v)) { 79 SdtdConsole.Instance.Output ("No land protection block at the given position or not a valid position. Use \"listlandprotection\" to get a list of keystones."); 79 SdtdConsole.Instance.Output ( 80 "No land protection block at the given position or not a valid position. Use \"listlandprotection\" to get a list of keystones."); 80 81 return; 81 82 } … … 88 89 GameManager.Instance.SetBlocksRPC (changes); 89 90 90 SdtdConsole.Instance.Output ("Land protection block at (" + v .ToString ()+ ") removed");91 SdtdConsole.Instance.Output ("Land protection block at (" + v + ") removed"); 91 92 } catch (Exception e) { 92 93 Log.Out ("Error in RemoveLandProtection.removeByPosition: " + e); … … 94 95 } 95 96 96 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 97 { 97 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 98 98 try { 99 99 if (_senderInfo.RemoteClientInfo != null) { … … 107 107 int closeToDistance = 32; 108 108 if (_params.Count == 3) { 109 if (!int.TryParse (_params [1], out closeToDistance)) {109 if (!int.TryParse (_params [1], out closeToDistance)) { 110 110 SdtdConsole.Instance.Output ("Given length is not an integer!"); 111 111 return; 112 112 } 113 113 114 closeToDistance /= 2; 114 115 } 116 115 117 ClientInfo ci = ConsoleHelper.ParseParamSteamIdOnline (_params [_params.Count - 1]); 116 118 EntityPlayer ep = GameManager.Instance.World.Players.dict [ci.entityId]; 117 119 Vector3i closeTo = new Vector3i (ep.GetPosition ()); 118 LandClaimList.PositionFilter[] posFilters = new LandClaimList.PositionFilter[] { LandClaimList.CloseToFilter2dRect (closeTo, closeToDistance) }; 119 Dictionary<PersistentData.Player, List<Vector3i>> claims = LandClaimList.GetLandClaims (null, posFilters); 120 LandClaimList.PositionFilter[] posFilters = 121 {LandClaimList.CloseToFilter2dRect (closeTo, closeToDistance)}; 122 Dictionary<Player, List<Vector3i>> claims = LandClaimList.GetLandClaims (null, posFilters); 120 123 121 124 try { 122 125 List<BlockChangeInfo> changes = new List<BlockChangeInfo> (); 123 foreach (KeyValuePair<P ersistentData.Player, List<Vector3i>> kvp in claims) {126 foreach (KeyValuePair<Player, List<Vector3i>> kvp in claims) { 124 127 foreach (Vector3i v in kvp.Value) { 125 128 BlockChangeInfo bci = new BlockChangeInfo (v, new BlockValue (0), true, false); … … 127 130 } 128 131 } 132 129 133 GameManager.Instance.SetBlocksRPC (changes); 130 134 } catch (Exception e) { 131 135 SdtdConsole.Instance.Output ("Error removing claims"); 132 136 Log.Out ("Error in RemoveLandProtection.Run: " + e); 133 return;134 137 } 135 138 } catch (Exception e) { 136 139 SdtdConsole.Instance.Output ("Error getting current player's position"); 137 140 Log.Out ("Error in RemoveLandProtection.Run: " + e); 138 return;139 141 } 140 142 } else if (_params.Count == 1) { -
binary-improvements/AllocsCommands/Commands/Reply.cs
r309 r325 1 using System;2 1 using System.Collections.Generic; 3 2 4 namespace AllocsFixes.CustomCommands 5 { 6 public class Reply : ConsoleCmdAbstract 7 { 8 public override string GetDescription () 9 { 3 namespace AllocsFixes.CustomCommands { 4 public class Reply : ConsoleCmdAbstract { 5 public override string GetDescription () { 10 6 return "send a message to the player who last sent you a PM"; 11 7 } … … 13 9 public override string GetHelp () { 14 10 return "Usage:\n" + 15 16 11 " reply <message>\n" + 12 "Send the given message to the user you last received a PM from."; 17 13 } 18 14 19 public override string[] GetCommands () 20 { 21 return new string[] { "reply", "re" }; 15 public override string[] GetCommands () { 16 return new[] {"reply", "re"}; 22 17 } 23 18 24 private void RunInternal (ClientInfo _sender, List<string> _params) 25 { 19 private void RunInternal (ClientInfo _sender, List<string> _params) { 26 20 if (_params.Count < 1) { 27 21 SdtdConsole.Instance.Output ("Usage: reply <message>"); … … 35 29 Chat.SendMessage (receiver, _sender, message); 36 30 } else { 37 SdtdConsole.Instance.Output ("You have not received a PM so far or sender of last received PM is no longer online."); 31 SdtdConsole.Instance.Output ( 32 "You have not received a PM so far or sender of last received PM is no longer online."); 38 33 } 39 34 } -
binary-improvements/AllocsCommands/Commands/SayToPlayer.cs
r238 r325 2 2 using System.Collections.Generic; 3 3 4 namespace AllocsFixes.CustomCommands 5 { 6 public class SayToPlayer : ConsoleCmdAbstract 7 { 8 public override string GetDescription () 9 { 4 namespace AllocsFixes.CustomCommands { 5 public class SayToPlayer : ConsoleCmdAbstract { 6 public override string GetDescription () { 10 7 return "send a message to a single player"; 11 8 } … … 13 10 public override string GetHelp () { 14 11 return "Usage:\n" + 15 16 12 " pm <player name / steam id / entity id> <message>\n" + 13 "Send a PM to the player given by the player name or entity id (as given by e.g. \"lpi\")."; 17 14 } 18 15 19 public override string[] GetCommands () 20 { 21 return new string[] { "sayplayer", "pm" }; 16 public override string[] GetCommands () { 17 return new[] {"sayplayer", "pm"}; 22 18 } 23 19 24 private void RunInternal (ClientInfo _sender, List<string> _params) 25 { 20 private void RunInternal (ClientInfo _sender, List<string> _params) { 26 21 if (_params.Count < 2) { 27 22 SdtdConsole.Instance.Output ("Usage: sayplayer <playername|entityid> <message>"); … … 39 34 } 40 35 41 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 42 { 36 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 43 37 try { 44 38 if (_senderInfo.RemoteClientInfo != null) { -
binary-improvements/AllocsCommands/Commands/ShowInventory.cs
r297 r325 1 using AllocsFixes.PersistentData;2 1 using System; 3 2 using System.Collections.Generic; 3 using AllocsFixes.PersistentData; 4 4 5 namespace AllocsFixes.CustomCommands 6 { 7 public class ShowInventory : ConsoleCmdAbstract 8 { 9 10 public override string GetDescription () 11 { 5 namespace AllocsFixes.CustomCommands { 6 public class ShowInventory : ConsoleCmdAbstract { 7 public override string GetDescription () { 12 8 return "list inventory of a given player"; 13 9 } 14 10 15 public override string GetHelp () 16 { 11 public override string GetHelp () { 17 12 return "Usage:\n" + 18 " showinventory <steam id / player name / entity id> [tag]\n" +19 "Show the inventory of the player given by his SteamID, player name or\n" +20 "entity id (as given by e.g. \"lpi\").\n" +21 "Optionally specify a tag that is included in each line of the output. In\n" +22 "this case output is designed to be easily parseable by tools.\n" +23 "Note: This only shows the player's inventory after it was first sent to\n" +24 "the server which happens at least every 30 seconds.";13 " showinventory <steam id / player name / entity id> [tag]\n" + 14 "Show the inventory of the player given by his SteamID, player name or\n" + 15 "entity id (as given by e.g. \"lpi\").\n" + 16 "Optionally specify a tag that is included in each line of the output. In\n" + 17 "this case output is designed to be easily parseable by tools.\n" + 18 "Note: This only shows the player's inventory after it was first sent to\n" + 19 "the server which happens at least every 30 seconds."; 25 20 } 26 21 27 public override string[] GetCommands () 28 { 29 return new string[] { "showinventory", "si" }; 22 public override string[] GetCommands () { 23 return new[] {"showinventory", "si"}; 30 24 } 31 25 32 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 33 { 26 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 34 27 try { 35 28 if (_params.Count < 1) { … … 40 33 string steamid = PersistentContainer.Instance.Players.GetSteamID (_params [0], true); 41 34 if (steamid == null) { 42 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s)."); 35 SdtdConsole.Instance.Output ( 36 "Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s)."); 43 37 return; 44 38 } … … 52 46 PersistentData.Inventory inv = p.Inventory; 53 47 54 if (tag == null) 48 if (tag == null) { 55 49 SdtdConsole.Instance.Output ("Belt of player " + p.Name + ":"); 50 } 51 56 52 PrintInv (inv.belt, p.EntityID, "belt", tag); 57 if (tag == null) 53 if (tag == null) { 58 54 SdtdConsole.Instance.Output (string.Empty); 55 } 59 56 60 if (tag == null) 57 if (tag == null) { 61 58 SdtdConsole.Instance.Output ("Bagpack of player " + p.Name + ":"); 59 } 60 62 61 PrintInv (inv.bag, p.EntityID, "backpack", tag); 63 if (tag == null) 62 if (tag == null) { 64 63 SdtdConsole.Instance.Output (string.Empty); 64 } 65 65 66 if (tag == null) 66 if (tag == null) { 67 67 SdtdConsole.Instance.Output ("Equipment of player " + p.Name + ":"); 68 } 69 68 70 PrintEquipment (inv.equipment, p.EntityID, "equipment", tag); 69 71 70 if (tag != null) { 71 SdtdConsole.Instance.Output ("tracker_item id=" + p.EntityID + ", tag=" + tag + ", SHOWINVENTORY DONE"); 72 if (tag != null) { 73 SdtdConsole.Instance.Output ("tracker_item id=" + p.EntityID + ", tag=" + tag + 74 ", SHOWINVENTORY DONE"); 72 75 } 73 74 76 } catch (Exception e) { 75 77 Log.Out ("Error in ShowInventory.Run: " + e); … … 77 79 } 78 80 79 private void PrintInv (List<InvItem> _inv, int _entityId, string _location, string _tag) 80 { 81 private void PrintInv (List<InvItem> _inv, int _entityId, string _location, string _tag) { 81 82 for (int i = 0; i < _inv.Count; i++) { 82 83 if (_inv [i] != null) { 83 if (_tag == null) { // no Tag defined -> readable output 84 if (_tag == null) { 85 // no Tag defined -> readable output 84 86 if (_inv [i].quality < 0) { 85 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, _inv [i].count, _inv [i].itemName)); 87 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, 88 _inv [i].count, _inv [i].itemName)); 86 89 } else { 87 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2} - quality: {3}", i, _inv [i].count, _inv [i].itemName, _inv [i].quality)); 90 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2} - quality: {3}", i, 91 _inv [i].count, _inv [i].itemName, _inv [i].quality)); 88 92 } 93 89 94 DoParts (_inv [i].parts, 1, null); 90 } else { // Tag defined -> parseable output 91 String partsMsg = DoParts(_inv[i].parts, 1, ""); 92 String msg = "tracker_item id=" + _entityId + ", tag=" + _tag + ", location=" + _location + ", slot=" + i + ", item=" + _inv[i].itemName + ", qnty=" + _inv[i].count + ", quality=" + _inv[i].quality + ", parts=(" + partsMsg + ")"; 93 SdtdConsole.Instance.Output(msg); 95 } else { 96 // Tag defined -> parseable output 97 string partsMsg = DoParts (_inv [i].parts, 1, ""); 98 string msg = "tracker_item id=" + _entityId + ", tag=" + _tag + ", location=" + _location + 99 ", slot=" + i + ", item=" + _inv [i].itemName + ", qnty=" + _inv [i].count + 100 ", quality=" + _inv [i].quality + ", parts=(" + partsMsg + ")"; 101 SdtdConsole.Instance.Output (msg); 94 102 } 95 103 } … … 97 105 } 98 106 99 private void PrintEquipment (InvItem[] _equipment, int _entityId, string _location, string _tag) 100 { 107 private void PrintEquipment (InvItem[] _equipment, int _entityId, string _location, string _tag) { 101 108 AddEquipment ("head", _equipment, EquipmentSlots.Headgear, _entityId, _location, _tag); 102 109 AddEquipment ("eyes", _equipment, EquipmentSlots.Eyewear, _entityId, _location, _tag); … … 114 121 } 115 122 116 private void AddEquipment (string _slotname, InvItem[] _items, EquipmentSlots _slot, int _entityId, string _location, string _tag)117 {123 private void AddEquipment (string _slotname, InvItem[] _items, EquipmentSlots _slot, int _entityId, 124 string _location, string _tag) { 118 125 int[] slotindices = XUiM_PlayerEquipment.GetSlotIndicesByEquipmentSlot (_slot); 119 126 … … 121 128 if (_items != null && _items [slotindices [i]] != null) { 122 129 InvItem item = _items [slotindices [i]]; 123 if (_tag == null) { // no Tag defined -> readable output 130 if (_tag == null) { 131 // no Tag defined -> readable output 124 132 if (item.quality < 0) { 125 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000}", _slotname, item.itemName)); 133 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000}", _slotname, 134 item.itemName)); 126 135 } else { 127 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000} - quality: {2}", _slotname, item.itemName, item.quality)); 136 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000} - quality: {2}", 137 _slotname, item.itemName, item.quality)); 128 138 } 139 129 140 DoParts (_items [slotindices [i]].parts, 1, null); 130 } else { // Tag defined -> parseable output 131 String partsMsg = DoParts(_items[slotindices[i]].parts, 1, ""); 132 String msg = "tracker_item id=" + _entityId + ", tag=" + _tag + ", location=" + _location + ", slot=" + _slotname + ", item=" + item.itemName + ", qnty=1, quality=" + item.quality + ", parts=(" + partsMsg + ")"; 133 SdtdConsole.Instance.Output(msg); 141 } else { 142 // Tag defined -> parseable output 143 string partsMsg = DoParts (_items [slotindices [i]].parts, 1, ""); 144 string msg = "tracker_item id=" + _entityId + ", tag=" + _tag + ", location=" + _location + 145 ", slot=" + _slotname + ", item=" + item.itemName + ", qnty=1, quality=" + 146 item.quality + ", parts=(" + partsMsg + ")"; 147 SdtdConsole.Instance.Output (msg); 134 148 } 149 135 150 return; 136 151 } … … 138 153 } 139 154 140 private string DoParts (InvItem[] _parts, int _indent, string _currentMessage) 141 { 155 private string DoParts (InvItem[] _parts, int _indent, string _currentMessage) { 142 156 if (_parts != null && _parts.Length > 0) { 143 157 string indenter = new string (' ', _indent * 4); 144 158 for (int i = 0; i < _parts.Length; i++) { 145 159 if (_parts [i] != null) { 146 if (_currentMessage == null) { // no currentMessage given -> readable output 160 if (_currentMessage == null) { 161 // no currentMessage given -> readable output 147 162 if (_parts [i].quality < 0) { 148 SdtdConsole.Instance.Output (string.Format ("{0} - {1}", indenter, _parts [i].itemName)); 163 SdtdConsole.Instance.Output (string.Format ("{0} - {1}", indenter, 164 _parts [i].itemName)); 149 165 } else { 150 SdtdConsole.Instance.Output (string.Format ("{0} - {1} - quality: {2}", indenter, _parts [i].itemName, _parts [i].quality)); 166 SdtdConsole.Instance.Output (string.Format ("{0} - {1} - quality: {2}", 167 indenter, _parts [i].itemName, _parts [i].quality)); 151 168 } 169 152 170 DoParts (_parts [i].parts, _indent + 1, _currentMessage); 153 } else { // currentMessage given -> parseable output 171 } else { 172 // currentMessage given -> parseable output 154 173 if (_currentMessage.Length > 0) { 155 174 _currentMessage += ","; 156 175 } 157 _currentMessage += _parts[i].itemName + "@" + _parts[i].quality; 176 177 _currentMessage += _parts [i].itemName + "@" + _parts [i].quality; 158 178 _currentMessage = DoParts (_parts [i].parts, _indent + 1, _currentMessage); 159 179 } … … 161 181 } 162 182 } 183 163 184 return _currentMessage; 164 185 } 165 166 186 } 167 187 } -
binary-improvements/AllocsCommands/PrivateMessageConnections.cs
r324 r325 1 using System;2 1 using System.Collections.Generic; 3 2 using Steamworks; 4 3 5 namespace AllocsFixes.CustomCommands 6 { 7 public class PrivateMessageConnections 8 { 9 private static Dictionary<CSteamID, CSteamID> senderOfLastPM = new Dictionary<CSteamID, CSteamID> (); 4 namespace AllocsFixes.CustomCommands { 5 public class PrivateMessageConnections { 6 private static readonly Dictionary<CSteamID, CSteamID> senderOfLastPM = new Dictionary<CSteamID, CSteamID> (); 10 7 11 public static void SetLastPMSender (ClientInfo _sender, ClientInfo _receiver) 12 { 8 public static void SetLastPMSender (ClientInfo _sender, ClientInfo _receiver) { 13 9 senderOfLastPM [_receiver.steamId] = _sender.steamId; 14 10 } 15 11 16 public static ClientInfo GetLastPMSenderForPlayer (ClientInfo _player) 17 { 12 public static ClientInfo GetLastPMSenderForPlayer (ClientInfo _player) { 18 13 if (senderOfLastPM.ContainsKey (_player.steamId)) { 19 14 CSteamID recSteamId = senderOfLastPM [_player.steamId]; … … 21 16 return recInfo; 22 17 } 18 23 19 return null; 24 20 }
Note:
See TracChangeset
for help on using the changeset viewer.