Post Pacific  

Go Back   Post Pacific > Lineage 2 > Lineage 2 General

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 27.10.2007, 22:00   #1
bvmster
Guest
 
Posts: n/a
Default Cached C#

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. Открыть источник.
 
Old 28.10.2007, 22:00   #2
~Marquis~
Guest
 
Posts: n/a
Default Cached C#

You're writing a L2admin in C#?

Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 29 October 2007. Открыть источник.
 
Old 28.10.2007, 22:00   #3
bvmster
Guest
 
Posts: n/a
Default Cached C#

Quote:


Originally Posted by ~Marquis~

You're writing a L2admin in C#?

Yes. Wink

Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 29 October 2007. Открыть источник.
 
Old 28.10.2007, 22:00   #4
GMan
Guest
 
Posts: n/a
Default Cached C#

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();
            }
        }
so basically what you want to do is


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. Открыть источник.
 
Old 28.10.2007, 22:00   #5
bvmster
Guest
 
Posts: n/a
Default Cached C#

Quote:


Originally Posted by GMan

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();
            }
        }
so basically what you want to do is


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. Открыть источник.
 
Old 28.10.2007, 22:00   #6
bvmster
Guest
 
Posts: n/a
Default Cached C#

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. Открыть источник.
 
Old 28.10.2007, 22:00   #7
Forcer
Guest
 
Posts: n/a
Default Cached C#

Can somebody help to do same function, but on pascal (delphi) ?

Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. В снимке указана только дата, без времени: 29 October 2007. Открыть источник.
 
Old 07.11.2007, 22:00   #8
wendigo
Guest
 
Posts: n/a
Default Cached C#

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. Открыть источник.
 
Old 07.11.2007, 22:00   #9
wendigo
Guest
 
Posts: n/a
Default Cached C#

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. Открыть источник.
 
Old 07.11.2007, 22:00   #10
wendigo
Guest
 
Posts: n/a
Default Cached C#

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. Открыть источник.
 
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 16:27.