예제 #1
0
        protected void Broadcast(string[] args)
        {
            if (args.Length < 3)
            {
                return;
            }
            //GENERATE BROADCAST
            SMSG_SENDCHAT spkt = new SMSG_SENDCHAT();

            spkt.Name        = "GM";
            spkt.MessageType = SMSG_SENDCHAT.MESSAGE_TYPE.SYSTEM_MESSAGE;
            spkt.Message     = args[2];

            //FORWARD THE BROADCAST
            foreach (Character characterTarget in LifeCycle.Characters)
            {
                try
                {
                    spkt.SessionId = characterTarget.id;
                    characterTarget.client.Send((byte[])spkt);
                }
                catch (SocketException)
                {
                    //do nothing client was busy disconnecting or such
                }
            }
        }
예제 #2
0
        private static void SendCommandReply(Client tc, string message)
        {
            SMSG_SENDCHAT spkt = new SMSG_SENDCHAT();

            spkt.Message     = message;
            spkt.Name        = "Saga";
            spkt.MessageType = SMSG_SENDCHAT.MESSAGE_TYPE.SYSTEM_MESSAGE;
            spkt.SessionId   = tc.character.id;
            tc.Send((byte[])spkt);
        }
예제 #3
0
    public static void SystemMessage(Character sender, Character target, string message)
    {
        SMSG_SENDCHAT spkt = new SMSG_SENDCHAT();

        spkt.Message     = message != null ? message : string.Empty;
        spkt.Name        = sender.Name;
        spkt.MessageType = SMSG_SENDCHAT.MESSAGE_TYPE.SYSTEM_MESSAGE_RED;
        spkt.SessionId   = target.id;
        target.client.Send((byte[])spkt);
    }
예제 #4
0
    public static void Broadcast(Character sender, string message)
    {
        string nmessage = message != null ? message : string.Empty;

        foreach (Character target in LifeCycle.Characters)
        {
            SMSG_SENDCHAT spkt = new SMSG_SENDCHAT();
            spkt.Message     = nmessage;
            spkt.Name        = sender.Name;
            spkt.MessageType = SMSG_SENDCHAT.MESSAGE_TYPE.SYSTEM_MESSAGE;
            spkt.SessionId   = target.id;
            target.client.Send((byte[])spkt);
        }
    }
예제 #5
0
        /// <summary>
        /// Broadcasts a string to all actors
        /// </summary>
        /// <param name="message">Message to broadcast</param>
        private void DoGlobalAnnounchment(string message)
        {
            //GENERATE BROADCAST
            SMSG_SENDCHAT spkt = new SMSG_SENDCHAT();

            spkt.Name        = "GM";
            spkt.MessageType = SMSG_SENDCHAT.MESSAGE_TYPE.SYSTEM_MESSAGE_RED;
            spkt.Message     = message;

            //FORWARD THE BROADCAST
            foreach (Character characterTarget in Saga.Tasks.LifeCycle.Characters)
            {
                try
                {
                    spkt.SessionId = characterTarget.id;
                    characterTarget.client.Send((byte[])spkt);
                }
                catch (Exception)
                {
                    //DON'T HANDLE THE EXCEPTION
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Process our maintenance schedule.
        /// </summary>
        internal static void Process()
        {
            try
            {
                if (IsScheduled == true)
                {
                    TimeSpan span = NextSceduledMaintenance - DateTime.Now;
                    if (span.TotalMinutes > 0 && span.TotalMinutes < 50)
                    {
                        TimeSpan span2 = DateTime.Now - LastBroadCast;
                        if (span2.TotalMinutes > 10)
                        {
                            LastBroadCast = DateTime.Now;

                            //GENERATE BROADCAST
                            SMSG_SENDCHAT spkt = new SMSG_SENDCHAT();
                            spkt.Name        = "GM";
                            spkt.MessageType = SMSG_SENDCHAT.MESSAGE_TYPE.SYSTEM_MESSAGE_RED;
                            spkt.Message     = String.Format(CultureInfo.InvariantCulture, "Maintenance starting at: {0}", NextSceduledMaintenance.ToShortTimeString());

                            //FORWARD THE BROADCAST
                            foreach (Character characterTarget in LifeCycle.Characters)
                            {
                                if (characterTarget.client.isloaded == false)
                                {
                                    continue;
                                }
                                spkt.SessionId = characterTarget.id;
                                characterTarget.client.Send((byte[])spkt);
                            }
                        }
                    }
                    else if (span.TotalMinutes < 0)
                    {
                        Saga.Managers.NetworkService.InterNetwork.MAINTENANCE_ENTER();
                        IsScheduled = false;

                        while (LifeCycle.Count > 0)
                        {
                            try
                            {
                                foreach (Character characterTarget in LifeCycle.Characters)
                                {
                                    characterTarget.client.Close();
                                    //LifeCycle.ListOfUsersByName.Remove(pair.Key);
                                    LifeCycle.Unsubscribe(characterTarget);
                                }
                            }
                            catch (Exception)
                            {
                                //Do nothing
                            }
                        }

                        //Wait half a minute
                        Thread.Sleep(30000);

                        //Exit's the process
                        Environment.Exit(2);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
            }
        }
예제 #7
0
        /// <summary>
        /// Occurs when a user speaks in general to the given channel
        /// </summary>
        /// <param name="cpkt"></param>
        private void CM_SENDCHAT(CMSG_SENDCHAT cpkt)
        {
            //Check if gm level is set prior to on checking if it's a gm command
            if (this.character.chatmute > 0)
            {
                CommonFunctions.Broadcast(this.character, this.character, "You've been muted");
            }
            else if (this.character.GmLevel >= 0 && ConsoleCommands.IsGMCommand(cpkt.Message))
            {
                ConsoleCommands.ParseGMCommand(cpkt.Message, this.character);
            }
            else
            {
                SMSG_SENDCHAT spkt = new SMSG_SENDCHAT();
                spkt.Message     = cpkt.Message;
                spkt.Name        = this.character.Name;
                spkt.MessageType = cpkt.MessageType;
                spkt.SessionId   = this.character.id;

                switch (spkt.MessageType)
                {
                case SMSG_SENDCHAT.MESSAGE_TYPE.CHANEL:
                    foreach (Character characterTarget in LifeCycle.Characters)
                    {
                        if (characterTarget.client.isloaded == false)
                        {
                            continue;
                        }
                        spkt.SessionId = characterTarget.id;
                        characterTarget.client.Send((byte[])spkt);
                    }
                    break;

                case SMSG_SENDCHAT.MESSAGE_TYPE.NORMAL:
                    foreach (MapObject myObject in this.character.currentzone.GetCharactersInSightRange(this.character))
                    {
                        Character characterTarget = (Character)myObject;
                        if (characterTarget.client.isloaded == false)
                        {
                            continue;
                        }
                        spkt.SessionId = characterTarget.id;
                        characterTarget.client.Send((byte[])spkt);
                    }
                    break;

                case SMSG_SENDCHAT.MESSAGE_TYPE.PARTY:
                    if (this.character.sessionParty != null)
                    {
                        foreach (Character myObject in this.character.sessionParty.GetCharacters())
                        {
                            spkt.SessionId = myObject.id;
                            myObject.client.Send((byte[])spkt);
                        }
                    }
                    else
                    {
                        spkt.MessageType2 = 0xFF;
                        spkt.SessionId    = this.character.id;
                        this.Send((byte[])spkt);
                    }
                    break;

                case SMSG_SENDCHAT.MESSAGE_TYPE.YELL:
                    foreach (MapObject myObject in this.character.currentzone.Regiontree.SearchActors(this.character, SearchFlags.Characters))
                    {
                        Character characterTarget = (Character)myObject;
                        if (characterTarget.client.isloaded == false)
                        {
                            continue;
                        }
                        spkt.SessionId = characterTarget.id;
                        characterTarget.client.Send((byte[])spkt);
                    }
                    break;

                default:
                    Trace.TraceError("Message type not found {0}", cpkt.MessageType);
                    spkt.MessageType2 = 0xFF;
                    spkt.SessionId    = this.character.id;
                    this.Send((byte[])spkt);
                    break;
                }
            }
        }