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
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
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%)
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.
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
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.