예제 #1
0
        public override void Execute()
        {
            RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(base.UserId);
            if (playerTeam == null)
            {
                SendError("no_team");
                return;
            }
            AppResponse appResponse = Pool.Get <AppResponse>();

            appResponse.teamChat          = Pool.Get <AppTeamChat>();
            appResponse.teamChat.messages = Pool.GetList <AppChatMessage>();
            IReadOnlyList <ChatLog.Entry> history = Server.TeamChat.GetHistory(playerTeam.teamID);

            if (history != null)
            {
                foreach (ChatLog.Entry item in history)
                {
                    AppChatMessage appChatMessage = Pool.Get <AppChatMessage>();
                    appChatMessage.steamId = item.SteamId;
                    appChatMessage.name    = item.Name;
                    appChatMessage.message = item.Message;
                    appChatMessage.color   = item.Color;
                    appChatMessage.time    = item.Time;
                    appResponse.teamChat.messages.Add(appChatMessage);
                }
            }
            Send(appResponse);
        }
예제 #2
0
        public static void BroadcastTeamChat(this RelationshipManager.PlayerTeam team, ulong steamId, string name, string message, string color)
        {
            uint current = (uint)Epoch.Current;

            Server.TeamChat.Record(team.teamID, steamId, name, message, color, current);
            AppBroadcast appBroadcast = Facepunch.Pool.Get <AppBroadcast>();

            appBroadcast.teamMessage         = Facepunch.Pool.Get <AppTeamMessage>();
            appBroadcast.teamMessage.message = Facepunch.Pool.Get <AppChatMessage>();
            appBroadcast.ShouldPool          = false;
            AppChatMessage message2 = appBroadcast.teamMessage.message;

            message2.steamId = steamId;
            message2.name    = name;
            message2.message = message;
            message2.color   = color;
            message2.time    = current;
            foreach (ulong member in team.members)
            {
                Server.Broadcast(new PlayerTarget(member), appBroadcast);
            }
            appBroadcast.ShouldPool = true;
            appBroadcast.Dispose();
        }