Changeset 230 for binary-improvements/AllocsCommands/Commands/Give.cs
- Timestamp:
- Apr 18, 2015, 4:27:57 PM (10 years ago)
- File:
-
- 1 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);
Note:
See TracChangeset
for help on using the changeset viewer.