- Timestamp:
- Oct 23, 2014, 3:09:29 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/CustomCommands/ListLandProtection.cs
r146 r202 20 20 } 21 21 22 public override void ExecuteRemote (string _sender, string[] _params) 23 { 24 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; 31 } 32 Run (_params); 33 } catch (Exception e) { 34 Log.Out ("Error in ListLandProtection.ExecuteRemote: " + e); 35 } 36 } 37 22 38 public override void Run (string[] _params) 23 39 { … … 28 44 bool summaryOnly = false; 29 45 string steamIdFilter = string.Empty; 46 Vector3i closeTo = default(Vector3i); 47 bool onlyCloseToPlayer = false; 48 int closeToDistance = 32; 30 49 31 50 if (_params.Length == 1) { … … 45 64 } 46 65 } 66 } else if (_params.Length >= 2) { 67 if (_params [0].ToLower ().Equals ("nearby")) { 68 try { 69 if (_params.Length == 3) { 70 if (!int.TryParse (_params[1], out closeToDistance)) { 71 m_Console.SendResult ("Given radius is not an integer!"); 72 } 73 } 74 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_params [_params.Length - 1]); 75 EntityPlayer ep = CommonMappingFunctions.GetEntityPlayer (ci); 76 closeTo = new Vector3i (ep.GetPosition ()); 77 onlyCloseToPlayer = true; 78 } catch (Exception e) { 79 m_Console.SendResult ("Error getting current player's position"); 80 Log.Out ("Error in ListLandProtection.Run: " + e); 81 } 82 } else { 83 m_Console.SendResult ("Illegal parameter list"); 84 return; 85 } 47 86 } 48 87 … … 51 90 Dictionary<PersistentPlayerData, List<Vector3i>> owners = new Dictionary<PersistentPlayerData, List<Vector3i>> (); 52 91 foreach (KeyValuePair<Vector3i, PersistentPlayerData> kvp in d) { 53 if (!owners.ContainsKey (kvp.Value)) { 54 owners.Add (kvp.Value, new List<Vector3i> ()); 92 if (!onlyCloseToPlayer || (Math.Abs (kvp.Key.x - closeTo.x) <= closeToDistance && Math.Abs (kvp.Key.z - closeTo.z) <= closeToDistance)) { 93 if (!owners.ContainsKey (kvp.Value)) { 94 owners.Add (kvp.Value, new List<Vector3i> ()); 95 } 96 owners [kvp.Value].Add (kvp.Key); 55 97 } 56 owners [kvp.Value].Add (kvp.Key);57 98 } 58 99 59 100 foreach (KeyValuePair<PersistentPlayerData, List<Vector3i>> kvp in owners) { 60 101 if (steamIdFilter.Length == 0 || kvp.Key.PlayerId.Equals (steamIdFilter)) { 61 string name = PersistentData.PersistentContainer.Instance.Players [kvp.Key.PlayerId].Name;102 string name = PersistentData.PersistentContainer.Instance.Players [kvp.Key.PlayerId].Name; 62 103 name += " (" + kvp.Key.PlayerId + ")"; 63 104
Note:
See TracChangeset
for help on using the changeset viewer.