[Bug]ItemLock save

08/16/2010 01:43 Sp!!ke#1
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NewestCOServer.PacketHandling
{
    public class ItemLock
    {
        public static void Handle(Main.GameClient GC, byte[] Data)
        {
            uint Itemuid = BitConverter.ToUInt32(Data, 4);
            byte LockType = Data[8];

            Game.Item Item = new Game.Item();

            foreach (Game.Item I in GC.MyChar.Inventory)
            {
                if (I.UID == Itemuid)
                {
                    Item = I;
                }
            }
            switch (LockType)
            {
                case 0:
                    {
                        if (Item.Locked == 0 || Item.Locked == 2)
                        { Item.Locked = 1; }

                        Database.SaveCharacter(GC.MyChar, GC.MyChar.Name);
                        GC.AddSend(Packets.ItemLock(Itemuid, LockType, 1, 0));
                        GC.AddSend(Packets.UpdateItem(Item, 0));
                        if (Item.Locked == 2)
                        { GC.AddSend(Packets.ItemLock(Item.UID, 1, 3, Item.LockedDays)); }
                        return;
                    }
                case 2:
                    {
                        DateTime datetounlock = DateTime.Now;
                        datetounlock = datetounlock.AddDays(5);
                        Item.LockedDays = Convert.ToUInt32(datetounlock.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture));
                        Item.Locked = 2;
                        GC.AddSend(Packets.UpdateItem(Item, 0));
                        if (Item.Locked == 2)
                        { GC.AddSend(Packets.ItemLock(Item.UID, 1, 3, Item.LockedDays)); }
                        break;
                    }
            }
        }
    }
}
Code:
public byte Locked;
        public uint LockedDays;


Code:
 public void WriteThis(System.IO.BinaryWriter I)
        {
            if (ID != 0 && UID == 0) UID = (uint)Program.Rnd.Next(10000000);
            if (ID != 0 && UID == 0) UID = (uint)World.Rnd.Next(10000000);

            I.Write((byte)26);
            I.Write(UID);
            I.Write(ID);
            I.Write(Plus);
            I.Write(Bless);
            I.Write(Enchant);
            I.Write((byte)Soc1);
            I.Write((byte)Soc2);
            I.Write(MaxDur);
            I.Write(CurDur);
            I.Write(FreeItem);
            I.Write(TalismanProgress);
            I.Write(Progress);
            I.Write((byte)Color);
            I.Write(Locked);
        }
        public void ReadThis(System.IO.BinaryReader I)
        {
            byte Length = I.ReadByte();
            if (Length == 25)
            {
                UID = I.ReadUInt32();

                if (UID == 0) UID = (uint)Program.Rnd.Next(10000000);
                if (UID == 0) UID = (uint)World.Rnd.Next(10000000);

                ID = I.ReadUInt32();
                if (Database.DatabaseItems.Contains(ID))
                {
                    Plus = I.ReadByte();
                    Bless = I.ReadByte();
                    Enchant = I.ReadByte();
                    Soc1 = (Gem)I.ReadByte();
                    Soc2 = (Gem)I.ReadByte();
                    MaxDur = I.ReadUInt16();
                    CurDur = I.ReadUInt16();
                    FreeItem = I.ReadBoolean();
                    TalismanProgress = I.ReadUInt32();
                    Progress = I.ReadUInt16();
                    Color = (ArmorColor)I.ReadByte();
                    Locked = I.ReadByte();
                }
                else
                {
                    UID = 0;
                    ID = 0;
                    I.ReadBytes(17);
                }
            }
            else I.ReadBytes(Length);
        }
    }

I apologize for this topic may seem silly but I have a problem with itemlock struggling for some time and I resolved, after block item discconect and give me away when I reconnect item disappear.
Anyone can say me where I wrong ?
08/16/2010 09:36 _DreadNought_#2
Your not saving it directly to the equipment, when it check weather it is a steed, necklace, boots, weapon etc etc it reads the itemlock directly, Check cosx
08/16/2010 15:58 Sp!!ke#3
ok :) I will dw cosx to try item lock thanks
08/16/2010 17:31 _DreadNought_#4
I know somebody who has converted the CoSx to newestcoserver itemlock saving/loading so you can too :)
10/27/2010 20:26 StefanHAKER#5
Let me help you, "SaveCharacter" and "LoadCharacter" void...
10/27/2010 21:06 Arcо#6
Quote:
Originally Posted by StefanHAKER View Post
Let me help you, "SaveCharacter" and "LoadCharacter" void...
Great job at bumping an old thread.
:facepalm:
10/27/2010 21:08 _DreadNought_#7
The whole thing was leeched from pastebin so...Yea I doubt u would be able to help anyway.