[Help]Converting...

02/02/2010 12:24 felipeboladao#1
How to convert the packet

Code:
 public static byte[] ItemLock(int ItemUID, int Type01, int Type02, int Series)
        {
            PacketBuilder Packet = new PacketBuilder(2048, 16);
            Packet.Long(ItemUID);
            Packet.Int(Type01);
            Packet.Int(Type02);
            Packet.Short(0);//where do u call ItemLock method
            Packet.Long(Series);
            return Packet.getFinal();
        }
to 5165 source?
02/02/2010 14:44 .Ocularis#2
I made my own item lock system for the item lock button ;-;

I couldn't help you with yours, but I could help you build your own... I just can't post my script

Add me on msn
[Only registered and activated users can see links. Click Here To Register...]
02/02/2010 17:19 CptSky#3
Probably, something like this... But I don't know the two methods and I don't have the source.

Code:
        public static COPacket ItemLock(int ItemUID, int Type01, int Type02, int Series)
        {
            byte[] Packet = new byte[8 + 16];
            COPacket P = new COPacket(Packet);
            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16(2048);
            P.WriteInt64(ItemUID);
            P.WriteInt32(Type01);
            P.WriteInt32(Type02);
            P.WriteInt16(0x00);
            P.WriteInt64(Series);

            return P;
        }
02/02/2010 17:34 |_Beetle_|#4
The code you post, as is done in the source look 5165:

Quote:
public static COPacket Packet2048 (uint Charu)
(
byte [] packet = new byte [8 + 16];
COPacket P = new COPacket (Packet);
P.WriteInt16 ((ushort) (Packet.Length - 8));
P.WriteInt16 ((ushort) 2048);
P.WriteInt32 (Charu);
P.WriteInt32 (4);
P.WriteInt32 (0);

return P;
)
02/02/2010 18:50 felipeboladao#5
I've been working on this code, and not getting much success to add 5 days to unlock the item, I ask your help to finish the code ... thank you very much!

Create an ItemLocking.cs in PacketHandling/ItemPacket... and paste a code bellow...

Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NewestCOServer.PacketHandling
{
    public class ItemLocking
    {
        public static void Handle(Main.GameClient GC, byte[] Data)
        {
            uint ItemUID = BitConverter.ToUInt32(Data, 4);
            Game.Item I = GC.MyChar.FindInvItem(ItemUID);
            byte TheType = Data[8];

            switch (TheType)
            {
                case 0: //Item Lock
                    {
                        GC.MyChar.RemoveItem1(ItemUID);
                        I.Locked = true;
                        //GC.AddSend(Packets.ItemLock(ItemUID, TheType, 1, 0));
                        GC.MyChar.AddItem(I);

                        if (I.Locked == false) { GC.AddSend(Packets.ItemLock(ItemUID, 1, 3, I.LockedDays)); }
                        return;
                    }
                case 1: //Item re-Lock
                    {

                        GC.MyChar.RemoveItem1(ItemUID);
                        DateTime datetounlock = DateTime.Now;
                        datetounlock = datetounlock.AddDays(5);                       
                        I.LockedDays = Convert.ToUInt32(datetounlock.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture));
                        I.Locked = false;
                        GC.MyChar.AddItem(I);

                        if (I.Locked == false) { GC.AddSend(Packets.ItemLock(ItemUID, 1, 3, I.LockedDays)); }
                        break;
                    }
            }
        }
    }
}
and go to PacketHandler.cs and search for

Code:
                        
case 10005:
                            {
                                PacketHandling.WalkRun.Handle(GC, Data);
                                break;
                            }
and paste bellow...

Code:
                        case 2048:
                            {
                                PacketHandling.ItemLock.Handle(GC, Data);
                                break;
                            }
Thanks, we will finalize this code ...