Changeset 230 for binary-improvements/AllocsCommands/Commands
- Timestamp:
- Apr 18, 2015, 4:27:57 PM (10 years ago)
- Location:
- binary-improvements/AllocsCommands/Commands
- Files:
-
- 7 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/Commands/Give.cs
r224 r230 5 5 namespace AllocsFixes.CustomCommands 6 6 { 7 public class Give : ConsoleC ommand7 public class Give : ConsoleCmdAbstract 8 8 { 9 public Give (ConsoleSdtd cons) : base(cons) 10 { 11 } 12 13 public override string Description () 9 public override string GetDescription () 14 10 { 15 11 return "give an item to a player (entity id or name)"; 16 12 } 17 13 18 public override string[] Names ()14 public override string[] GetCommands () 19 15 { 20 16 return new string[] { "give", string.Empty }; 21 17 } 22 18 23 public override void Run (string[] _params)19 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 24 20 { 25 21 try { 26 if (_params. Length!= 3) {27 m_Console.SendResult ("Usage: give <playername|entityid> <itemname> <amount>");22 if (_params.Count != 3) { 23 SdtdConsole.Instance.Output ("Usage: give <playername|entityid> <itemname> <amount>"); 28 24 return; 29 25 } 30 26 31 ClientInfo ci = Co mmonMappingFunctions.GetClientInfoFromNameOrID (_params [0], false);27 ClientInfo ci = ConsoleHelper.ParseParamIdOrName (_params [0]); 32 28 33 29 if (ci == null) { 34 m_Console.SendResult ("Playername or entity id not found.");30 SdtdConsole.Instance.Output ("Playername or entity id not found."); 35 31 return; 36 32 } 37 33 38 ItemValue iv = ItemList.Instance.GetItemValue (_params[1]);34 ItemValue iv = ItemList.Instance.GetItemValue (_params[1]); 39 35 if (iv == null) { 40 m_Console.SendResult ("Item not found.");36 SdtdConsole.Instance.Output ("Item not found."); 41 37 return; 42 38 } … … 44 40 int n = int.MinValue; 45 41 if (!int.TryParse (_params [2], out n) || n <= 0) { 46 m_Console.SendResult ("Amount is not an integer or not greater than zero.");42 SdtdConsole.Instance.Output ("Amount is not an integer or not greater than zero."); 47 43 return; 48 44 } 49 45 50 EntityPlayer p = CommonMappingFunctions.GetEntityPlayer (ci);46 EntityPlayer p = GameManager.Instance.World.Players.dict [ci.entityId]; 51 47 52 48 InventoryField invField = new InventoryField (iv, n); 53 49 54 CommonMappingFunctions.GetGameManager ().ItemDropServer (invField, p.GetPosition (), Vector3.zero, -1, 50);50 GameManager.Instance.ItemDropServer (invField, p.GetPosition (), Vector3.zero, -1, 50); 55 51 56 m_Console.SendResult ("Dropped item");52 SdtdConsole.Instance.Output ("Dropped item"); 57 53 } catch (Exception e) { 58 54 Log.Out ("Error in Give.Run: " + e); -
binary-improvements/AllocsCommands/Commands/ListItems.cs
r224 r230 4 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public class ListItems : ConsoleC ommand6 public class ListItems : ConsoleCmdAbstract 7 7 { 8 public ListItems (ConsoleSdtd cons) : base(cons) 9 { 10 } 11 12 public override string Description () 8 public override string GetDescription () 13 9 { 14 10 return "lists all items that contain the given substring"; 15 11 } 16 12 17 public override string[] Names ()13 public override string[] GetCommands () 18 14 { 19 15 return new string[] { "listitems", "li" }; 20 16 } 21 17 22 public override void Run (string[] _params)18 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 23 19 { 24 20 try { 25 if (_params. Length!= 1 || _params [0].Length == 0) {26 m_Console.SendResult ("Usage: listitems <searchString>");21 if (_params.Count != 1 || _params [0].Length == 0) { 22 SdtdConsole.Instance.Output ("Usage: listitems <searchString>"); 27 23 return; 28 24 } … … 31 27 foreach (string s in ItemList.Instance.ItemNames) { 32 28 if (s.ToLower ().Contains (_params [0].ToLower ())) { 33 m_Console.SendResult (" " + s);29 SdtdConsole.Instance.Output (" " + s); 34 30 n++; 35 31 } 36 32 } 37 33 38 m_Console.SendResult ("Listed " + n + " matching items.");34 SdtdConsole.Instance.Output ("Listed " + n + " matching items."); 39 35 } catch (Exception e) { 40 36 Log.Out ("Error in ListItems.Run: " + e); -
binary-improvements/AllocsCommands/Commands/ListKnownPlayers.cs
r224 r230 5 5 namespace AllocsFixes.CustomCommands 6 6 { 7 public class ListKnownPlayers : ConsoleC ommand7 public class ListKnownPlayers : ConsoleCmdAbstract 8 8 { 9 public ListKnownPlayers (ConsoleSdtd cons) : base(cons) 10 { 11 } 12 13 public override string Description () 9 public override string GetDescription () 14 10 { 15 11 return "lists all players that were ever online (optionally filtered)"; 16 12 } 17 13 18 public override string[] Names ()14 public override string[] GetCommands () 19 15 { 20 16 return new string[] { "listknownplayers", "lkp" }; 21 17 } 22 18 23 public override void Run (string[] _params)19 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 24 20 { 25 21 try { 26 AdminTools admTools = CommonMappingFunctions.GetGameManager ().adminTools;22 AdminTools admTools = GameManager.Instance.adminTools; 27 23 28 24 bool onlineOnly = false; … … 30 26 string nameFilter = string.Empty; 31 27 32 if (_params. Length== 1) {28 if (_params.Count == 1) { 33 29 if (_params [0].ToLower ().Equals ("-online")) { 34 30 onlineOnly = true; … … 49 45 && (nameFilter.Length == 0 || p.Name.ToLower ().Contains (nameFilter)) 50 46 ) { 51 m_Console.SendResult (String.Format ("{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}",47 SdtdConsole.Instance.Output (String.Format ("{0}. {1}, id={2}, steamid={3}, online={4}, ip={5}, playtime={6} m, seen={7}", 52 48 ++num, p.Name, p.EntityID, sid, p.IsOnline, p.IP, 53 49 p.TotalPlayTime / 60, … … 56 52 } 57 53 } 58 m_Console.SendResult ("Total of " + PersistentContainer.Instance.Players.Count + " known");54 SdtdConsole.Instance.Output ("Total of " + PersistentContainer.Instance.Players.Count + " known"); 59 55 } catch (Exception e) { 60 56 Log.Out ("Error in ListKnownPlayers.Run: " + e); -
binary-improvements/AllocsCommands/Commands/ListLandProtection.cs
r224 r230 4 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public class ListLandProtection : ConsoleC ommand6 public class ListLandProtection : ConsoleCmdAbstract 7 7 { 8 public ListLandProtection (ConsoleSdtd cons) : base(cons) 9 { 10 } 11 12 public override string Description () 8 public override string GetDescription () 13 9 { 14 10 return "lists all land protection blocks and owners"; 15 11 } 16 12 17 public override string[] Names ()13 public override string[] GetCommands () 18 14 { 19 15 return new string[] { "listlandprotection", "llp" }; 20 16 } 21 17 22 public override void Execute Remote (string _sender, string[] _params)18 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 23 19 { 24 20 try { 25 if (_params.Length >= 1 && _params [0].ToLower ().Equals ("nearby")) { 26 string[] params2 = new string[_params.Length + 1]; 27 for (int i = 0; i < _params.Length; i++) 28 params2 [i] = _params [i]; 29 params2 [_params.Length] = _sender; 30 _params = params2; 21 if (_senderInfo.RemoteClientInfo != null) { 22 if (_params.Count >= 1 && _params [0].ToLower ().Equals ("nearby")) { 23 _params.Add (_senderInfo.RemoteClientInfo.playerId); 24 } 31 25 } 32 Run (_params);33 } catch (Exception e) {34 Log.Out ("Error in ListLandProtection.ExecuteRemote: " + e);35 }36 }37 26 38 public override void Run (string[] _params) 39 { 40 try { 41 World w = CommonMappingFunctions.GetGameManager ().World; 42 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList (); 27 World w = GameManager.Instance.World; 28 PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList (); 43 29 44 30 bool summaryOnly = false; … … 48 34 int closeToDistance = 32; 49 35 50 if (_params. Length== 1) {36 if (_params.Count == 1) { 51 37 long tempLong; 52 38 … … 56 42 steamIdFilter = _params [0]; 57 43 } else { 58 ClientInfo ci = Co mmonMappingFunctions.GetClientInfoFromNameOrID (_params [0], true);44 ClientInfo ci = ConsoleHelper.ParseParamIdOrName (_params [0]); 59 45 if (ci != null) { 60 steamIdFilter = CommonMappingFunctions.GetSteamID (ci);46 steamIdFilter = ci.playerId; 61 47 } else { 62 m_Console.SendResult ("Player name or entity id \"" + _params [0] + "\" not found.");48 SdtdConsole.Instance.Output ("Player name or entity id \"" + _params [0] + "\" not found."); 63 49 return; 64 50 } 65 51 } 66 } else if (_params. Length>= 2) {52 } else if (_params.Count >= 2) { 67 53 if (_params [0].ToLower ().Equals ("nearby")) { 68 54 try { 69 if (_params. Length== 3) {55 if (_params.Count == 3) { 70 56 if (!int.TryParse (_params[1], out closeToDistance)) { 71 m_Console.SendResult ("Given radius is not an integer!");57 SdtdConsole.Instance.Output ("Given radius is not an integer!"); 72 58 } 73 59 } 74 ClientInfo ci = Co mmonMappingFunctions.GetClientInfoFromSteamID (_params [_params.Length- 1]);75 EntityPlayer ep = CommonMappingFunctions.GetEntityPlayer (ci);60 ClientInfo ci = ConsoleHelper.ParseParamSteamIdOnline (_params [_params.Count - 1]); 61 EntityPlayer ep = w.Players.dict [ci.entityId]; 76 62 closeTo = new Vector3i (ep.GetPosition ()); 77 63 onlyCloseToPlayer = true; 78 64 } catch (Exception e) { 79 m_Console.SendResult ("Error getting current player's position");65 SdtdConsole.Instance.Output ("Error getting current player's position"); 80 66 Log.Out ("Error in ListLandProtection.Run: " + e); 81 67 } 82 68 } else { 83 m_Console.SendResult ("Illegal parameter list");69 SdtdConsole.Instance.Output ("Illegal parameter list"); 84 70 return; 85 71 } … … 103 89 name += " (" + kvp.Key.PlayerId + ")"; 104 90 105 m_Console.SendResult (String.Format ("Player \"{0}\" owns {3} keystones (protected: {1}, current hardness multiplier: {2})", name, w.LandClaimIsActive (kvp.Key), w.LandClaimPower (kvp.Key), kvp.Value.Count));91 SdtdConsole.Instance.Output (String.Format ("Player \"{0}\" owns {3} keystones (protected: {1}, current hardness multiplier: {2})", name, w.LandClaimIsActive (kvp.Key), w.LandClaimPower (kvp.Key), kvp.Value.Count)); 106 92 if (!summaryOnly) { 107 93 foreach (Vector3i v in kvp.Value) { 108 m_Console.SendResult (" (" + v.ToString () + ")");94 SdtdConsole.Instance.Output (" (" + v.ToString () + ")"); 109 95 } 110 96 } … … 114 100 115 101 if (steamIdFilter.Length == 0) 116 m_Console.SendResult ("Total of " + d.Count + " keystones in the game");102 SdtdConsole.Instance.Output ("Total of " + d.Count + " keystones in the game"); 117 103 } catch (Exception e) { 118 104 Log.Out ("Error in ListLandProtection.Run: " + e); -
binary-improvements/AllocsCommands/Commands/RemoveLandProtection.cs
r224 r230 4 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public class RemoveLandProtection : ConsoleC ommand6 public class RemoveLandProtection : ConsoleCmdAbstract 7 7 { 8 public RemoveLandProtection (ConsoleSdtd cons) : base(cons) 9 { 10 } 11 12 public override string Description () 8 public override string GetDescription () 13 9 { 14 10 return "removes the association of a land protection block to the owner"; 15 11 } 16 12 17 public override string[] Names ()13 public override string[] GetCommands () 18 14 { 19 15 return new string[] { "removelandprotection", "rlp" }; … … 23 19 { 24 20 try { 25 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList ();21 PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList (); 26 22 27 23 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.");24 SdtdConsole.Instance.Output ("Not a valid Steam ID or user has never logged on. Use \"listlandprotection\" to get a list of keystones."); 29 25 return; 30 26 } 31 27 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.");28 SdtdConsole.Instance.Output ("Player does not own any keystones. Use \"listlandprotection\" to get a list of keystones."); 33 29 return; 34 30 } … … 39 35 changes.Add (bci); 40 36 } 41 CommonMappingFunctions.GetGameManager ().SetBlocksRPC (changes);37 GameManager.Instance.SetBlocksRPC (changes); 42 38 43 m_Console.SendResult ("Tried to remove #" + changes.Count + " land protection blocks for player \"" + _id + "\". Note "+39 SdtdConsole.Instance.Output ("Tried to remove #" + changes.Count + " land protection blocks for player \"" + _id + "\". Note "+ 44 40 "that only blocks in chunks that are currently loaded (close to any player) could be removed. "+ 45 41 "Please check for remaining blocks by running:"); 46 m_Console.SendResult(" listlandprotection " + _id);42 SdtdConsole.Instance.Output(" listlandprotection " + _id); 47 43 } catch (Exception e) { 48 44 Log.Out ("Error in RemoveLandProtection.removeById: " + e); … … 50 46 } 51 47 52 private void removeByPosition ( string[]_coords)48 private void removeByPosition (List<string> _coords) 53 49 { 54 50 try { … … 61 57 62 58 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { 63 m_Console.SendResult ("At least one of the given coordinates is not a valid integer");59 SdtdConsole.Instance.Output ("At least one of the given coordinates is not a valid integer"); 64 60 return; 65 61 } … … 67 63 Vector3i v = new Vector3i (x, y, z); 68 64 69 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList ();65 PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList (); 70 66 71 67 Dictionary<Vector3i, PersistentPlayerData> d = ppl.positionToLPBlockOwner; 72 68 if (d == null || !d.ContainsKey (v)) { 73 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 SdtdConsole.Instance.Output ("No land protection block at the given position or not a valid position. Use \"listlandprotection\" to get a list of keystones."); 74 70 return; 75 71 } … … 80 76 changes.Add (bci); 81 77 82 CommonMappingFunctions.GetGameManager ().SetBlocksRPC (changes);78 GameManager.Instance.SetBlocksRPC (changes); 83 79 84 m_Console.SendResult ("Land protection block at (" + v.ToString () + ") removed");80 SdtdConsole.Instance.Output ("Land protection block at (" + v.ToString () + ") removed"); 85 81 } catch (Exception e) { 86 82 Log.Out ("Error in RemoveLandProtection.removeByPosition: " + e); … … 88 84 } 89 85 90 public override void Run (string[] _params)86 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 91 87 { 92 88 try { 93 if (_params. Length== 1) {89 if (_params.Count == 1) { 94 90 removeById (_params [0]); 95 } else if (_params. Length== 3) {91 } else if (_params.Count == 3) { 96 92 removeByPosition (_params); 97 93 } else { 98 m_Console.SendResult ("Usage: removelandprotection <x> <y> <z> OR removelandprotection <steamid>");94 SdtdConsole.Instance.Output ("Usage: removelandprotection <x> <y> <z> OR removelandprotection <steamid>"); 99 95 } 100 96 } catch (Exception e) { -
binary-improvements/AllocsCommands/Commands/Reply.cs
r224 r230 4 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public class Reply : ConsoleC ommand6 public class Reply : ConsoleCmdAbstract 7 7 { 8 public Reply (ConsoleSdtd cons) : base(cons) 9 { 10 } 11 12 public override string Description () 8 public override string GetDescription () 13 9 { 14 10 return "send a message to the player who last sent you a PM"; 15 11 } 16 12 17 public override string[] Names ()13 public override string[] GetCommands () 18 14 { 19 15 return new string[] { "reply", "re" }; 20 16 } 21 17 22 private void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message)18 private void RunInternal (ClientInfo _sender, List<string> _params) 23 19 { 24 PrivateMassageConnections.SetLastPMSender (_sender, _receiver); 25 string senderName = CommonMappingFunctions.GetPlayerName (_sender); 26 27 _receiver.netConnection [0].AddToSendQueue (new NetPackage_GameInfoMessage (_message, senderName + " (PM)")); 28 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 29 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 30 } 31 32 private void RunInternal (ClientInfo _sender, string[] _params) 33 { 34 if (_params.Length < 1) { 35 m_Console.SendResult ("Usage: reply <message>"); 20 if (_params.Count < 1) { 21 SdtdConsole.Instance.Output ("Usage: reply <message>"); 36 22 return; 37 23 } 38 24 39 25 string message = _params [0]; 40 for (int i = 1; i < _params.Length; i++) {41 message += " " + _params [i];42 }43 26 44 27 ClientInfo receiver = PrivateMassageConnections.GetLastPMSenderForPlayer (_sender); 45 if (receiver != null && CommonMappingFunctions.GetClientID (receiver)>= 0) {46 SendMessage (receiver, _sender, message);28 if (receiver != null && receiver.clientId >= 0) { 29 Chat.SendMessage (receiver, _sender, message); 47 30 } else { 48 31 if (receiver != null) { 49 m_Console.SendResult ("The sender of the PM you last received is currently not online.");32 SdtdConsole.Instance.Output ("The sender of the PM you last received is currently not online."); 50 33 } else { 51 m_Console.SendResult ("You have not received a PM so far.");34 SdtdConsole.Instance.Output ("You have not received a PM so far."); 52 35 } 53 36 } 54 37 } 55 38 56 public override void ExecuteRemote (string _sender, string[] _params) 57 { 58 try { 59 m_Console.SendResult (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 60 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 61 RunInternal (ci, _params); 62 } catch (Exception e) { 63 Log.Out ("Error in Reply.ExecuteRemote: " + e); 39 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 40 if (_senderInfo.RemoteClientInfo == null) { 41 Log.Out ("Command \"reply\" can only be used on clients!"); 42 } else { 43 RunInternal (_senderInfo.RemoteClientInfo, _params); 64 44 } 65 }66 67 public override void Run (string[] _params)68 {69 Log.Out ("Command \"reply\" can only be used on clients!");70 45 } 71 46 } -
binary-improvements/AllocsCommands/Commands/SayToPlayer.cs
r224 r230 4 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public class SayToPlayer : ConsoleC ommand6 public class SayToPlayer : ConsoleCmdAbstract 7 7 { 8 public SayToPlayer (ConsoleSdtd cons) : base(cons) 9 { 10 } 11 12 public override string Description () 8 public override string GetDescription () 13 9 { 14 10 return "send a message to a single player"; 15 11 } 16 12 17 public override string[] Names ()13 public override string[] GetCommands () 18 14 { 19 15 return new string[] { "sayplayer", "pm" }; 20 16 } 21 17 22 private void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message)18 private void RunInternal (ClientInfo _sender, List<string> _params) 23 19 { 24 string senderName; 25 if (_sender != null) { 26 PrivateMassageConnections.SetLastPMSender (_sender, _receiver); 27 senderName = CommonMappingFunctions.GetPlayerName (_sender); 28 } else { 29 senderName = "Server"; 30 } 31 ConnectionManager.Instance.SendPackage (new NetPackage_GameInfoMessage (_message, senderName + " (PM)"), new PackageDestinationSingleEntityID (_receiver.entityId)); 32 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 33 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + senderName + "\""); 34 } 35 36 private void RunInternal (ClientInfo _sender, string[] _params) 37 { 38 if (_params.Length < 2) { 39 m_Console.SendResult ("Usage: sayplayer <playername|entityid> <message>"); 20 if (_params.Count < 2) { 21 SdtdConsole.Instance.Output ("Usage: sayplayer <playername|entityid> <message>"); 40 22 return; 41 23 } 42 24 43 25 string message = _params [1]; 44 for (int i = 2; i < _params.Length; i++) {45 message += " " + _params [i];46 }47 26 48 ClientInfo receiver = Co mmonMappingFunctions.GetClientInfoFromNameOrID (_params [0], true);27 ClientInfo receiver = ConsoleHelper.ParseParamIdOrName (_params [0]); 49 28 if (receiver != null) { 50 SendMessage (receiver, _sender, message);29 Chat.SendMessage (receiver, _sender, message); 51 30 } else { 52 m_Console.SendResult ("Playername or entity ID not found.");31 SdtdConsole.Instance.Output ("Playername or entity ID not found."); 53 32 } 54 33 } 55 34 56 public override void Execute Remote (string _sender, string[] _params)35 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 57 36 { 58 37 try { 59 this.m_Console.SendResult (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 60 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 61 RunInternal (ci, _params); 62 } catch (Exception e) { 63 Log.Out ("Error in SayToPlayer.ExecuteRemote: " + e); 64 } 65 } 66 67 public override void Run (string[] _params) 68 { 69 try { 70 RunInternal (null, _params); 38 if (_senderInfo.RemoteClientInfo != null) { 39 RunInternal (_senderInfo.RemoteClientInfo, _params); 40 } else { 41 RunInternal (null, _params); 42 } 71 43 } catch (Exception e) { 72 44 Log.Out ("Error in SayToPlayer.Run: " + e); -
binary-improvements/AllocsCommands/Commands/ShowInventory.cs
r224 r230 5 5 namespace AllocsFixes.CustomCommands 6 6 { 7 public class ShowInventory : ConsoleC ommand7 public class ShowInventory : ConsoleCmdAbstract 8 8 { 9 public ShowInventory (ConsoleSdtd cons) : base(cons) 10 { 11 } 12 13 public override string Description () 9 public override string GetDescription () 14 10 { 15 11 return "list inventory of a given player (steam id, entity id or name)"; 16 12 } 17 13 18 public override string[] Names ()14 public override string[] GetCommands () 19 15 { 20 16 return new string[] { "showinventory", "si" }; 21 17 } 22 18 23 public override void Run (string[] _params)19 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 24 20 { 25 21 try { 26 if (_params. Length< 1) {27 m_Console.SendResult ("Usage: showinventory <steamid|playername|entityid>");22 if (_params.Count < 1) { 23 SdtdConsole.Instance.Output ("Usage: showinventory <steamid|playername|entityid>"); 28 24 return; 29 25 } … … 31 27 string steamid = PersistentContainer.Instance.Players.GetSteamID (_params [0], true); 32 28 if (steamid == null) { 33 m_Console.SendResult ("Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s).");29 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s)."); 34 30 return; 35 31 } … … 38 34 PersistentData.Inventory inv = p.Inventory; 39 35 40 m_Console.SendResult ("Belt of player " + p.Name + ":");36 SdtdConsole.Instance.Output ("Belt of player " + p.Name + ":"); 41 37 for (int i = 0; i < inv.belt.Count; i++) { 42 38 if (inv.belt [i] != null) 43 m_Console.SendResult (string.Format (" Slot {0}: {1:000} * {2}", i, inv.belt [i].count, inv.belt [i].itemName));39 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, inv.belt [i].count, inv.belt [i].itemName)); 44 40 } 45 m_Console.SendResult (string.Empty);46 m_Console.SendResult ("Bagpack of player " + p.Name + ":");41 SdtdConsole.Instance.Output (string.Empty); 42 SdtdConsole.Instance.Output ("Bagpack of player " + p.Name + ":"); 47 43 for (int i = 0; i < inv.bag.Count; i++) { 48 44 if (inv.bag [i] != null) 49 m_Console.SendResult (string.Format (" Slot {0}: {1:000} * {2}", i, inv.bag [i].count, inv.bag [i].itemName));45 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, inv.bag [i].count, inv.bag [i].itemName)); 50 46 } 51 m_Console.SendResult (string.Empty);47 SdtdConsole.Instance.Output (string.Empty); 52 48 } catch (Exception e) { 53 49 Log.Out ("Error in ShowInventory.Run: " + e); -
binary-improvements/AllocsCommands/Commands/TeleportPlayer.cs
r228 r230 1 using AllocsFixes.PersistentData;2 1 using System; 3 2 using System.Collections.Generic; … … 6 5 namespace AllocsFixes.CustomCommands 7 6 { 8 public class TeleportPlayer : ConsoleC ommand7 public class TeleportPlayer : ConsoleCmdAbstract 9 8 { 10 public TeleportPlayer (ConsoleSdtd cons) : base(cons) 11 { 12 } 13 14 public override string Description () 9 public override string GetDescription () 15 10 { 16 11 return "teleport a player to a given location"; 17 12 } 18 13 19 public override string[] Names ()14 public override string[] GetCommands () 20 15 { 21 16 return new string[] { "teleportplayer", "tele" }; 22 17 } 23 18 24 public override void Run (string[] _params)19 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 25 20 { 26 21 try { 27 if (_params. Length != 4 && _params.Length!= 2) {28 m_Console.SendResult ("Usage: teleportplayer <entityid|playername|steamid> <x> <y> <z>");29 m_Console.SendResult (" or: teleportplayer <entityid|playername|steamid> <target entityid|playername|steamid>");22 if (_params.Count != 4 && _params.Count != 2) { 23 SdtdConsole.Instance.Output ("Usage: teleportplayer <entityid|playername|steamid> <x> <y> <z>"); 24 SdtdConsole.Instance.Output (" or: teleportplayer <entityid|playername|steamid> <target entityid|playername|steamid>"); 30 25 } else { 31 Player p1 = PersistentContainer.Instance.Players.GetPlayerByNameOrId (_params [0], true);32 if ( p1 == null) {33 m_Console.SendResult ("Playername or entity/steamid id not found.");26 ClientInfo ci1 = ConsoleHelper.ParseParamIdOrName (_params [0]); 27 if (ci1 == null) { 28 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found."); 34 29 return; 35 30 } 36 if (!p1.IsOnline) { 37 m_Console.SendResult ("Player not online."); 38 return; 39 } 31 EntityPlayer ep1 = GameManager.Instance.World.Players.dict [ci1.entityId]; 40 32 41 if (_params. Length== 4) {33 if (_params.Count == 4) { 42 34 int x = int.MinValue; 43 35 int y = int.MinValue; … … 49 41 50 42 if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { 51 m_Console.SendResult ("At least one of the given coordinates is not a valid integer");43 SdtdConsole.Instance.Output ("At least one of the given coordinates is not a valid integer"); 52 44 return; 53 45 } 54 46 55 p1.Entity.position.x = x;56 p1.Entity.position.y = y;57 p1.Entity.position.z = z;47 ep1.position.x = x; 48 ep1.position.y = y; 49 ep1.position.z = z; 58 50 } else { 59 Player p2 = PersistentContainer.Instance.Players.GetPlayerByNameOrId (_params [1], true);60 if ( p2 == null) {61 m_Console.SendResult ("Target playername or entity/steamid id not found.");51 ClientInfo ci2 = ConsoleHelper.ParseParamIdOrName (_params [1]); 52 if (ci2 == null) { 53 SdtdConsole.Instance.Output ("Target playername or entity/steamid id not found."); 62 54 return; 63 55 } 64 if (!p2.IsOnline) { 65 m_Console.SendResult ("Target player not online."); 66 return; 67 } 56 EntityPlayer ep2 = GameManager.Instance.World.Players.dict [ci2.entityId]; 68 57 69 p1.Entity.position = p2.Entity.GetPosition();70 p1.Entity.position.y += 1;71 p1.Entity.position.z += 1;58 ep1.position = ep2.GetPosition(); 59 ep1.position.y += 1; 60 ep1.position.z += 1; 72 61 } 73 62 74 NetPackage_EntityTeleport pkg = new NetPackage_EntityTeleport ( p1.Entity);63 NetPackage_EntityTeleport pkg = new NetPackage_EntityTeleport (ep1); 75 64 76 ConnectionManager.Instance.SendPackage (pkg, new PackageDestinationSingleEntityID (p1.ClientInfo.entityId));65 ci1.netConnection [0].AddToSendQueue (pkg); 77 66 } 78 67 } catch (Exception e) {
Note:
See TracChangeset
for help on using the changeset viewer.