Register for your free account! | Forgot your password?

You last visited: Today at 10:58

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Bug]ItemLock save

Discussion on [Bug]ItemLock save within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
Sp!!ke's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 380
Received Thanks: 58
[Bug]ItemLock save

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 ?
Sp!!ke is offline  
Old 08/16/2010, 10:36   #2
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,223
Received Thanks: 867
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
_DreadNought_ is offline  
Thanks
1 User
Old 08/16/2010, 16:58   #3
 
Sp!!ke's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 380
Received Thanks: 58
ok I will dw cosx to try item lock thanks
Sp!!ke is offline  
Old 08/16/2010, 18:31   #4
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,223
Received Thanks: 867
I know somebody who has converted the CoSx to newestcoserver itemlock saving/loading so you can too
_DreadNought_ is offline  
Old 10/27/2010, 21:26   #5
 
elite*gold: 0
Join Date: Sep 2008
Posts: 128
Received Thanks: 8
Let me help you, "SaveCharacter" and "LoadCharacter" void...
StefanHAKER is offline  
Old 10/27/2010, 22:06   #6
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,764
Received Thanks: 5,291
Quote:
Originally Posted by StefanHAKER View Post
Let me help you, "SaveCharacter" and "LoadCharacter" void...
Great job at bumping an old thread.
Arcо is offline  
Old 10/27/2010, 22:08   #7
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,223
Received Thanks: 867
The whole thing was leeched from pastebin so...Yea I doubt u would be able to help anyway.
_DreadNought_ is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
itemlock
08/24/2010 - CO2 Private Server - 6 Replies
hey guys ive kinda got my item lock function to work it locks the items but when i equipt them there unlocked :/ anybody know a solution for this problem?
ItemLock for 5165 Problem?
06/22/2010 - CO2 Private Server - 1 Replies
okay, so I followed ImmuneOne's guide of adding and saving/loading item lock but somehow I keep gettin a dumb ass error, well actually I got it in different files...in character.cs its saying "Locked does not exist in the corrent context" and I added public int Locked; and public unit LockedDays;...then sum more in ItemLock.cs saying: "NewestCOServer.Game.Item does not contain a definition for 'Locked' and no extension method 'Locked' accepting a first arguement of type...
[REL] ItemLock Saving/Loading
03/31/2010 - CO2 PServer Guides & Releases - 27 Replies
Since all those people think a code is not complete because I didn't post a save/load method, here it is. Search for foreach (Game.Item I in C.Inventory) I.WriteThis(BW); Right click it and click on go to definition. Then search for
Itemlock ?
10/23/2009 - Metin2 - 7 Replies
Hi Leute wollte mal fragen ob es ein item anziehung gibt weil wenn man z:B Moblock an hat und items/yang droppt droppt man die manchmal weit weg also wer echt dankbar für ein oder mehrere antworten gibt es sowas :confused:



All times are GMT +1. The time now is 10:58.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.