Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
[C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6) - Page 2
Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

  1. #11
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    2 bytes packet length
    1 byte packet type (0x14)
    2 bytes motd length
    x bytes motd (id:0-255 + message, example: 123 + "\n\nyaddayadda")
    0x64 (not sure what this is)
    1 byte amount of characters
    --- loop this
    ---2 bytes character name length
    ---x bytes character name
    ---2 bytes server name length
    ---x bytes server name
    ---4 bytes server ip
    ---2 bytes server port
    2 bytes premium days

    Your disconnect packet doesn't work because the packet data length is 4, not 6 (packet length does not count the first 2 bytes holding the packet length)

    edit: your disconnect packet is probably wrong (I never had to send one, closing the socket is enough), as your packet length is much longer than the packet itself
    edit2: pretty sure the server is the one who always closes connections

  2. #12

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Aight so I'm on it, but it's debugging my client rolfmao.

    [code=c#]
    public NetworkMessage Parse(CharacterListPacket msg)
    {
    NetworkMessage pMsg = new NetworkMessage(0);

    string MotdMsg = "Welcome to Nowhere!";

    pMsg.AddByte(0x14); // Packet Type
    pMsg.AddString(MotdMsg);
    pMsg.AddByte(0x64);
    pMsg.AddByte(Convert.ToByte(msg.Characters.Count)) ; // Characters Count
    for (int i = 1; i <= msg.Characters.Count - 1; i++)
    {
    pMsg.AddString(msg.Characters[i].Name);
    pMsg.AddString(msg.Characters[i].WorldName);
    pMsg.AddUInt32(msg.Characters[i].Ip);
    pMsg.AddUInt16(msg.Characters[i].Port);
    }
    pMsg.AddUInt16(100);

    return pMsg;
    }
    [/code][hr]
    Edit;

    DisconnectedMessage packet works now:

    [code=c#]
    public NetworkMessage Parse(string Message)
    {
    NetworkMessage msg = new NetworkMessage(0);

    int size = 3 + Message.Length;
    msg.AddByte(Convert.ToByte(size));
    msg.AddByte(0x00);
    msg.AddByte(0x0A);
    msg.AddString(Message);

    return msg;
    }
    [/code]

    Ima check now the CharacterList packet.

  3. #13
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    You're looping the msg.Characters wrong.
    [code=c#]
    for (int i = 0; i < msg.Characters.Count; i++)
    [/code]
    Also, you didn't add an id nor a newline to the motd, like so: "123\nWelcome to nowhere!"
    The id is stored in Tibia.cfg (I think) and is used to now show the same motd more than once. The id can be any number between 0 and 255

    edit: if you want the motd to always show up:
    [code=c#]
    msg.AddString(new Random().Next(255) + "\nMessage of the day");
    [/code]
    There is a tiny chance it will have the same id as the previous id and thus not show up, but the odds are very slim (<0.5%)

  4. #14

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Alright, so...

    Got any idea to add the size of the packet in the beginning? That's now why it's debugging my client.

    Edit:

    Completed!! :-)

    Forgot that NetworkMessage class has a function named "InsertTotalPacketLength", so first I add 2 empty bytes, corresponding to be the length of the packet, and once my packet is done I call this function, adding the 2 bytes of the packet length. And it's working now!!

    Thank you dude!

    However IP is 4 bytes sure?. Cause client tells me Invalid server address.

  5. #15
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Yes, although keep in mind it's a byte array, not a 32-bit integer, so "127.0.0.1" would be {127,0,0,1}

  6. #16

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Great!

    Anyway, how is it the exact way to make a proxy through this way?.

    I have no idea how to manage packets from Server and send them to the client, got a tutorial around?.

  7. #17
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Both sockets (client <-> proxy and proxy <-> server) needs to "see" eachother, so either declare two TcpClient objects that belongs to the class (can also be declared statically for access cross classes) or write a small class that holds both sockets

  8. #18

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Hmm then how can I access to the server connection?. I need an IPAddress?.

    I see this way;

    TcpClient Server;
    TcpClient Client;

    Then Server gets packets from real Server and sends them to Client, Client sends packets to Server, and it sends them to real server?.

  9. #19
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    You should read the login server data before changing it to your local IP (127.0.0.1). When you receive the login packet you connect to the login server, like so:
    [code=c#]
    try
    {
    Server = new TcpClient();
    Server.Connect(string ip, int port);
    }
    catch {} // failed
    [/code]
    Then make a new thread where the packets are forwarded to Client (TcpClient). Remember to close Client's connection whenever Server's connection is closed.

    When you've done this, you need to change the character list packet so the client will connect to your local IP. You can either change the packet directly or write to memory. Remember to store the character list data before changing it.

  10. #20
    Senior Member
    Join Date
    Feb 2024
    Location
    SLOT GACOR
    Posts
    657

    Recommended Product Site

    Please try Google before asking about Cool Product Tips 2289ded

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •