Changeset 103 for binary-improvements/7dtd-server-fixes
- Timestamp:
- Jul 24, 2014, 3:25:58 PM (10 years ago)
- Location:
- binary-improvements/7dtd-server-fixes
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/7dtd-server-fixes.csproj
r96 r103 36 36 <HintPath>..\assembly-patcher\bin\Release\UnityEngine.dll</HintPath> 37 37 </Reference> 38 <Reference Include="SteamworksManaged"> 39 <HintPath>bin\Release\SteamworksManaged.dll</HintPath> 40 </Reference> 38 41 </ItemGroup> 39 42 <ItemGroup> … … 51 54 <Compile Include="src\PlayerDataStuff.cs" /> 52 55 <Compile Include="src\CommandExtensions.cs" /> 56 <Compile Include="src\CommonMappingFunctions.cs" /> 53 57 </ItemGroup> 54 58 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
binary-improvements/7dtd-server-fixes/src/AdminToolsStuff.cs
r86 r103 6 6 public static string[] GetAllowedCommandsList (AdminTools admTools, string _steamID) 7 7 { 8 AdminToolsClientInfo tmpInfo = admTools.GetClientCommandInfo (_steamID);9 10 List<AdminToolsCommandPermissions> perms = admTools.commandPermissions;11 8 List<string> allowed = new List<string> (); 12 9 13 ConsoleSdtd console = ConnectionManager.Instance.gameManager.m_GUIConsole; 10 try { 11 AdminToolsClientInfo tmpInfo = admTools.GetClientCommandInfo (_steamID); 14 12 15 foreach (AdminToolsCommandPermissions atcp in perms) { 16 if (tmpInfo.SteamID != null && tmpInfo.SteamID.Length > 0) { 17 if ((atcp.PermissionLevel >= tmpInfo.PermissionLevel) || (atcp.PermissionLevel >= 1000)) { 18 addAllowed (console, allowed, atcp.Command); 19 } 20 } else { 21 if (atcp.PermissionLevel >= 1000) { 22 addAllowed (console, allowed, atcp.Command); 13 List<AdminToolsCommandPermissions> perms = admTools.commandPermissions; 14 ConsoleSdtd console = CommonMappingFunctions.GetGameManager ().m_GUIConsole; 15 16 foreach (AdminToolsCommandPermissions atcp in perms) { 17 if (tmpInfo.SteamID != null && tmpInfo.SteamID.Length > 0) { 18 if ((atcp.PermissionLevel >= tmpInfo.PermissionLevel) || (atcp.PermissionLevel >= 1000)) { 19 addAllowed (console, allowed, atcp.Command); 20 } 21 } else { 22 if (atcp.PermissionLevel >= 1000) { 23 addAllowed (console, allowed, atcp.Command); 24 } 23 25 } 24 26 } 27 } catch (Exception e) { 28 Log.Out ("Error in GetAllowedCommandsList: " + e); 25 29 } 30 26 31 27 32 return allowed.ToArray (); -
binary-improvements/7dtd-server-fixes/src/AllocsLogFunctions.cs
r83 r103 7 7 public static void RequestToSpawnPlayer (GameManager manager, int _clientId, string _name, string _playerClassname, string _skinTexture, int _chunkViewDim) 8 8 { 9 string ip = manager.connectionManager.connectedClients [_clientId].networkPlayer.ipAddress; 10 string name = string.Empty; 11 int entityId = -1; 12 Dictionary<int,int> d = manager.connectionManager.mapClientToEntity; 13 if (d.ContainsKey (_clientId)) { 14 entityId = d [_clientId]; 15 World w = manager.World; 16 name = w.playerEntities.dict [entityId].EntityName; 9 try { 10 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromClientID (_clientId); 11 int entityId = CommonMappingFunctions.GetEntityID (ci); 12 EntityPlayer ep = CommonMappingFunctions.GetEntityPlayer (ci); 13 14 string ip = ci.networkPlayer.ipAddress; 15 string name = string.Empty; 16 17 if (ep != null) 18 name = ep.EntityName; 19 20 Log.Out ("Player connected, clientid=" + _clientId + 21 ", entityid=" + entityId + 22 ", name=" + name + 23 ", steamid=" + CommonMappingFunctions.GetSteamID (ci) + 24 ", ip=" + ip 25 ); 26 } catch (Exception e) { 27 Log.Out ("Error in RequestToSpawnPlayer: " + e); 17 28 } 18 19 Log.Out ("Player connected, clientid=" + _clientId +20 ", entityid=" + entityId +21 ", name=" + name +22 ", steamid=" + SingletonMonoBehaviour<Authenticator>.Instance.GetPlayerId (name) +23 ", ip=" + ip24 );25 29 } 26 30 -
binary-improvements/7dtd-server-fixes/src/AllocsNetTelnetServer.cs
r96 r103 18 18 public static void init (int port) 19 19 { 20 Log.Out ("[7dtd-server-fixes by Alloc] Version: " + Assembly.GetExecutingAssembly ().GetName ().Version); 21 authEnabled = GamePrefs.GetString (EnumGamePrefs.TelnetPassword).Length != 0; 22 if (authEnabled) 23 listener = new TcpListener (IPAddress.Any, port); 24 else 25 listener = new TcpListener (IPAddress.Loopback, port); 26 telnetThread = ThreadMaster.Create ("thread Allocs TelnetListenThread", new ThreadStart (telnetListenThread)); 27 telnetThread.Start (); 28 Log.Out ("Started Allocs NetTelnetServer thread on " + port); 20 try { 21 Log.Out ("[7dtd-server-fixes by Alloc] Version: " + Assembly.GetExecutingAssembly ().GetName ().Version); 22 authEnabled = GamePrefs.GetString (EnumGamePrefs.TelnetPassword).Length != 0; 23 if (authEnabled) 24 listener = new TcpListener (IPAddress.Any, port); 25 else 26 listener = new TcpListener (IPAddress.Loopback, port); 27 telnetThread = ThreadMaster.Create ("thread Allocs TelnetListenThread", new ThreadStart (telnetListenThread)); 28 telnetThread.Start (); 29 Log.Out ("Started Allocs NetTelnetServer thread on " + port); 30 } catch (Exception e) { 31 Log.Out ("Error in AllocsTelnetServer.init: " + e); 32 } 29 33 } 30 34 … … 90 94 { 91 95 c.WriteLine ("*** Connected with 7DTD server."); 92 c.WriteLine ("*** Server version: Alpha 8.7 (b29) Compatibility Version: Alpha 8.7");96 c.WriteLine ("*** Dedicated server only build"); 93 97 c.WriteLine ("*** Allocs server fixes loaded"); 94 98 c.WriteLine (string.Empty); … … 120 124 public static void Disconnect () 121 125 { 122 closed = true; 123 if (listener != null) { 124 listener.Stop (); 126 try { 127 closed = true; 128 if (listener != null) { 129 listener.Stop (); 130 } 131 foreach (AllocsTelnetConnection c in connections) { 132 c.Close (); 133 } 134 Thread.Sleep (100); 135 } catch (Exception e) { 136 Log.Out ("Error in AllocsTelnetServer.Disconnect: " + e); 125 137 } 126 foreach (AllocsTelnetConnection c in connections) {127 c.Close ();128 }129 Thread.Sleep (100);130 138 } 131 139 132 140 public static void SetConsole (ConsoleSdtd console) 133 141 { 134 Log.Out ("Telnet SetConsole called");142 Log.Out ("Telnet SetConsole called"); 135 143 AllocsNetTelnetServer.console = console; 136 144 } … … 138 146 private static void RemoveClosedConnections () 139 147 { 140 foreach (AllocsTelnetConnection c in connections) { 141 if (c.IsClosed ()) { 142 c.Close (); 148 try { 149 foreach (AllocsTelnetConnection c in connections) { 150 if (c.IsClosed ()) { 151 c.Close (); 152 } 143 153 } 154 } catch (Exception e) { 155 Log.Out ("Error in AllocsTelnetServer.RemvoeClosedConnections: " + e); 144 156 } 145 157 } -
binary-improvements/7dtd-server-fixes/src/AllocsTelnetConnection.cs
r91 r103 39 39 WriteByte ((byte)s [i]); 40 40 } 41 WriteByte(13); 41 42 WriteByte (10); 42 43 } -
binary-improvements/7dtd-server-fixes/src/PlayerDataStuff.cs
r98 r103 13 13 foreach (InventoryField item in _belt) { 14 14 if (item.count > 0) { 15 string name = getInvFieldName (item);16 if (belt.ContainsKey (name)) {17 belt [name] += item.count;15 string name = getInvFieldName (item); 16 if (belt.ContainsKey (name)) { 17 belt [name] += item.count; 18 18 } else { 19 19 belt.Add (name, item.count); … … 24 24 foreach (InventoryField item in _bag) { 25 25 if (item.count > 0) { 26 string name = getInvFieldName (item);27 if (bag.ContainsKey (name)) {28 bag [name] += item.count;26 string name = getInvFieldName (item); 27 if (bag.ContainsKey (name)) { 28 bag [name] += item.count; 29 29 } else { 30 30 bag.Add (name, item.count); … … 47 47 public static void GM_SavePlayerData (GameManager manager, int _clientId, PlayerDataFile _playerDataFile) 48 48 { 49 if (manager.connectionManager.mapClientToEntity.ContainsKey (_clientId)) { 50 int entityId = manager.connectionManager.mapClientToEntity [_clientId]; 51 Log.Out ("Saving playerData for entity id: " + entityId); 49 try { 50 int entityId = CommonMappingFunctions.GetEntityID (CommonMappingFunctions.GetClientInfoFromClientID (_clientId)); 51 if (entityId >= 0) { 52 Log.Out ("Saving playerData for entity id: " + entityId); 52 53 53 if (itemsPerEntityId.ContainsKey(entityId)) 54 itemsPerEntityId.Remove(entityId); 55 itemsPerEntityId.Add (entityId, new PlayerItems (_playerDataFile.inventory, _playerDataFile.bag)); 54 if (itemsPerEntityId.ContainsKey (entityId)) 55 itemsPerEntityId.Remove (entityId); 56 itemsPerEntityId.Add (entityId, new PlayerItems (_playerDataFile.inventory, _playerDataFile.bag)); 57 } 58 } catch (Exception e) { 59 Log.Out ("Error in GM_SavePlayerData: " + e); 56 60 } 57 61 /* -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/GetGamePrefs.cs
r91 r103 45 45 public override void Run (string[] _params) 46 46 { 47 EnumGamePrefs enumGamePrefs = EnumGamePrefs.Last; 47 try { 48 EnumGamePrefs enumGamePrefs = EnumGamePrefs.Last; 48 49 49 if (_params.Length > 0) { 50 try { 51 enumGamePrefs = (EnumGamePrefs)((int)Enum.Parse (typeof(EnumGamePrefs), _params [0])); 52 } catch (Exception) { 50 if (_params.Length > 0) { 51 try { 52 enumGamePrefs = (EnumGamePrefs)((int)Enum.Parse (typeof(EnumGamePrefs), _params [0])); 53 } catch (Exception) { 54 } 53 55 } 54 }55 56 56 if (enumGamePrefs == EnumGamePrefs.Last) { 57 SortedList<string, string> sortedList = new SortedList<string, string> (); 58 foreach (EnumGamePrefs gp in Enum.GetValues(typeof(EnumGamePrefs))) { 59 if ((_params.Length == 0) || (gp.ToString ().ToLower ().Contains (_params [0].ToLower ()))) { 60 if (prefAccessAllowed (gp)) { 61 sortedList.Add (gp.ToString (), string.Format ("{0} = {1}", gp.ToString (), GamePrefs.GetObject (gp))); 57 if (enumGamePrefs == EnumGamePrefs.Last) { 58 SortedList<string, string> sortedList = new SortedList<string, string> (); 59 foreach (EnumGamePrefs gp in Enum.GetValues(typeof(EnumGamePrefs))) { 60 if ((_params.Length == 0) || (gp.ToString ().ToLower ().Contains (_params [0].ToLower ()))) { 61 if (prefAccessAllowed (gp)) { 62 sortedList.Add (gp.ToString (), string.Format ("{0} = {1}", gp.ToString (), GamePrefs.GetObject (gp))); 63 } 62 64 } 63 65 } 66 foreach (string s in sortedList.Keys) { 67 m_Console.md000a (sortedList [s]); 68 } 69 } else { 70 if (prefAccessAllowed (enumGamePrefs)) 71 m_Console.md000a (string.Format ("{0} = {1}", enumGamePrefs, GamePrefs.GetObject (enumGamePrefs))); 72 else 73 m_Console.md000a ("Access to requested preference is forbidden"); 64 74 } 65 foreach (string s in sortedList.Keys) { 66 m_Console.md000a (sortedList [s]); 67 } 68 } else { 69 if (prefAccessAllowed (enumGamePrefs)) 70 m_Console.md000a (string.Format ("{0} = {1}", enumGamePrefs, GamePrefs.GetObject (enumGamePrefs))); 71 else 72 m_Console.md000a ("Access to requested preference is forbidden"); 75 } catch (Exception e) { 76 Log.Out ("Error in GetGamePrefs.Run: " + e); 73 77 } 74 78 } -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/GetTime.cs
r84 r103 19 19 public override void Run (string[] _params) 20 20 { 21 ulong time = this.m_Console.gameManager.World.gameTime; 22 int day = (int)(time / 24000) + 1; 23 int hour = (int)(time % 24000) / 1000 + 8; 24 if (hour > 23) { 25 day++; 26 hour -= 24; 21 try { 22 ulong time = this.m_Console.gameManager.World.gameTime; 23 int day = (int)(time / 24000) + 1; 24 int hour = (int)(time % 24000) / 1000 + 8; 25 if (hour > 23) { 26 day++; 27 hour -= 24; 28 } 29 int min = (int)(time % 1000) * 60 / 1000; 30 m_Console.md000a (String.Format ("Day {0}, {1:00}:{2:00} ", day, hour, min)); 31 } catch (Exception e) { 32 Log.Out ("Error in GetTime.Run: " + e); 27 33 } 28 int min = (int)(time % 1000) * 60 / 1000;29 m_Console.md000a (String.Format ("Day {0}, {1:00}:{2:00} ", day, hour, min));30 34 } 31 35 } -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/ListPlayersExtended.cs
r91 r103 4 4 public class ListPlayersExtended : ConsoleCommand 5 5 { 6 public ListPlayersExtended(ConsoleSdtd cons) : base(cons) { 6 public ListPlayersExtended (ConsoleSdtd cons) : base(cons) 7 { 7 8 } 8 9 … … 12 13 } 13 14 14 public override string[] Names () { 15 public override string[] Names () 16 { 15 17 return new string[] { "listplayersextended", "lpe" }; 16 18 } … … 18 20 public override void Run (string[] _params) 19 21 { 20 World w = this.m_Console.gameManager.World; 21 int num = 0; 22 foreach (KeyValuePair<int, EntityPlayer> current in w.playerEntities.dict) 23 { 24 int clientId = -1; 25 Dictionary<int,int> d = this.m_Console.gameManager.connectionManager.mapClientToEntity; 26 foreach (KeyValuePair<int, int> mapping in d) { 27 if (mapping.Value == current.Value.fd0087) { 28 clientId = mapping.Key; 22 try { 23 World w = CommonMappingFunctions.GetGameManager ().World; 24 int num = 0; 25 foreach (KeyValuePair<int, EntityPlayer> current in w.playerEntities.dict) { 26 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromEntityID (current.Key); 27 string ip = string.Empty; 28 if (ci != null) { 29 ip = ci.networkPlayer.ipAddress; 29 30 } 30 } 31 string ip = string.Empty; 32 if (clientId >= 0) { 33 ip = this.m_Console.gameManager.connectionManager.connectedClients [clientId].networkPlayer.ipAddress; 34 } 35 m_Console.md000a (string.Concat (new object[] 31 m_Console.md000a (string.Concat (new object[] 36 32 { 37 33 string.Empty, … … 58 54 current.Value.Score, 59 55 ", steamid=", 60 SingletonMonoBehaviour<Authenticator>.Instance.GetPlayerId (current.Value.EntityName),56 CommonMappingFunctions.GetSteamID (ci), 61 57 ", ip=", 62 58 ip, 63 59 ", ping=", 64 60 current.Value.pingToServer 65 })); 61 } 62 ) 63 ); 64 } 65 m_Console.md000a ("Total of " + w.playerEntities.list.Count + " in the game"); 66 } catch (Exception e) { 67 Log.Out ("Error in ListPlayersExtended.Run: " + e); 66 68 } 67 m_Console.md000a ("Total of " + w.playerEntities.list.Count + " in the game");68 69 } 69 70 } -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/SayToPlayer.cs
r83 r103 4 4 public class SayToPlayer : ConsoleCommand 5 5 { 6 private GameManager manager;7 8 6 public SayToPlayer (ConsoleSdtd cons) : base(cons) 9 7 { 10 manager = m_Console.gameManager;11 8 } 12 9 … … 18 15 public override string[] Names () 19 16 { 20 return new string[] { "sayplayer", string.Empty};17 return new string[] { "sayplayer", "pm" }; 21 18 } 22 19 23 public override void Run (string[] _params) 20 private void SendMessage (ClientInfo _receiver, string _sender, string _message) 21 { 22 CommonMappingFunctions.GetConnectionManager ().networkView.RPC ("RPC_ChatMessage", _receiver.networkPlayer, 23 new object[] { _message, -1, _sender + " (PM)", true }); 24 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 25 m_Console.md000a ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + _sender + "\""); 26 } 27 28 private void RunInternal (string _sender, string[] _params) 24 29 { 25 30 if (_params.Length < 2) { … … 33 38 } 34 39 35 int entityId = -1; 36 if (int.TryParse (_params [0], out entityId)) { 37 foreach (KeyValuePair<int, int> kvp in manager.connectionManager.mapClientToEntity) { 38 if (kvp.Value == entityId) { 39 int clientid = kvp.Key; 40 ClientInfo ci = manager.connectionManager.connectedClients[clientid]; 41 if (ci != null) { 42 manager.connectionManager.networkView.RPC ("RPC_ChatMessage", ci.networkPlayer, new object[] { 43 message, 44 -1, 45 "Server (private)", 46 true 47 } 48 ); 49 m_Console.md000a ("Message sent"); 50 return; 51 } 52 } 40 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromNameOrID (_params [0]); 41 if (ci != null) { 42 SendMessage (ci, _sender, message); 43 } else { 44 m_Console.md000a ("Playername or entity ID not found."); 45 } 46 } 47 48 public override void ExecuteRemote (string _sender, string[] _params) 49 { 50 try { 51 this.m_Console.md000a (string.Format ("{0} executing remote command '{1}' {2}", _sender, this.Names () [0], string.Join (" ", _params))); 52 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_sender); 53 if (ci != null) { 54 _sender = CommonMappingFunctions.GetPlayerName (ci); 53 55 } 54 m_Console.md000a ("Entity ID not found."); 55 } else { 56 string destPlayerName = _params [0].ToLower (); 57 foreach (ClientInfo ci in manager.connectionManager.connectedClients.Values) { 58 Dictionary<int,int> d = manager.connectionManager.mapClientToEntity; 59 if (d.ContainsKey (ci.clientId)) { 60 entityId = d [ci.clientId]; 61 string curName = manager.World.playerEntities.dict [entityId].EntityName; 62 if (curName.ToLower ().Equals (destPlayerName)) { 63 manager.connectionManager.networkView.RPC ("RPC_ChatMessage", ci.networkPlayer, new object[] { 64 message, 65 -1, 66 "Server (private)", 67 true 68 } 69 ); 70 m_Console.md000a ("Message sent"); 71 return; 72 } 73 } 74 } 75 m_Console.md000a ("Playername not found."); 56 RunInternal (_sender, _params); 57 } catch (Exception e) { 58 Log.Out ("Error in SayToPlayer.ExecuteRemote: " + e); 59 } 60 } 61 62 public override void Run (string[] _params) 63 { 64 try { 65 RunInternal ("Server", _params); 66 } catch (Exception e) { 67 Log.Out ("Error in SayToPlayer.Run: " + e); 76 68 } 77 69 } -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/SetTimeReal.cs
r84 r103 19 19 public override void Run (string[] _params) 20 20 { 21 if (_params.Length != 3) { 22 m_Console.md000a ("Usage: settimereal <day> <hour> <min>"); 23 return; 21 try { 22 if (_params.Length != 3) { 23 m_Console.md000a ("Usage: settimereal <day> <hour> <min>"); 24 return; 25 } 26 27 int day, hour, min; 28 if (!int.TryParse (_params [0], out day)) { 29 m_Console.md000a ("Could not parse day number \"" + _params [0] + "\""); 30 return; 31 } 32 if (day < 1) { 33 m_Console.md000a ("Day must be >= 1"); 34 return; 35 } 36 if (!int.TryParse (_params [1], out hour)) { 37 m_Console.md000a ("Could not parse hour \"" + _params [1] + "\""); 38 return; 39 } 40 if (hour > 23) { 41 m_Console.md000a ("Hour must be <= 23"); 42 return; 43 } 44 if (!int.TryParse (_params [2], out min)) { 45 m_Console.md000a ("Could not parse minute \"" + _params [2] + "\""); 46 return; 47 } 48 if (min > 59) { 49 m_Console.md000a ("Minute must be <= 59"); 50 return; 51 } 52 if ((day < 1) || (hour < 8 && day < 1)) { 53 m_Console.md000a ("Time may not be prior to day 1, 8:00"); 54 return; 55 } 56 57 ulong time = ((ulong)(day - 1) * 24000) + ((ulong)hour * 1000) + ((ulong)min * 1000 / 60) - 8000; 58 m_Console.gameManager.World.gameTime = time; 59 m_Console.md000a (String.Format ("Set time to Day {0}, {1:00}:{2:00} = {3}", day, hour, min, time)); 60 } catch (Exception e) { 61 Log.Out ("Error in SetTimeReal.Run: " + e); 24 62 } 25 26 int day, hour, min;27 if (!int.TryParse (_params [0], out day)) {28 m_Console.md000a ("Could not parse day number \"" + _params [0] + "\"");29 return;30 }31 if (day < 1) {32 m_Console.md000a ("Day must be >= 1");33 return;34 }35 if (!int.TryParse (_params [1], out hour)) {36 m_Console.md000a ("Could not parse hour \"" + _params [1] + "\"");37 return;38 }39 if (hour > 23) {40 m_Console.md000a ("Hour must be <= 23");41 return;42 }43 if (!int.TryParse (_params [2], out min)) {44 m_Console.md000a ("Could not parse minute \"" + _params [2] + "\"");45 return;46 }47 if (min > 59) {48 m_Console.md000a ("Minute must be <= 59");49 return;50 }51 if ((day < 1) || (hour < 8 && day < 1)) {52 m_Console.md000a ("Time may not be prior to day 1, 8:00");53 return;54 }55 56 ulong time = ((ulong)(day-1) * 24000) + ((ulong)hour * 1000) + ((ulong)min * 1000 / 60) - 8000;57 this.m_Console.gameManager.World.gameTime = time;58 m_Console.md000a (String.Format ("Set time to Day {0}, {1:00}:{2:00} = {3}", day, hour, min, time));59 63 } 60 64 } -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/ShowInventory.cs
r93 r103 23 23 public override void Run (string[] _params) 24 24 { 25 if (_params.Length < 1) { 26 m_Console.md000a ("Usage: showinventory <playername|entityid>"); 27 return; 28 } 25 try { 26 if (_params.Length < 1) { 27 m_Console.md000a ("Usage: showinventory <playername|entityid>"); 28 return; 29 } 29 30 30 int entityId = -1;31 PlayerDataStuff.PlayerItems items = null;32 if (int.TryParse (_params [0], out entityId)) {33 items = PlayerDataStuff.GetPlayerItems (entityId);34 }31 int entityId = -1; 32 PlayerDataStuff.PlayerItems items = null; 33 if (int.TryParse (_params [0], out entityId)) { 34 items = PlayerDataStuff.GetPlayerItems (entityId); 35 } 35 36 36 if (items == null) { 37 string playerName = _params [0].ToLower (); 38 foreach (KeyValuePair<int, EntityPlayer> kvp in manager.World.playerEntities.dict) { 39 if (kvp.Value.EntityName.ToLower ().Equals (playerName)) { 40 entityId = kvp.Key; 41 break; 37 if (items == null) { 38 string playerName = _params [0].ToLower (); 39 foreach (KeyValuePair<int, EntityPlayer> kvp in manager.World.playerEntities.dict) { 40 if (kvp.Value.EntityName.ToLower ().Equals (playerName)) { 41 entityId = kvp.Key; 42 break; 43 } 42 44 } 43 45 } 46 items = PlayerDataStuff.GetPlayerItems (entityId); 47 48 if (items == null) { 49 m_Console.md000a ("Playername or entity id not found or no inventory saved (first saved after a player has been online for 30s)."); 50 return; 51 } 52 53 m_Console.md000a ("Belt of player:"); 54 foreach (KeyValuePair<string, int> kvp in items.belt) { 55 m_Console.md000a (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key)); 56 } 57 m_Console.md000a (string.Empty); 58 m_Console.md000a ("Bagpack of player:"); 59 foreach (KeyValuePair<string, int> kvp in items.bag) { 60 m_Console.md000a (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key)); 61 } 62 m_Console.md000a (string.Empty); 63 } catch (Exception e) { 64 Log.Out ("Error in ShowInventory.Run: " + e); 44 65 } 45 items = PlayerDataStuff.GetPlayerItems (entityId);46 47 if (items == null) {48 m_Console.md000a ("Playername or entity id not found or no inventory saved (first saved after a player has been online for 30s).");49 return;50 }51 52 m_Console.md000a ("Belt of player:");53 foreach (KeyValuePair<string, int> kvp in items.belt) {54 m_Console.md000a (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key));55 }56 m_Console.md000a (string.Empty);57 m_Console.md000a ("Bagpack of player:");58 foreach (KeyValuePair<string, int> kvp in items.bag) {59 m_Console.md000a (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key));60 }61 m_Console.md000a (string.Empty);62 66 } 63 67 }
Note:
See TracChangeset
for help on using the changeset viewer.