- Timestamp:
- Aug 26, 2014, 4:41:47 PM (10 years ago)
- Location:
- binary-improvements/7dtd-server-fixes/src/CustomCommands
- Files:
-
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.