[-]
Shout:
Click Refresh to load shouts.

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trade Say - what's wrong
11-01-2009, 04:39 PM (This post was last modified: 11-02-2009 06:33 PM by Ian. Edit Reason: Added code highlighting)
Post: #1
Trade Say - what's wrong
Hello,

I have edited say function to say function but I don't know what's wrong in that.

select delphi
procedure tradesay(text:string);
var
PacketBuffer: array [0..200] of byte;
ProcessID: Cardinal;
 
begin
GetWindowThreadProcessId(FindWindow('TibiaClient', Nil), @ProcessID);
 
PacketBuffer[0] := Byte(Length(text) + 4);
PacketBuffer[1] := $00;
PacketBuffer[2] := $96;
PacketBuffer[3] := $07;
PacketBuffer[4] := $06;
PacketBuffer[5] := $00;
PacketBuffer[6] := Byte(Length(text));
PacketBuffer[7] := $00;
CopyMemory(@PacketBuffer[8], @text[1], Length(text));
SendPacket(ProcessID, @PacketBuffer, TRUE, FALSE);
end;


When I send it to server Tibia cuts last 2 digits!
How to manage it?

Muttley
Find all posts by this user
Quote this message in a reply
11-02-2009, 05:39 PM
Post: #2
RE: Trade Say - what's wrong
Whats wrong?

The data length.
Find all posts by this user
Quote this message in a reply
11-02-2009, 06:35 PM
Post: #3
RE: Trade Say - what's wrong
select delphi
procedure tradesay(text:string);
PacketBuffer[0] := Byte(Length(text) + 4);

should be:
select delphi
procedure tradesay(text:string);
PacketBuffer[0] := Byte(Length(text) + 6);

OpenTibiaTools, TibiaAPI, SharpOT
Visit this user's website Find all posts by this user
Quote this message in a reply
11-03-2009, 07:48 AM
Post: #4
RE: Trade Say - what's wrong
Big thanks Smile
It works.
Find all posts by this user
Quote this message in a reply
11-03-2009, 12:20 PM
Post: #5
RE: Trade Say - what's wrong
(11-03-2009 07:48 AM)muttley Wrote:  Big thanks Smile
It works.

Going forward, it would be easier for you to create a packet building class, like TibiaAPI's NetworkMessage. Then you don't have to worry about the size of the packet, adding the headers, encrypting, and all that stuff every time you just want to build a simple packet.

OpenTibiaTools, TibiaAPI, SharpOT
Visit this user's website Find all posts by this user
Quote this message in a reply
11-04-2009, 10:10 AM
Post: #6
RE: Trade Say - what's wrong
(11-03-2009 12:20 PM)Ian Wrote:  
(11-03-2009 07:48 AM)muttley Wrote:  Big thanks Smile
It works.

Going forward, it would be easier for you to create a packet building class, like TibiaAPI's NetworkMessage. Then you don't have to worry about the size of the packet, adding the headers, encrypting, and all that stuff every time you just want to build a simple packet.


Yep, if you do a networkmessage class your code will be more clean and easier to maintences..
Find all posts by this user
Quote this message in a reply
Post Reply 



Contact UsTProgrammingReturn to TopReturn to ContentLite (Archive) ModeRSS Syndication