public MyObjectBuilder_Checkpoint.PlayerItem GetPlayerItemFromPlayerId(long playerId)
        {
            MyObjectBuilder_Checkpoint.PlayerItem playerItem = new MyObjectBuilder_Checkpoint.PlayerItem();

            try
            {
                Dictionary <long, InternalPlayerItem> playerDictionary = InternalGetPlayerDictionary();
                if (!playerDictionary.ContainsKey(playerId))
                {
                    return(playerItem);
                }

                InternalPlayerItem item = playerDictionary[playerId];
                playerItem.PlayerId = item.PlayerId;
                playerItem.SteamId  = item.SteamId;
                playerItem.Name     = item.Name;
                playerItem.Model    = item.Model;
                playerItem.IsDead   = item.IsDead;
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
            }

            return(playerItem);
        }
        protected Dictionary <long, InternalPlayerItem> InternalGetPlayerDictionary()
        {
            Dictionary <long, InternalPlayerItem> result = new Dictionary <long, InternalPlayerItem>();

            Dictionary <long, InternalClientItem>   allSteamList;
            Dictionary <long, InternalIdentityItem> allPlayerList;

            InternalGetReferenceLists(out allSteamList, out allPlayerList);

            foreach (KeyValuePair <long, InternalIdentityItem> p in allPlayerList)
            {
                InternalPlayerItem item = new InternalPlayerItem();
                item.IsDead   = false;
                item.Model    = p.Value.Model;
                item.Name     = p.Value.Name;
                item.PlayerId = p.Value.PlayerId;
                item.SteamId  = 0;
                if (allSteamList.ContainsKey(p.Value.PlayerId))
                {
                    item.SteamId = allSteamList[p.Value.PlayerId].SteamId;
                }

                if (result.ContainsKey(item.PlayerId))
                {
                    result[item.PlayerId] = item;
                }
                else
                {
                    result.Add(item.PlayerId, item);
                }
            }

            return(result);
        }
        public List <long> GetPlayerIdsFromSteamId(ulong steamId, bool ignoreDead = true)
        {
            List <long> matchingPlayerIds = new List <long>();

            try
            {
                Dictionary <long, Object> allPlayers = InternalGetPlayerItemMappping();
                foreach (var entry in allPlayers)
                {
                    InternalPlayerItem internalPlayerItem = new InternalPlayerItem(entry.Value);
                    if (ignoreDead && internalPlayerItem.isDead)
                    {
                        continue;
                    }

                    if (internalPlayerItem.steamId == steamId)
                    {
                        matchingPlayerIds.Add(entry.Key);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
            }

            return(matchingPlayerIds);
        }
        public MyObjectBuilder_Checkpoint.PlayerItem GetPlayerItemFromPlayerId(long playerId)
        {
            MyObjectBuilder_Checkpoint.PlayerItem playerItem = new MyObjectBuilder_Checkpoint.PlayerItem();

            try
            {
                Dictionary <long, Object> allPlayers = InternalGetPlayerItemMappping();
                if (!allPlayers.ContainsKey(playerId))
                {
                    return(playerItem);
                }
                Object             item = allPlayers[playerId];
                InternalPlayerItem internalPlayerItem = new InternalPlayerItem(item);
                playerItem.PlayerId = playerId;
                playerItem.SteamId  = internalPlayerItem.steamId;
                playerItem.Name     = internalPlayerItem.name;
                playerItem.Model    = internalPlayerItem.model;
                playerItem.IsDead   = internalPlayerItem.isDead;
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
            }

            return(playerItem);
        }
Exemple #5
0
        protected List <InternalPlayerItem> InternalGetPlayerList()
        {
            try
            {
                Dictionary <long, InternalClientItem>   allSteamList;
                Dictionary <long, InternalIdentityItem> allPlayerList;
                InternalGetReferenceLists(out allSteamList, out allPlayerList);

                List <InternalPlayerItem> result = new List <InternalPlayerItem>();
                foreach (KeyValuePair <long, InternalIdentityItem> p in allPlayerList)
                {
                    for (int x = 0; x < result.Count; x++)
                    {
                        InternalPlayerItem test = result[x];
                        if (test.Name == p.Value.Name)
                        {
                            test.IsDead = true;
                        }
                    }

                    InternalPlayerItem item = new InternalPlayerItem();
                    item.IsDead   = false;
                    item.Model    = p.Value.Model;
                    item.Name     = p.Value.Name;
                    item.PlayerId = p.Value.PlayerId;
                    item.SteamId  = 0;
                    InternalClientItem internalClientItem;
                    if (allSteamList.TryGetValue(p.Value.PlayerId, out internalClientItem))
                    {
                        item.SteamId = internalClientItem.SteamId;
                    }

                    result.Add(item);
                }

                return(result);
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex.ToString());
                return(new List <InternalPlayerItem>());
            }
        }
        protected List <InternalPlayerItem> InternalGetPlayerList()
        {
            try
            {
                Dictionary <long, InternalClientItem>   allSteamList;
                Dictionary <long, InternalIdentityItem> allPlayerList;
                InternalGetReferenceLists(out allSteamList, out allPlayerList);

                List <InternalPlayerItem> result = new List <InternalPlayerItem>();
                foreach (KeyValuePair <long, InternalIdentityItem> p in allPlayerList)
                {
                    for (int x = 0; x < result.Count; x++)
                    {
                        InternalPlayerItem test = result[x];
                        if (test.name == p.Value.name)
                        {
                            test.isDead = true;
                        }
                    }

                    InternalPlayerItem item = new InternalPlayerItem();
                    item.isDead   = false;
                    item.model    = p.Value.model;
                    item.name     = p.Value.name;
                    item.playerId = p.Value.playerId;
                    item.steamId  = 0;
                    if (allSteamList.ContainsKey(p.Value.playerId))
                    {
                        item.steamId = allSteamList[p.Value.playerId].SteamId;
                    }

                    result.Add(item);
                }

                return(result);
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex.ToString());
                return(new List <InternalPlayerItem>());
            }
        }
		public List<long> GetPlayerIdsFromSteamId(ulong steamId, bool ignoreDead = true)
		{
			List<long> matchingPlayerIds = new List<long>();

			try
			{
				Dictionary<long, Object> allPlayers = InternalGetPlayerItemMappping();
				foreach (var entry in allPlayers)
				{
					InternalPlayerItem internalPlayerItem = new InternalPlayerItem(entry.Value);
					if (ignoreDead && internalPlayerItem.isDead)
						continue;

					if (internalPlayerItem.steamId == steamId)
						matchingPlayerIds.Add(entry.Key);
				}
			}
			catch (Exception ex)
			{
				LogManager.ErrorLog.WriteLine(ex);
			}

			return matchingPlayerIds;
		}
		public MyObjectBuilder_Checkpoint.PlayerItem GetPlayerItemFromPlayerId(long playerId)
		{
			MyObjectBuilder_Checkpoint.PlayerItem playerItem = new MyObjectBuilder_Checkpoint.PlayerItem();

			try
			{
				Dictionary<long, Object> allPlayers = InternalGetPlayerItemMappping();
				if (!allPlayers.ContainsKey(playerId))
					return playerItem;
				Object item = allPlayers[playerId];
				InternalPlayerItem internalPlayerItem = new InternalPlayerItem(item);
				playerItem.PlayerId = playerId;
				playerItem.SteamId = internalPlayerItem.steamId;
				playerItem.Name = internalPlayerItem.name;
				playerItem.Model = internalPlayerItem.model;
				playerItem.IsDead = internalPlayerItem.isDead;
			}
			catch (Exception ex)
			{
				LogManager.ErrorLog.WriteLine(ex);
			}

			return playerItem;
		}