I'll be posting up some useful delphi code here every so often for those that don't know how to do certain things.
Find Item:
Code:
Function FindItem(ID_Item:integer):TItemBp;
var
BP, slot:byte;
Begin
Result.found :=False;
For Bp:=0 to 15 do
Begin
If MemReadByte(Adr_bp_Open+(Dist_bp*bp)) = 1 then
Begin
For slot:=0 to MemReadByte(Adr_bp+(Dist_bp*bp)-4) do
Begin
if ID_Item = MemReadSmallInt(adr_Bp+(Dist_bp*bp)+(12*slot)) then
Begin
Result.BP:= bp;
Result.slot:= slot;
Result.found :=True;
Exit;
End;
End;
End;
End;
End;
Some memory functions:
Code:
function MemReadByte(Address: Integer): Byte;
var Value:Byte;
begin
ReadProcessMemory(TibiaClient.IDProcess, Ptr(Address), @Value, 1, TibiaClient.NBR);
Result := Value;
end;
function MemReadSmallInt(adress:integer): SmallInt;
var
value : SmallInt;
Begin
ReadProcessMemory(TibiaClient.IDProcess, Ptr(adress), @Value, 2, TibiaClient.NBR);
Result:=Value;
End;
Count items function:
Code:
function getamount(itemid:integer):integer;
var
amount,i,x:integer;
begin
amount:=0;
for i:=0 to 15 do
begin
If MemReadByte(Adr_bp_Open+(Dist_bp*i)) = 1 then
Begin
For x:=0 to MemReadByte(Adr_bp+(Dist_bp*i)-4) do
Begin
if itemid = MemReadSmallInt(adr_Bp+(Dist_bp*i)+(12*x)) then
Begin
amount:=amount+1;
End;
End;
End;
end;
result:=amount;
end;
Move item from to:
Code:
procedure packetsend_movefromto(slotto:byte;count:byte; item_ID:smallint);
var
Pid:Cardinal;
begin
GetWindowThreadProcessId(FindWindow('TibiaClient', nil), @Pid);
item:= FindItem(item_ID);
if (item.found=true) then
begin
packetBuffer[0]:= $0F;
packetBuffer[1]:= $00;
packetBuffer[2] := $78;
packetBuffer[3] := $FF;
packetBuffer[4] := $FF;
packetBuffer[5] := $40+item.bp;
packetBuffer[6] := $00;
packetBuffer[7] := item.slot;
packetBuffer[8] := $4B;
packetBuffer[9] := $0C;
packetBuffer[10] := item.slot;
packetBuffer[11] := $FF;
packetBuffer[12] := $FF;
packetBuffer[13] := Slotto;
packetBuffer[14] := $00;
packetBuffer[15] := Slotto;
packetBuffer[16] := Count;
SendPacket(Pid, @PacketBuffer, TRUE, FALSE);
end;
end;