![]() |
|
|
#1 |
|
Guest
Posts: n/a
|
Anybody can move this function from php to C#?
function KickCharacterPacket($char_id) { $buf=pack("cV",5,$char_id).tounicode("admin"); $cachedsocket=@fsockopen("localhost",2012,$errno,$ errstr,1) or die($notconnected); fwrite($cachedsocket,pack("s",(strlen($buf)+2)).$b uf); $len=unpack("v",fread($cachedsocket,2));$rid=unpac k("c",fread($cachedsocket,1)); for($i=0;$i<(($len[1]-4)/4);$i++){$read=unpack("i",fread($cachedsocket,4)); $rs.=$read[1];} fclose($cachedsocket); return $rs; } Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 28 October 2007. Открыть источник. |
|
|
#2 |
|
Guest
Posts: n/a
|
You're writing a L2admin in C#?
Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 29 October 2007. Открыть источник. |
|
|
#3 |
|
Guest
Posts: n/a
|
Quote:
Originally Posted by ~Marquis~ View Post You're writing a L2admin in C#? Yes. Wink Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 29 October 2007. Открыть источник. |
|
|
#4 |
|
Guest
Posts: n/a
|
easyest is to use the dll from the petition server NC.Toolnet.dll or something like that name. it has all the packed creating stuff.but you would need to create a receive and send function. heres our send function from our petition client
Code: Code:
public void SendPacket(Packer p)
{
lock (mSenderMutex)
{
byte[] sourceArray = p.ToArray();
int num = sourceArray.Length - 1;
byte[] destinationArray = new byte[num + 3];
destinationArray[0] = (byte)(num & 0xff);
destinationArray[1] = (byte)((num & 0xff00) >> 8);
Array.Copy(sourceArray, 0, destinationArray, 2, sourceArray.Length);
GetStream().Write(destinationArray, 0, destinationArray.Length);
GetStream().Flush();
}
}
Packer p = new Packer((byte) (PacketType.KICK)); p.addint32(char_id); p.addstring(GMName); SendPacket(p); hope this helps you out Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 29 October 2007. Открыть источник. |
|
|
#5 |
|
Guest
Posts: n/a
|
Quote:
Originally Posted by GMan View Post easyest is to use the dll from the petition server NC.Toolnet.dll or something like that name. it has all the packed creating stuff.but you would need to create a receive and send function. heres our send function from our petition client Code: Code:
public void SendPacket(Packer p)
{
lock (mSenderMutex)
{
byte[] sourceArray = p.ToArray();
int num = sourceArray.Length - 1;
byte[] destinationArray = new byte[num + 3];
destinationArray[0] = (byte)(num & 0xff);
destinationArray[1] = (byte)((num & 0xff00) >> 8);
Array.Copy(sourceArray, 0, destinationArray, 2, sourceArray.Length);
GetStream().Write(destinationArray, 0, destinationArray.Length);
GetStream().Flush();
}
}
Packer p = new Packer((byte) (PacketType.KICK)); p.addint32(char_id); p.addstring(GMName); SendPacket(p); hope this helps you out Can you show this file? I have some trouble with PacketType.KICK, i don't know namespace Sad Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 29 October 2007. Открыть источник. |
|
|
#6 |
|
Guest
Posts: n/a
|
NC.ToolNet.Net.Client.CLTSocket sock = new NC.ToolNet.Net.Client.CLTSocket();
Packer p = new Packer((byte)0); p.AddInt32(5); p.AddInt32(222); p.AddString("admin"); byte[] sourceArray = p.ToArray(); int num = sourceArray.Length - 1; byte[] destinationArray = new byte[num + 3]; destinationArray[0] = (byte)(num & 0xff); destinationArray[1] = (byte)((num & 0xff00) >> Cool; Array.Copy(sourceArray, 0, destinationArray, 2, sourceArray.Length); //GetStream().Write(destinationArray, 0, destinationArray.Length); //GetStream().Flush(); System.Net.Sockets.TcpClient cliente = new System.Net.Sockets.TcpClient(); cliente.Connect("localhost", 2012); if (cliente.Connected) { Console.WriteLine("Conected..."); //System.IO.StreamWriter sw = new StreamWriter(cliente.GetStream()); //sw.Write(destinationArray, 0, destinationArray.Length); cliente.GetStream().Write(destinationArray, 0, destinationArray.Length); cliente.Close(); } Console.ReadLine(); } Don't works Sad(( Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 29 October 2007. Открыть источник. |
|
|
#7 |
|
Guest
Posts: n/a
|
Can somebody help to do same function, but on pascal (delphi) ?
Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 29 October 2007. Открыть источник. |
|
|
#8 |
|
Guest
Posts: n/a
|
GMan can u post the references that nc.toolset uses? i wish to try it in this way, i cant make it work just adding it to my project, if not, do u know the packet structure? i guess its an struct, but will be nice if someone can bring me a bit of light on this. thanks in advance
Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 8 November 2007. Открыть источник. |
|
|
#9 |
|
Guest
Posts: n/a
|
Packer p = new Packer((byte)0); ---->>> ??!!! try for example 1, the packet to check if a char its online-
p.AddInt32(5); ---------------------------> ??? no sense here. p.AddInt32(222); p.AddString("admin"); try it in this way: Packer p = new Packer((byte)1); p.AddInt32(222); //use for example the id of ur gm char. //packet ready. if works u should see a msg at cached telling u its checking for that charid if not..nothing. good luck! Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 8 November 2007. Открыть источник. |
|
|
#10 |
|
Guest
Posts: n/a
|
ima be a good boy..
this is a working code. private int SendPacket(string ipserver,Packer pakete) { try { System.Net.Sockets.TcpClient supersocket = new System.Net.Sockets.TcpClient(); supersocket.Connect (ipserver,2012); //si no pega excepcion abrimos el stream de escritura... NetworkStream sstream = supersocket.GetStream(); byte[] sourceArray = pakete.ToArray(); int num = sourceArray.Length - 1; byte[] destinationArray = new byte[num + 3]; destinationArray[0] = (byte)(num & 0xff); destinationArray[1] = (byte)((num & 0xff00) >> Cool; Array.Copy(sourceArray, 0, destinationArray, 2, sourceArray.Length); sstream.Write(destinationArray, 0, destinationArray.Length); supersocket.Close(); sstream.Flush(); return(0); } catch (SocketException se) { //algo anormal ha ocurrido y se ha lanzado una excepcion del socket. return (2);//error. } } public int CheckCharStatus(string ipserver, int charid) { Packer paketito=new Packer ((byte) 1); paketito.AddInt32(4); //0 char offline, 1 char online, 2 error. return (SendPacket(ipserver,paketito)); } hope this helps to u. GMan obviously i found what i was doing wrong, now its working...thanks anyway... btw i made this functions to help this guy, obviously it doesnt reads the answer from server blah blah blah xd Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 8 November 2007. Открыть источник. |
|
|