Example #1
0
        public void PlayerText(RealmTime time, PlayerTextPacket pkt)
        {
            if (pkt.Text[0] == '/')
            {
                string[] x = pkt.Text.Trim().Split(' ');
                ProcessCmd(x[0].Trim('/'), x.Skip(1).ToArray());
                //CommandManager.Execute(this, time, pkt.Text); // Beta Processor
            }
            else
            {
                string txt = Encoding.ASCII.GetString(
                    Encoding.Convert(
                        Encoding.UTF8,
                        Encoding.GetEncoding(
                            Encoding.ASCII.EncodingName,
                            new EncoderReplacementFallback(string.Empty),
                            new DecoderExceptionFallback()
                            ),
                        Encoding.UTF8.GetBytes(pkt.Text)
                    )
                );
                if (txt != "")
                {
                    //Removing unwanted crashing characters from strings
                    string chatColor = "";
                    if (Client.Account.Rank > 3)
                        chatColor = "@";
                    else if (Client.Account.Rank == 3)
                        chatColor = "#";

                    Owner.BroadcastPacket(new TextPacket()
                    {
                        Name = chatColor + Name,
                        ObjectId = Id,
                        Stars = Stars,
                        BubbleTime = 5,
                        Recipient = "",
                        Text = txt,
                        CleanText = txt
                    }, null);
                    foreach (var e in Owner.Enemies)
                    {
                        foreach (var b in e.Value.CondBehaviors)
                        {
                            if (b.Condition == BehaviorCondition.OnChat)
                            {
                                b.Behave(BehaviorCondition.OnChat, e.Value, time, null, pkt.Text);
                                b.Behave(BehaviorCondition.OnChat, e.Value, time, null, pkt.Text, this);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
 public void PlayerText(RealmTime time, PlayerTextPacket pkt)
 {
     if (pkt.Text[0] == '/')
     {
         CommandManager.Execute(this, time, pkt.Text);
     }
     else
         Owner.BroadcastPacket(new TextPacket()
         {
             Name = (Client.Account.Admin ? "@" : "") + Name,
             ObjectId = Id,
             Stars = Stars,
             BubbleTime = 5,
             Recipient = "",
             Text = pkt.Text,
             CleanText = pkt.Text
         }, null);
 }