Esempio n. 1
0
        public void ServerAddChatRecord(string message, string playerId, string adminId = "")
        {
            if (!serverAdminPlayerChatLogs.ContainsKey(playerId))
            {
                serverAdminPlayerChatLogs.Add(playerId, new List <AdminChatMessage>());
            }

            var entry = new AdminChatMessage
            {
                fromUserid = playerId,
                Message    = message
            };

            if (!string.IsNullOrEmpty(adminId))
            {
                entry.fromUserid   = adminId;
                entry.wasFromAdmin = true;
            }
            serverAdminPlayerChatLogs[playerId].Add(entry);
            AdminPlayerChatUpdateMessage.SendSingleEntryToAdmins(entry, playerId);
            if (!string.IsNullOrEmpty(adminId))
            {
                AdminChatNotifications.SendToAll(playerId, AdminChatWindow.AdminPlayerChat, 0, true);
            }
            else
            {
                AdminChatNotifications.SendToAll(playerId, AdminChatWindow.AdminPlayerChat, 1);
            }

            ServerMessageRecording(playerId, entry);
        }
Esempio n. 2
0
        void ServerMessageRecording(string playerId, AdminChatMessage entry)
        {
            var chatlogDir = Path.Combine(Application.streamingAssetsPath, "chatlogs");

            if (!Directory.Exists(chatlogDir))
            {
                Directory.CreateDirectory(chatlogDir);
            }

            var filePath = Path.Combine(chatlogDir, $"{playerId}.txt");

            var connectedPlayer = PlayerList.Instance.GetByUserID(playerId);

            if (!File.Exists(filePath))
            {
                var stream = File.Create(filePath);
                stream.Close();
                string header = $"Username: {connectedPlayer.Username} Player Name: {connectedPlayer.Name} \r\n" +
                                $"IsAntag: {PlayerList.Instance.AntagPlayers.Contains(connectedPlayer)}  role: {connectedPlayer.Job} \r\n" +
                                $"-----Chat Log----- \r\n" +
                                $" \r\n";
                File.AppendAllText(filePath, header);
            }

            string entryName = connectedPlayer.Name;

            if (entry.wasFromAdmin)
            {
                var adminPlayer = PlayerList.Instance.GetByUserID(entry.fromUserid);
                entryName = "[A] " + adminPlayer.Name;
            }

            File.AppendAllText(filePath, $"[{DateTime.Now.ToString("O")}] {entryName}: {entry.Message}");
        }
		public void ServerAddChatRecord(string message, string userId)
		{
			var entry = new AdminChatMessage
			{
				fromUserid = userId,
				Message = message
			};

			serverAdminChatLogs.Add(entry);
			AdminChatUpdateMessage.SendSingleEntryToAdmins(entry);
			AdminChatNotifications.SendToAll(NotificationKey, AdminChatWindow.AdminToAdminChat, 1);
		}
        public void OnInputSend(string message)
        {
            var adminMsg = new AdminChatMessage
            {
                fromUserid   = ServerData.UserID,
                Message      = message,
                wasFromAdmin = true
            };

            var msg = $"{ServerData.Auth.CurrentUser.DisplayName}: {message}";

            RequestAdminChatMessage.Send(ServerData.UserID, PlayerList.Instance.AdminToken, msg);
        }