コード例 #1
0
        protected override void OnChatMessage(ref ChatMsg msg)
        {
            if (m_memberData.ContainsKey(msg.Author))
            {
                if (m_memberData[msg.Author].IsAdmin)
                {
                    if (msg.Text.ToLower().Contains("+unban"))
                    {
                        string[] parts = msg.Text.Split(' ');
                        if (parts.Length > 1)
                        {
                            ulong user = 0;
                            if (ulong.TryParse(parts[1], out user))
                            {
                                BanClient(user, false);
                            }
                        }
                    }
                    else if (msg.Text.ToLower() == "+reload")
                    {
                        MySandboxGame.ReloadDedicatedServerSession();
                    }
                }
            }

            RaiseChatMessageReceived(msg.Author, msg.Text, ChatEntryTypeEnum.ChatMsg);
        }
コード例 #2
0
        protected static void SendChatMessage(ref ChatMsg msg)
        {
            EndpointId targetEndpoint = new EndpointId();
            Vector3D?  position       = null;

            Sandbox.Engine.Multiplayer.MyMultiplayer.RaiseStaticEvent <ChatMsg>(s => new Action <ChatMsg>(MyMultiplayerBase.OnChatMessageRecieved_Server), msg, targetEndpoint, position);
        }
コード例 #3
0
        void OnChatMessage(ref ChatMsg msg, ulong sender)
        {
            if (m_memberData.ContainsKey(sender))
            {
                if (m_memberData[sender].IsAdmin)
                {
                    if (msg.Text.ToLower() == "+save")
                    {
                        MySession.Static.Save();
                    }
                    else
                    if (msg.Text.ToLower().Contains("+unban"))
                    {
                        string[] parts = msg.Text.Split(' ');
                        if (parts.Length > 1)
                        {
                            ulong user = 0;
                            if (ulong.TryParse(parts[1], out user))
                            {
                                BanClient(user, false);
                            }
                        }
                    }
                }
            }

            RaiseChatMessageReceived(sender, msg.Text, ChatEntryTypeEnum.ChatMsg);
        }
コード例 #4
0
        protected override void OnChatMessage(ref ChatMsg msg, ulong sender)
        {
            bool debugCommands = !MyFinalBuildConstants.IS_OFFICIAL && MyFinalBuildConstants.IS_DEBUG;

            msg.Author = sender;
            if (m_memberData.ContainsKey(sender))
            {
                if (m_memberData[sender].IsAdmin || debugCommands)
                {
                    if (msg.Text.Equals("+save", StringComparison.InvariantCultureIgnoreCase))
                    {
                        MySession.Static.Save();
                    }
                    else if (msg.Text.Contains("+unban", StringComparison.InvariantCultureIgnoreCase))
                    {
                        string[] parts = msg.Text.Split(' ');
                        if (parts.Length > 1)
                        {
                            ulong user = 0;
                            if (ulong.TryParse(parts[1], out user))
                            {
                                BanClient(user, false);
                            }
                        }
                    }
                }
                if (debugCommands)
                {
                    MyServerDebugCommands.Process(msg.Text, msg.Author);
                }
            }

            SendControlMessageToAll(ref msg, msg.Author);
            RaiseChatMessageReceived(sender, msg.Text, ChatEntryTypeEnum.ChatMsg);
        }
コード例 #5
0
        public override void OnChatMessage(ref ChatMsg msg)
        {
            MyMultiplayerBase.MyConnectedClientData data;
            bool flag = false;

            if (base.MemberDataGet(msg.Author, out data) && (data.IsAdmin | flag))
            {
                MyServerDebugCommands.Process(msg.Text, msg.Author);
            }
            string str = Sync.Players.TryGetIdentityNameFromSteamId(msg.Author);

            if (string.IsNullOrEmpty(str) && (msg.Author == Sync.MyId))
            {
                str = MyTexts.GetString(MySpaceTexts.ChatBotName);
            }
            if (!string.IsNullOrEmpty(str))
            {
                MyChatMessage message1 = new MyChatMessage();
                message1.SteamId    = msg.Author;
                message1.AuthorName = string.IsNullOrEmpty(msg.CustomAuthorName) ? str : msg.CustomAuthorName;
                MyChatMessage item = message1;
                item.Text      = msg.Text;
                item.Timestamp = DateTime.UtcNow;
                this.m_globalChatHistory.Add(item);
            }
            this.RaiseChatMessageReceived(msg.Author, msg.Text, (ChatChannel)msg.Channel, msg.TargetId, string.IsNullOrEmpty(msg.CustomAuthorName) ? null : msg.CustomAuthorName);
        }
コード例 #6
0
        public override void SendChatMessage(string text)
        {
            ChatMsg msg = new ChatMsg();

            msg.Text = text;

            SendControlMessageToAllAndSelf(ref msg);
        }
コード例 #7
0
        public override void OnChatMessage(ref ChatMsg msg)
        {
            bool flag = false;

            if (this.m_memberData.ContainsKey(msg.Author) && (this.m_memberData[msg.Author].IsAdmin | flag))
            {
                MyClientDebugCommands.Process(msg.Text, msg.Author);
            }
            this.RaiseChatMessageReceived(msg.Author, msg.Text, (ChatChannel)msg.Channel, msg.TargetId, string.IsNullOrEmpty(msg.CustomAuthorName) ? string.Empty : msg.CustomAuthorName);
        }
コード例 #8
0
        public override void SendChatMessage(string text)
        {
            ChatMsg msg = new ChatMsg();

            msg.Text   = text;
            msg.Author = MySteam.UserId;

            // This will send the message to every client except message author
            OnChatMessage(ref msg, MySteam.UserId);
        }
コード例 #9
0
        public override void SendChatMessage(string text)
        {
            ChatMsg msg = new ChatMsg();

            msg.Text   = text;
            msg.Author = Sync.MyId;

            OnChatMessage(ref msg, MySteam.AppId);
            SendControlMessage(ServerId, ref msg);
        }
コード例 #10
0
        public override void SendChatMessage(string text)
        {
            ChatMsg msg = new ChatMsg();

            msg.Text   = text;
            msg.Author = Sync.MyId;

            SendChatMessage(ref msg);
            // This will send the message to every client except message author
            OnChatMessage(ref msg);
        }
コード例 #11
0
        public override void SendChatMessage(string text)
        {
            ChatMsg msg = new ChatMsg();

            msg.Text   = text;
            msg.Author = Sync.MyId;

            OnChatMessage(ref msg);

            SendChatMessage(ref msg);
        }
コード例 #12
0
        public override void SendChatMessage(string text, ChatChannel channel, long targetId = 0L)
        {
            ChatMsg msg = new ChatMsg {
                Text             = text,
                Author           = Sync.MyId,
                Channel          = (byte)channel,
                TargetId         = targetId,
                CustomAuthorName = string.Empty
            };

            SendChatMessage(ref msg);
        }
コード例 #13
0
        protected override void OnChatMessage(ref ChatMsg msg)
        {
            bool debugCommands = !MyFinalBuildConstants.IS_OFFICIAL && MyFinalBuildConstants.IS_DEBUG;

            if (m_memberData.ContainsKey(msg.Author))
            {
                if (m_memberData[msg.Author].IsAdmin || debugCommands)
                {
                    MyClientDebugCommands.Process(msg.Text, msg.Author);
                }
            }

            RaiseChatMessageReceived(msg.Author, msg.Text, ChatEntryTypeEnum.ChatMsg);
        }
コード例 #14
0
        public override unsafe void SendChatMessageScripted(string text, ChatChannel channel, long targetId = 0L, string customAuthor = null)
        {
            ChatMsg *msgPtr1;
            ChatMsg  msg = new ChatMsg {
                Text     = text,
                Author   = Sync.MyId,
                Channel  = (byte)channel,
                TargetId = targetId
            };

            msgPtr1->CustomAuthorName = string.IsNullOrEmpty(customAuthor) ? string.Empty : customAuthor;
            msgPtr1 = (ChatMsg *)ref msg;
            SendChatMessage(ref msg);
        }
コード例 #15
0
 public void SendChatMessageToPlayer(string text, ulong steamId)
 {
     if (MyMultiplayer.Static.IsServer)
     {
         ChatMsg msg = new ChatMsg {
             Text             = text,
             Author           = Sync.MyId,
             Channel          = 3,
             CustomAuthorName = string.Empty
         };
         Vector3D?position = null;
         MyMultiplayer.RaiseStaticEvent <ChatMsg>(s => new Action <ChatMsg>(MyMultiplayerBase.OnChatMessageRecieved_ToPlayer), msg, new EndpointId(steamId), position);
     }
 }
コード例 #16
0
        public override unsafe void SendChatMessageScripted(string text, ChatChannel channel, long targetId = 0L, string customAuthor = null)
        {
            ChatMsg *msgPtr1;
            ChatMsg  msg2 = new ChatMsg {
                Text     = "This is god speaking! You are not allowed to send scripted messages from client so your message will be suppressed.",
                Author   = Sync.MyId,
                Channel  = 1,
                TargetId = MySession.Static.LocalPlayerId
            };

            msgPtr1->CustomAuthorName = string.IsNullOrEmpty(customAuthor) ? MyTexts.GetString(MySpaceTexts.ChatBotName) : customAuthor;
            msgPtr1 = (ChatMsg *)ref msg2;
            ChatMsg msg = msg2;

            this.OnChatMessage(ref msg);
        }
コード例 #17
0
 protected abstract void OnChatMessage(ref ChatMsg msg, ulong sender);
コード例 #18
0
 static void OnChatMessageRecieved(ChatMsg msg)
 {
     MyMultiplayer.Static.OnChatMessage(ref msg);
 }
コード例 #19
0
 public virtual void OnChatMessage(ref ChatMsg msg)
 {
 }
コード例 #20
0
 protected virtual void OnChatMessage(ref ChatMsg msg)
 {
 }
コード例 #21
0
 protected static void SendChatMessage(ref ChatMsg msg)
 {
     MyMultiplayer.RaiseStaticEvent(s => MyMultiplayerBase.OnChatMessageRecieved, msg);
 }
コード例 #22
0
        protected override void OnChatMessage(ref ChatMsg msg, ulong sender)
        {
            bool debugCommands = !MyFinalBuildConstants.IS_OFFICIAL && MyFinalBuildConstants.IS_DEBUG;

            msg.Author = sender;
            if (m_memberData.ContainsKey(sender))
            {
                if (m_memberData[sender].IsAdmin || debugCommands)
                {
                    if (msg.Text.Equals("+save", StringComparison.InvariantCultureIgnoreCase))
                    {
                        MySession.Static.Save();
                    }
                    else if (msg.Text.Contains("+unban", StringComparison.InvariantCultureIgnoreCase))
                    {
                        string[] parts = msg.Text.Split(' ');
                        if (parts.Length > 1)
                        {
                            ulong user = 0;
                            if (ulong.TryParse(parts[1], out user))
                            {
                                BanClient(user, false);
                            }
                        }
                    }
                }
                if(debugCommands)
                {
                    MyServerDebugCommands.Process(msg.Text, msg.Author);
                }
            }

            SendControlMessageToAll(ref msg, msg.Author);
            RaiseChatMessageReceived(sender, msg.Text, ChatEntryTypeEnum.ChatMsg);
        }
コード例 #23
0
        protected override void OnChatMessage(ref ChatMsg msg, ulong sender)
        {
            msg.Author = sender;
            if (m_memberData.ContainsKey(sender))
            {
                if (m_memberData[sender].IsAdmin)
                {
                    if (msg.Text.ToLower().Contains("+unban"))
                    {
                        string[] parts = msg.Text.Split(' ');
                        if (parts.Length > 1)
                        {
                            ulong user = 0;
                            if (ulong.TryParse(parts[1], out user))
                            {
                                BanClient(user, false);
                            }
                        }
                    }
                    else if (msg.Text.ToLower() == "+reload")
                    {
                        MySandboxGame.ReloadDedicatedServerSession();
                    }
                }
            }

            SendControlMessageToAll(ref msg, msg.Author);            
            RaiseChatMessageReceived(sender, msg.Text, ChatEntryTypeEnum.ChatMsg);
        }
コード例 #24
0
 protected override void OnChatMessage(ref ChatMsg msg)
 {
     RaiseChatMessageReceived(msg.Author, msg.Text, ChatEntryTypeEnum.ChatMsg);
 }
コード例 #25
0
 void OnChatMessage(ref ChatMsg msg, ulong sender)
 {
     RaiseChatMessageReceived(sender, msg.Text, ChatEntryTypeEnum.ChatMsg);
 }
コード例 #26
0
 private static void OnChatMessageRecieved_BroadcastExcept(ChatMsg msg)
 {
     Sandbox.Engine.Multiplayer.MyMultiplayer.Static.OnChatMessage(ref msg);
 }
コード例 #27
0
 protected static void OnChatMessageRecieved_ToPlayer(ChatMsg msg)
 {
     Sandbox.Engine.Multiplayer.MyMultiplayer.Static.OnChatMessage(ref msg);
 }
コード例 #28
0
        private static void OnChatMessageRecieved_Server(ChatMsg msg)
        {
            Vector3D?  nullable;
            EndpointId sender     = MyEventContext.Current.Sender;
            string     playerName = sender.ToString();
            string     playerName = msg.TargetId.ToString();

            switch (msg.Channel)
            {
            case 0:
                playerName = GetPlayerName(MyEventContext.Current.Sender.Value);
                playerName = "everyone";
                nullable   = null;
                Sandbox.Engine.Multiplayer.MyMultiplayer.RaiseStaticEvent <ChatMsg>(s => new Action <ChatMsg>(MyMultiplayerBase.OnChatMessageRecieved_BroadcastExcept), msg, MyEventContext.Current.Sender, nullable);
                goto TR_0003;

            case 1:
                if (msg.TargetId <= 0L)
                {
                    sender   = new EndpointId();
                    nullable = null;
                    Sandbox.Engine.Multiplayer.MyMultiplayer.RaiseStaticEvent <ChatMsg>(s => new Action <ChatMsg>(MyMultiplayerBase.OnChatMessageRecieved_BroadcastExcept), msg, sender, nullable);
                }
                else
                {
                    ulong num3 = MySession.Static.Players.TryGetSteamId(msg.TargetId);
                    if (num3 != 0)
                    {
                        playerName = GetPlayerName(MyEventContext.Current.Sender.Value);
                        playerName = GetPlayerName(msg.TargetId);
                        nullable   = null;
                        Sandbox.Engine.Multiplayer.MyMultiplayer.RaiseStaticEvent <ChatMsg>(s => new Action <ChatMsg>(MyMultiplayerBase.OnChatMessageRecieved_SingleTarget), msg, new EndpointId(num3), nullable);
                    }
                }
                goto TR_0003;

            case 2:
            {
                IMyFaction faction = MySession.Static.Factions.TryGetFactionById(msg.TargetId);
                if (faction == null)
                {
                    goto TR_0003;
                }
                else
                {
                    playerName = GetPlayerName(MyEventContext.Current.Sender.Value);
                    playerName = faction.Tag;
                    foreach (KeyValuePair <long, MyFactionMember> pair in faction.Members)
                    {
                        if (!MySession.Static.Players.IsPlayerOnline(pair.Value.PlayerId))
                        {
                            continue;
                        }
                        ulong num = MySession.Static.Players.TryGetSteamId(pair.Value.PlayerId);
                        if ((num != 0) && (num != MyEventContext.Current.Sender.Value))
                        {
                            nullable = null;
                            Sandbox.Engine.Multiplayer.MyMultiplayer.RaiseStaticEvent <ChatMsg>(s => new Action <ChatMsg>(MyMultiplayerBase.OnChatMessageRecieved_SingleTarget), msg, new EndpointId(num), nullable);
                        }
                    }
                    goto TR_0003;
                }
                break;
            }

            case 3:
                break;

            case 4:
                playerName = GetPlayerName(MyEventContext.Current.Sender.Value);
                playerName = GetPlayerName(msg.TargetId);
                goto TR_0003;

            default:
                goto TR_0003;
            }
            ulong num2 = MySession.Static.Players.TryGetSteamId(msg.TargetId);

            if ((num2 != 0) && (num2 != MyEventContext.Current.Sender.Value))
            {
                playerName = GetPlayerName(MyEventContext.Current.Sender.Value);
                playerName = GetPlayerName(msg.TargetId);
                nullable   = null;
                Sandbox.Engine.Multiplayer.MyMultiplayer.RaiseStaticEvent <ChatMsg>(s => new Action <ChatMsg>(MyMultiplayerBase.OnChatMessageRecieved_SingleTarget), msg, new EndpointId(num2), nullable);
            }
TR_0003:
            Sandbox.Engine.Multiplayer.MyMultiplayer.Static.OnChatMessage(ref msg);
            if (Game.IsDedicated && MySandboxGame.ConfigDedicated.SaveChatToLog)
            {
                StringBuilder builder1 = new StringBuilder();
                MyLog.Default.WriteLine($"CHAT - channel: [{msg.Channel.ToString()}], from [{playerName}] to [{playerName}], message: '{msg.Text}'");
            }
        }
コード例 #29
0
        public override void SendChatMessage(string text)
        {
            ChatMsg msg = new ChatMsg();
            msg.Text = text;

            SendControlMessageToAllAndSelf(ref msg);
        }
コード例 #30
0
        void OnChatMessage(ref ChatMsg msg, ulong sender)
        {
            if (m_memberData.ContainsKey(sender))
            {
                if (m_memberData[sender].IsAdmin)
                {
                    if (msg.Text.ToLower().Contains("+unban"))
                    {
                        string[] parts = msg.Text.Split(' ');
                        if (parts.Length > 1)
                        {
                            ulong user = 0;
                            if (ulong.TryParse(parts[1], out user))
                            {
                                BanClient(user, false);
                            }
                        }
                    }
                }
            }

            RaiseChatMessageReceived(sender, msg.Text, ChatEntryTypeEnum.ChatMsg);
        }
コード例 #31
0
 private static void OnChatMessageRecieved_SingleTarget(ChatMsg msg)
 {
     Sandbox.Engine.Multiplayer.MyMultiplayer.Static.OnChatMessage(ref msg);
 }
コード例 #32
0
 void OnChatMessage(ref ChatMsg msg, ulong sender)
 {
     RaiseChatMessageReceived(msg.Author, msg.Text, ChatEntryTypeEnum.ChatMsg);
 }