Esempio n. 1
0
        public static void SendFlowers(Client.GameState client, byte[] packet)
        {
            uint TargetID = BitConverter.ToUInt32(packet, 8);
            int Flowers = BitConverter.ToUInt16(packet, 20);
            int Type = packet[24];
            if (Flowers == 1)
            {
                if (client.Entity.AddFlower == 0)
                {
                    client.Send(new Network.GamePackets.Message("Sorry, but you send the flower today! ", System.Drawing.Color.White, Message.Center));
                    return;
                }
            }

            bool change = false;
            if (ServerBase.Kernel.GamePool.ContainsKey(TargetID))
            {
                Client.GameState Cclient = ServerBase.Kernel.GamePool[TargetID];
                if (Conquer_Online_Server.ServerBase.Kernel.AllFlower.ContainsKey(Cclient.Entity.UID))
                {
                    if (Cclient.Entity.Body.ToString().EndsWith("3") || Cclient.Entity.Body.ToString().EndsWith("4"))
                        return;
                    byte[] packe2nd2 = new byte[24]
                                {
                                    0x10, 0x00 , 0x7F , 0x04 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
                                   , 0x54 , 0x51 , 0x53 , 0x65 , 0x72 , 0x76 , 0x65 , 0x72
                                };
                    Cclient.Send(packe2nd2);
                    Game.Struct.Flowers F = Conquer_Online_Server.ServerBase.Kernel.AllFlower[Cclient.Entity.UID];
                    switch (Type)
                    {

                        case 0:
                            {
                                string It = "751";
                                if (Flowers == 1)
                                    It += "001";
                                else if (Flowers == 3)
                                    It += "003";
                                else if (Flowers == 9)
                                    It += "009";
                                else if (Flowers == 99)
                                    It += "099";
                                else if (Flowers == 999)
                                    It += "999";
                                if (client.Inventory.Contains(uint.Parse(It), 1))
                                    client.Inventory.Remove(uint.Parse(It), 1);
                                client.Send(packet);
                                F.RedRoses += Flowers;
                                F.RedRoses2day += Flowers;
                                //if (F.RedRoses > 100000)
                                //   Cclient.Entity.FlowerSend = "TakeOnRoseSuit";
                                Cclient.Entity.MyFlowers = Conquer_Online_Server.ServerBase.Kernel.AllFlower[Cclient.Entity.UID];
                                Cclient.Send(packet);

                                int mybestcount = 0;
                                if (F.Lilies > mybestcount)
                                    mybestcount = F.Lilies;
                                if (F.Orchads > mybestcount)
                                    mybestcount = F.Orchads;
                                if (F.RedRoses > mybestcount)
                                    mybestcount = F.RedRoses;
                                if (F.Tulips > mybestcount)
                                    mybestcount = F.Tulips;
                                if (F.RedRoses == mybestcount)
                                {
                                    if (F.RedRoses >= ServerBase.Kernel.MaxRoses)
                                    {
                                        Cclient.Entity.ActualMyTypeFlower = 30010002;
                                        Cclient.Send(new FlowerSpawn("1", Cclient.Entity.Name, F.RedRoses.ToString(), Cclient.Entity.UID.ToString(), 30000002).ThePacket());
                                        ServerBase.Kernel.MaxRoses = (uint)F.RedRoses;
                                        change = true;
                                    }
                                }

                                break;
                            }
                        case 1:
                            {
                                string It = "752";
                                if (Flowers == 1)
                                    It += "001";
                                else if (Flowers == 3)
                                    It += "003";
                                else if (Flowers == 9)
                                    It += "009";
                                else if (Flowers == 99)
                                    It += "099";
                                else if (Flowers == 999)
                                    It += "999";
                                if (client.Inventory.Contains(uint.Parse(It), 1))
                                    client.Inventory.Remove(uint.Parse(It), 1);
                                client.Send(packet);
                                F.Lilies += Flowers;
                                F.Lilies2day += Flowers;
                                //if (F.Lilies > 100000)
                                //    Cclient.Entity.FlowerSend = "TakeOnLilySuit";

                                Cclient.Entity.MyFlowers = Conquer_Online_Server.ServerBase.Kernel.AllFlower[Cclient.Entity.UID];
                                Cclient.Send(packet);
                                int mybestcount = 0;
                                if (F.Lilies > mybestcount)
                                    mybestcount = F.Lilies;
                                if (F.Orchads > mybestcount)
                                    mybestcount = F.Orchads;
                                if (F.RedRoses > mybestcount)
                                    mybestcount = F.RedRoses;
                                if (F.Tulips > mybestcount)
                                    mybestcount = F.Tulips;
                                if (F.Lilies == mybestcount)
                                {
                                    if (F.RedRoses >= ServerBase.Kernel.MaxLilies)
                                    {
                                        Cclient.Entity.ActualMyTypeFlower = 30010102;
                                        FlowerSpawn fl = new FlowerSpawn("1", Cclient.Entity.Name, F.Lilies.ToString(), Cclient.Entity.UID.ToString(), 30000102);
                                        Cclient.Send(fl.ThePacket());
                                        ServerBase.Kernel.MaxLilies = (uint)F.RedRoses;
                                        change = true;
                                    }
                                }
                                break;
                            }
                        case 2:
                            {
                                string It = "753";
                                if (Flowers == 1)
                                    It += "001";
                                else if (Flowers == 3)
                                    It += "003";
                                else if (Flowers == 9)
                                    It += "009";
                                else if (Flowers == 99)
                                    It += "099";
                                else if (Flowers == 999)
                                    It += "999";
                                if (client.Inventory.Contains(uint.Parse(It), 1))
                                    client.Inventory.Remove(uint.Parse(It), 1);
                                client.Send(packet);
                                F.Orchads += Flowers;
                                F.Orchads2day += Flowers;
                                //if (F.Orchads> 100000)
                                //    Cclient.Entity.FlowerSend = "TakeOnOrchisSuit";

                                Cclient.Entity.MyFlowers = Conquer_Online_Server.ServerBase.Kernel.AllFlower[Cclient.Entity.UID];
                                Cclient.Send(packet);
                                int mybestcount = 0;
                                if (F.Lilies > mybestcount)
                                    mybestcount = F.Lilies;
                                if (F.Orchads > mybestcount)
                                    mybestcount = F.Orchads;
                                if (F.RedRoses > mybestcount)
                                    mybestcount = F.RedRoses;
                                if (F.Tulips > mybestcount)
                                    mybestcount = F.Tulips;
                                if (F.Orchads == mybestcount)
                                {
                                    if (F.Orchads >= ServerBase.Kernel.MaxOrchads)
                                    {
                                        Cclient.Entity.ActualMyTypeFlower = 30010202;
                                        FlowerSpawn fl = new FlowerSpawn("1", Cclient.Entity.Name, F.Orchads.ToString(), Cclient.Entity.UID.ToString(), 30000202);
                                        Cclient.Send(fl.ThePacket());
                                        ServerBase.Kernel.MaxOrchads = (uint)F.Orchads;
                                        change = true;
                                    }
                                }

                                break;

                            }
                        case 3:
                            {
                                string It = "754";
                                if (Flowers == 1)
                                    It += "001";
                                else if (Flowers == 3)
                                    It += "003";
                                else if (Flowers == 9)
                                    It += "009";
                                else if (Flowers == 99)
                                    It += "099";
                                else if (Flowers == 999)
                                    It += "999";

                                if (client.Inventory.Contains(uint.Parse(It), 1))
                                    client.Inventory.Remove(uint.Parse(It), 1);
                                client.Send(packet);
                                F.Tulips += Flowers;
                                F.Tulips2day += Flowers;
                                //if (F.Tulips > 100000)
                                //    Cclient.Entity.FlowerSend = "TakeOnTulipSuit";

                                Cclient.Entity.MyFlowers = Conquer_Online_Server.ServerBase.Kernel.AllFlower[Cclient.Entity.UID];
                                Cclient.Send(packet);
                                int mybestcount = 0;
                                if (F.Lilies > mybestcount)
                                    mybestcount = F.Lilies;
                                if (F.Orchads > mybestcount)
                                    mybestcount = F.Orchads;
                                if (F.RedRoses > mybestcount)
                                    mybestcount = F.RedRoses;
                                if (F.Tulips > mybestcount)
                                    mybestcount = F.Tulips;
                                if (F.Tulips == mybestcount)
                                {
                                    if (F.Tulips >= ServerBase.Kernel.MaxTulips)
                                    {
                                        Cclient.Entity.ActualMyTypeFlower = 30010302;
                                        FlowerSpawn fl = new FlowerSpawn("1", Cclient.Entity.Name, F.Tulips.ToString(), Cclient.Entity.UID.ToString(), 30000302);

                                        Cclient.Send(fl.ThePacket());
                                        ServerBase.Kernel.MaxTulips = (uint)F.Tulips;
                                        change = true;
                                    }
                                }

                                break;
                            }
                    }

                    if (Flowers == 1)
                        client.Entity.AddFlower = 0;

                    //client.Send(new FlowerSpawn2(Cclient.Entity.UID.ToString()).ThePacket());
                    string name = client.Entity.Name + " " + Cclient.Entity.Name + " " + Flowers + " " + Type + "";
                    byte[] Buffer = new byte[68];
                    Network.Writer.WriteUInt16((ushort)(60), 0, Buffer);
                    Network.Writer.WriteUInt16(1150, 2, Buffer);

                    Network.Writer.WriteUInt32((uint)Flowers, 48, Buffer);

                    Network.Writer.WriteUInt32((uint)Type, 56, Buffer);//52

                    for (int i = 0; i < client.Entity.Name.Length; i++)
                    {
                        try
                        {
                            Buffer[16 + i] = Convert.ToByte(client.Entity.Name[i]);
                        }
                        catch { }
                    }

                    for (int i = 0; i < Cclient.Entity.Name.Length; i++)
                    {
                        try
                        {
                            Buffer[32 + i] = Convert.ToByte(Cclient.Entity.Name[i]);
                        }
                        catch { }
                    }

                    Cclient.Send(Buffer);
                    if (Flowers == 1)
                        client.Send(Buffer);
                    //clienSend(new FlowerSpawn2(Cclient.Entity.UID.ToString()).ThePacket());
                    Network.GamePackets._String strgp = new Network.GamePackets._String(true);
                    strgp.Texts.Add("NEW-flower-r-1");
                    strgp.TextsCount = 1;
                    strgp.Type = 10;
                    strgp.UID = client.Entity.UID;
                    client.Screen.Reload(strgp);

                    strgp.UID = Cclient.Entity.UID;

                    Cclient.Screen.Reload(strgp);

                    Network.GamePackets.FlowerPacket flow = new FlowerPacket(F);
                    Cclient.Send(flow.ToArray());

                    Database.Flowers.SaveFlowerRank(Cclient);

                    if (change)
                    {
                        byte[] packe2nd = new byte[24]
                                {
                                    0x10, 0x00 , 0x7F , 0x04 , 0x05 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
                                   , 0x54 , 0x51 , 0x53 , 0x65 , 0x72 , 0x76 , 0x65 , 0x72
                                };
                        Cclient.Send(packe2nd);
                    }
                }
            }
        }
Esempio n. 2
0
        public static void AddFlowers(Client.GameState client, byte[] packet)
        {
            if (packet[4] == 2)
            {
                if (client.Entity.MyFlowers != null)
                {
                    Game.Struct.Flowers F = client.Entity.MyFlowers;
                    //string ToSend = " " + F.RedRoses.ToString() + " " + F.RedRoses2day.ToString() + " " + F.Lilies.ToString() + " " + F.Lilies2day.ToString() + " ";
                    //ToSend += F.Orchads.ToString() + " " + F.Orchads2day.ToString() + " " + F.Tulips.ToString() + " " + F.Tulips2day.ToString();
                    Network.GamePackets.FlowerPacket flow = new FlowerPacket(F);
                    client.Send(flow.ToArray());

                    int mybestcount = 0;
                    if (F.Lilies > mybestcount)
                        mybestcount = F.Lilies;
                    if (F.Orchads > mybestcount)
                        mybestcount = F.Orchads;
                    if (F.RedRoses > mybestcount)
                        mybestcount = F.RedRoses;
                    if (F.Tulips > mybestcount)
                        mybestcount = F.Tulips;

                    if (F.Lilies == mybestcount)
                    {
                        if (mybestcount >= ServerBase.Kernel.MaxLilies)
                        {
                            client.Entity.ActualMyTypeFlower = 30010102;
                            FlowerSpawn fl = new FlowerSpawn("1", client.Entity.Name, F.Lilies.ToString(), client.Entity.UID.ToString(), 30000102);
                            client.Send(fl.ThePacket());
                            ServerBase.Kernel.MaxLilies = (uint)mybestcount;
                        }
                    }
                    if (F.Orchads == mybestcount)
                    {
                        if (mybestcount >= ServerBase.Kernel.MaxOrchads)
                        {
                            client.Entity.ActualMyTypeFlower = 30010202;
                            FlowerSpawn fl = new FlowerSpawn("1", client.Entity.Name, F.Orchads.ToString(), client.Entity.UID.ToString(), 30000202);
                            client.Send(fl.ThePacket());
                            ServerBase.Kernel.MaxOrchads = (uint)mybestcount;
                        }
                    }
                    if (F.RedRoses == mybestcount)
                    {
                        if (mybestcount >= ServerBase.Kernel.MaxRoses)
                        {
                            client.Entity.ActualMyTypeFlower = 30010002;
                            FlowerSpawn fl = new FlowerSpawn("1", client.Entity.Name, F.RedRoses.ToString(), client.Entity.UID.ToString(), 30000002);
                            client.Send(fl.ThePacket());
                            ServerBase.Kernel.MaxRoses = (uint)mybestcount;
                        }
                    }
                    if (F.Tulips == mybestcount)
                    {
                        if (mybestcount >= ServerBase.Kernel.MaxTulips)
                        {
                            client.Entity.ActualMyTypeFlower = 30010302;
                            FlowerSpawn fl = new FlowerSpawn("1", client.Entity.Name, F.Tulips.ToString(), client.Entity.UID.ToString(), 30000302);
                            client.Send(fl.ThePacket());
                        } ServerBase.Kernel.MaxTulips = (uint)mybestcount;
                    }
                }
                else
                {
                    client.Entity.MyFlowers = new Conquer_Online_Server.Game.Struct.Flowers();
                    Game.Struct.Flowers F = client.Entity.MyFlowers;
                    Network.GamePackets.FlowerPacket flow = new FlowerPacket(F);
                    client.Send(flow.ToArray());
                    Database.Flowers.SaveFlowerRank(client);
                }
                byte[] packe2nd = new byte[24]
                                {
                                    0x10, 0x00 , 0x7F , 0x04 , 0x05 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
                                   , 0x54 , 0x51 , 0x53 , 0x65 , 0x72 , 0x76 , 0x65 , 0x72
                                };
                client.Send(packe2nd);
            }
        }