Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 14.02.2007, 23:21   #1
vladimir
Архивный участник
 
Join Date: Feb 2007
Posts: 9
Default 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”)
vladimir is offline  
Old 15.02.2007, 00:20   #2
astrid
Архивный участник
 
Join Date: May 2006
Posts: 55
Default

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.
astrid is offline  
Old 15.02.2007, 10:40   #3
vladimir
Архивный участник
 
Join Date: Feb 2007
Posts: 9
Default

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!
vladimir is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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