Example #1
0
 public void OnChatSent(SEModAPIExtensions.API.ChatManager.ChatEvent obj)
 {
     return;             //no handling for motd right now
 }
Example #2
0
        public void OnChatReceived(SEModAPIExtensions.API.ChatManager.ChatEvent obj)
        {
            if (SandboxGameAssemblyWrapper.IsDebugging)
            {
                Console.WriteLine("Onchat Recieved: " + obj.message.ToString());
            }
            if (obj.sourceUserId == 0)
            {
                return;
            }
            bool isadmin = PlayerManager.Instance.IsUserAdmin(obj.sourceUserId);

            if (obj.message[0] == '/')
            {
                string[] words = obj.message.Split(' ');
                string   rem;
                //proccess
                if (words[0] == "/motd")
                {
                    if (m_lastupdate + TimeSpan.FromSeconds(motdRepeatSuppress) < DateTime.UtcNow)
                    {
                        m_lastupdate = DateTime.UtcNow;
                        sendMotd();
                        return;
                    }
                }
                if (words[0] == "/rules")
                {
                    if (m_ruleslastupdate + TimeSpan.FromSeconds(rulesRepeatSuppress) < DateTime.UtcNow)
                    {
                        m_ruleslastupdate = DateTime.UtcNow;
                        sendRules();
                        return;
                    }
                }
                if (words.Count() > 1)
                {
                    if (isadmin && words[0] == "/set" && words[1] == "motd")
                    {
                        rem  = String.Join(" ", words, 2, words.Count() - 2);
                        motd = rem;
                        LogManager.APILog.WriteLineAndConsole("Motd set: " + motd);
                        sendMotd();
                        return;
                    }
                    if (isadmin && words[0] == "/set" && words[1] == "rules")
                    {
                        rem   = String.Join(" ", words, 2, words.Count() - 2);
                        rules = rem;
                        LogManager.APILog.WriteLineAndConsole("Rules set: " + rules);
                        sendRules();
                        return;
                    }
                }

                if (isadmin && words[0] == "/motd-enable")
                {
                    enable = true;
                    return;
                }

                if (isadmin && words[0] == "/motd-disable")
                {
                    enable = false;
                    return;
                }

                if (isadmin && words[0] == "/motd-save")
                {
                    saveXML();
                    ChatManager.Instance.SendPrivateChatMessage(obj.sourceUserId, "Motd Configuration Saved.");
                    return;
                }
                if (isadmin && words[0] == "/motd-load")
                {
                    loadXML(false);
                    ChatManager.Instance.SendPrivateChatMessage(obj.sourceUserId, "Motd Configuration Loaded.");
                    return;
                }
                if (isadmin && words[0] == "/motd-loaddefault")
                {
                    loadXML(true);
                    ChatManager.Instance.SendPrivateChatMessage(obj.sourceUserId, "Motd Configuration Defaults Loaded.");
                    return;
                }
            }
            return;
        }