private static List <AdminPlayerEntryData> GetAllPlayerStates(string adminID)
    {
        var playerList = new List <AdminPlayerEntryData>();

        if (string.IsNullOrEmpty(adminID))
        {
            return(playerList);
        }

        var checkMessages = PlayerList.Instance.CheckAdminInbox(adminID);

        foreach (var player in PlayerList.Instance.AllPlayers)
        {
            if (player == null)
            {
                continue;
            }
            if (player.Connection == null)
            {
                continue;
            }

            var entry = new AdminPlayerEntryData();
            entry.name        = player.Name;
            entry.uid         = player.UserId;
            entry.currentJob  = player.Job.ToString();
            entry.accountName = player.Username;
            entry.ipAddress   = player.Connection.address;
            if (player.Script != null && player.Script.playerHealth != null)
            {
                entry.isAlive = player.Script.playerHealth.ConsciousState != ConsciousState.DEAD;
            }
            else
            {
                entry.isAdmin = false;
            }
            entry.isAntag  = PlayerList.Instance.AntagPlayers.Contains(player);
            entry.isAdmin  = PlayerList.Instance.IsAdmin(player.UserId);
            entry.isOnline = true;

            foreach (var msg in checkMessages)
            {
                if (msg.fromUserid == entry.uid)
                {
                    entry.newMessages.Add(msg);
                }
            }

            playerList.Add(entry);
        }

        return(playerList.OrderBy(p => p.name).ThenBy(p => p.isOnline).ToList());
    }
Exemple #2
0
        private static List <AdminPlayerEntryData> GetAllPlayerStates(string adminID)
        {
            var playerList = new List <AdminPlayerEntryData>();

            if (string.IsNullOrEmpty(adminID))
            {
                return(playerList);
            }
            var ToSearchThrough = PlayerList.Instance.AllPlayers.ToList();

            ToSearchThrough.AddRange(PlayerList.Instance.loggedOff);
            foreach (var player in ToSearchThrough)
            {
                if (player == null)
                {
                    continue;
                }
                //if (player.Connection == null) continue;

                var entry = new AdminPlayerEntryData();
                entry.name        = player.Name;
                entry.uid         = player.UserId;
                entry.currentJob  = player.Job.ToString();
                entry.accountName = player.Username;
                if (player.Connection != null)
                {
                    entry.ipAddress = player.Connection.address;
                }

                if (player.Script != null && player.Script.playerHealth != null)
                {
                    entry.isAlive = player.Script.playerHealth.ConsciousState != ConsciousState.DEAD;
                }
                else
                {
                    entry.isAdmin = false;
                }
                entry.isAntag  = PlayerList.Instance.AntagPlayers.Contains(player);
                entry.isAdmin  = PlayerList.Instance.IsAdmin(player.UserId);
                entry.isOnline = true;

                playerList.Add(entry);
            }

            return(playerList.OrderBy(p => p.name).ThenBy(p => p.isOnline).ToList());
        }