Post Pacific

Post Pacific (https://postpacific.loc-online.com/index.php)
-   Темы без сохранившегося раздела (https://postpacific.loc-online.com/forumdisplay.php?f=10001)
-   -   C4 cached, commands for asp.net (https://postpacific.loc-online.com/showthread.php?t=6853)

vladimir 14.02.2007 23:21

C4 cached, commands for asp.net
 
somebody can explain to me like turning these data types Asp.net
#d = int (4 bytes, little endian)
#S = unicode String ending with \ 0
#f = float

but the complete code of some of the functions, for example:
#5 KickCharacterPacket (“dS”)
#39 BanCharPacket (“ddS”)
#55 AddItem2Packet (“dddddddddS”)

astrid 15.02.2007 00:20

At last one who write code not on PHP :)
Use this for datatypes(C#):
Code:

using System;
using System.IO;
using System.Text;
namespace l2.cached
{
        /// <summary>
        /// Упаковка нешифрованных пакетов Клиент->Сервер (CacheD).
        /// Формирование заголовка пакета.
        /// </summary>
        public abstract class sPacketModel
        {
                MemoryStream _ms;
               

                protected sPacketModel()
                {
                        _ms = new MemoryStream();
                }

                protected void WriteD(int value)
                {
                        _ms.WriteByte((byte)(value &0xff));       
                        _ms.WriteByte((byte)(value >> 8 &0xff));
                        _ms.WriteByte((byte)(value >> 16 &0xff));
                        _ms.WriteByte((byte)(value >> 24 &0xff));
                }

                protected void WriteH(int value)
                {
                        _ms.WriteByte((byte)(value &0xff));       
                        _ms.WriteByte((byte)(value >> 8 &0xff));
                }

                protected void WriteC(int value)
                {
                        _ms.WriteByte((byte)(value &0xff));
                }

                protected void WriteF(double fvalue)
                {
                        byte[] b = System.BitConverter.GetBytes(fvalue);
                        _ms.Write(b,0,b.Length);
                }

                protected void WriteS(string text)
                {
                        try
                        {
                                if (text != null)
                                {       
                                        byte[] byteText = Encoding.Unicode.GetBytes(text);
                                        _ms.Write(byteText,0,byteText.Length);
                                }
                        }
                        catch
                        {
                        }

                        _ms.WriteByte((byte)0);
                        _ms.WriteByte((byte)0);
                }

                public byte[] GetBytes()
                {
                        MemoryStream _ms2=new MemoryStream();
                        int length = (int)_ms.Length+2;
                        _ms2.WriteByte((byte)(length &0xff));       
                        _ms2.WriteByte((byte)(length >> 8 &0xff));
                        _ms.WriteTo(_ms2);
                        return _ms2.ToArray();
                }
                public abstract byte[] GetContent();
        }
}

and this is example of BanCharPacket packet:
Code:

using System;
using l2.cached;

namespace l2.cachedpackets
{
        /// <summary>
        /// Пакет BanCharPacket бан персонажа на n часов.
        /// ID: 39
        /// формат: ddS
        /// </summary>
        public class sBanChar:sPacketModel
        {
                private int _charid;
                private int _hours;
                public sBanChar(int charid, int hours)
                {
                        _charid=charid;
                        _hours=hours;
                }
                public override byte[] GetContent()
                {
                        WriteC(39);
                        WriteD(_charid);
                        WriteD(_hours);
                        WriteS("1");
                        return GetBytes();
                }
        }
}

i think you can make rest by yourself.

vladimir 15.02.2007 10:40

Thx!

maybe vb.net code? i'm suck with C# :P

And if u can an app example how to use all that
For example how i ban a user with that code?
THX AGAIN!


All times are GMT. The time now is 15:26.