Need help for this code

10/14/2008 16:07 emogoth213#1
How do i fixed this codes problem,to avoid bringing the pharmacist anywhere...

here is the codes below...

Code:
 MyChar.Ready = false;
                                    uint ItemID = (uint)((Data[0x0b] << 24) + (Data[0x0a] << 16) + (Data[0x09] << 8) + Data[0x08]);
                                    uint CPsVal = Data[18];
                                    uint Value = (uint)((Data[0x07] << 24) + (Data[0x06] << 16) + (Data[0x05] << 8) + Data[0x04]);
                                    byte Amount = Data[20];
                                    int Money = Data[5];
                                    if (Amount == 0)
                                        Amount = 1;

                                    string TehShop = System.IO.File.ReadAllText(System.Windows.Forms.Application.StartupPath + @"\Shop.dat");

                                    try
                                    {
                                        if (Other.CharExist(Convert.ToString(ItemID), TehShop))
                                        {
                                            foreach (uint[] item in DataBase.Items)
                                            {
                                                if (ItemID == item[0])
                                                {
                                                    Value = item[7];
                                                    CPsVal = item[15];
                                                }
                                            }
                                            for (int i = 0; i < Amount; i++)
                                            {
                                                if (MyChar.ItemsInInventory > 39)
                                                    return;
                                                if (MyChar.Silvers >= Value && CPsVal == 0 || MyChar.CPs > CPsVal && CPsVal != 0)
                                                {
                                                    if (CPsVal == 0)
                                                        MyChar.Silvers -= Value;
                                                    if (CPsVal > 0)
                                                        MyChar.CPs -= CPsVal;

                                                    if (MyChar.Silvers < 0)
                                                        MyChar.Silvers = 0;
                                                    if (MyChar.CPs < 0)
                                                        MyChar.CPs = 0;

                                                    byte WithPlus = 0;
                                                    if (ItemID == 730003)
                                                        WithPlus = 3;
                                                    if (ItemID == 730004)
                                                        WithPlus = 4;
                                                    if (ItemID == 730005)
                                                        WithPlus = 5;
                                                    if (ItemID == 730006)
                                                        WithPlus = 6;
                                                    if (ItemID == 730007)
                                                        WithPlus = 7;

                                                    MyChar.AddItem(Convert.ToString(ItemID) + "-" + WithPlus + "-0-0-0-0", 0, (uint)General.Rand.Next(10000000));
                                                    SendPacket(General.MyPackets.Vital(MyChar.UID, 4, MyChar.Silvers));
                                                    SendPacket(General.MyPackets.Vital(MyChar.UID, 30, MyChar.CPs));
                                                }
                                                else
                                                {
                                                    SendPacket(General.MyPackets.SendMsg(MessageId, "SYSTEM", MyChar.Name, "You don't have " + Value + " silvers or " + CPsVal + " CPs.", 2005));
                                                    break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            General.WriteLine("There is no such item in Shop.dat.(" + ItemID + ")");
                                        }
                                    }
                                    catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
                                    MyChar.Ready = true;
                                    break;
                                }
Thx in advance....:)