Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Packet format for selling item to NPC
Author Message
mandymua Offline
Expired VIP Member
**

Posts: 37
Joined: Dec 2013
Reputation: 2
Version: 1.4.2.142
Post: #1
Packet format for selling item to NPC

Since l2t sell-to-NPC function is not working and we don't know when it's gonna be fixed, I am trying to make a custom one using packet builder. However, I am unable to understand the meanings of all fields in the packet. Please help me out.

Here is the packet I captured when selling a single Healing Potion:

C[0] = 0x37 <--- packet ID, constant
D[1] = 0x06B87FCF <---- I don't know what this is
D[5] = 0x00000001 <----- the total number of items
B[9]:
72 6A C5 40 24 04 00 00 01 00 00 00 00 00 00 00

"04 24" or 0x424 seems to be item's display ID (1060)
"01" seems to be item's number that you want to sell
"72 6A C5 40" or 0x40C56A72 should be the item's object ID, however, it doesn't match the item's ojbect ID I printed out with item.objectId from my inventory (1086679666 vs 1084407337)

Any help with decoding this packet's format is much appreciated!
(This post was last modified: 07-03-2015 20:21 PM by mandymua.)
07-03-2015 20:20 PM
Find all posts by this user Quote this message in a reply
mandymua Offline
Expired VIP Member
**

Posts: 37
Joined: Dec 2013
Reputation: 2
Version: 1.4.2.142
Post: #2
RE: Packet format for selling item to NPC

Devs, pros, anyone help!
@Clockman, @Sakaszli, @Vinter

I also found out that the new (correct) packet ID is 0x37 while the old one is 0x40. Devs, can you please change the packet ID to 0x37 for selling item to NPC to see if it works?
(This post was last modified: 07-04-2015 10:21 AM by mandymua.)
07-04-2015 08:33 AM
Find all posts by this user Quote this message in a reply
amiroooo Offline
Beta Tester

Posts: 1,270
Joined: Sep 2011
Reputation: 412
Version: 1.4.2.142
Post: #3
RE: Packet format for selling item to NPC

its exactly as it looks lol, d1 is objectId obviously,b9 is simply copy paste whole block from the items in list for sale packet..
07-04-2015 10:58 AM
Find all posts by this user Quote this message in a reply
mandymua Offline
Expired VIP Member
**

Posts: 37
Joined: Dec 2013
Reputation: 2
Version: 1.4.2.142
Post: #4
RE: Packet format for selling item to NPC

(07-04-2015 10:58 AM)amiroooo Wrote:  its exactly as it looks lol, d1 is objectId obviously,b9 is simply copy paste whole block from the items in list for sale packet..

Thanks for replying, Amiroo but I don't quite understand. You meant D1 is object ID of the item I am selling? But the objectID of my healing potion is not that one so I guess that's not what you meant.

Also, when I clicked on the Sell button, I only saw the above 0x37 packet. Am I missing that list for sale packet somewhere?
(This post was last modified: 07-04-2015 18:31 PM by mandymua.)
07-04-2015 17:15 PM
Find all posts by this user Quote this message in a reply
Vinter Offline
Expired VIP Member
**

Posts: 299
Joined: Sep 2013
Reputation: 109
Version: 1.4.1.128
Post: #5
RE: Packet format for selling item to NPC

    LUA Programming
function GetItemByName(itemname)
	invList = GetInventory();
	for item in invList.list do
		if item.Name == itemname then
		ShowToClient("obj",tostring(item.objectId))
		ShowToClient("dis",tostring(item.displayId))
			return item.objectId,item.displayId
		end;
	end;
end;
 
 
function SellItemByName(name, amount)
objid,itemid = GetItemByName(name)
packet = PacketBuilder();
packet:AppendInt(0x37,1); -- Packet Id
packet:AppendInt(objid,4) -- objectid
packet:AppendInt(itemid,4) -- displayid
packet:AppendInt(amount,8)
SendPacket(packet);
end
 
--GetItemByName("Ring of Wisdom")
SellItemByName("Ring of Wisdom",1)



try this, roughly coded, but try it anyway Tongue. This would only sell one item though, will have to add objid, disid, and amount per item, and then send the huge-ass packet.. so.. would need a function to create the packet based on items, which should only be an array and some code.
(This post was last modified: 07-04-2015 17:43 PM by Vinter.)
07-04-2015 17:29 PM
Find all posts by this user Quote this message in a reply
mandymua Offline
Expired VIP Member
**

Posts: 37
Joined: Dec 2013
Reputation: 2
Version: 1.4.2.142
Post: #6
RE: Packet format for selling item to NPC

Thanks a lot Vincent for the codes!

However, I tried it with SellItemByName("Major Healing Potion",1) and SellItemByName("Healing Potion",1) and nothing got sold, the objectID and displayID printed on the screen are correct though.

I even opened the NPC trading window in advance but it still didn't work. I am wondering what I did wrong here?

I basically copied and pasted your code in a script file and then run the script.

Also, Vincent, do you by any chance know what is D1 in the packet that I posted? I am pretty sure it's not the object ID of my healing potion because the correct one is "72 6A C5 40", not 0x06B87FCF.

C[0] = 0x37 <--- packet ID, constant
D[1] = 0x06B87FCF <---- I don't know what this is
D[5] = 0x00000001 <----- the total number of different items to sell
B[9]:
72 6A C5 40 24 04 00 00 01 00 00 00 00 00 00 00

Do you see the same packet format when you sell an item to NPC?
(This post was last modified: 07-04-2015 18:44 PM by mandymua.)
07-04-2015 18:27 PM
Find all posts by this user Quote this message in a reply
Vinter Offline
Expired VIP Member
**

Posts: 299
Joined: Sep 2013
Reputation: 109
Version: 1.4.1.128
Post: #7
RE: Packet format for selling item to NPC

It's easy.. if packet isn't exactly as it should be, it does nothing.. so mby something's off.

Pre-god you needed a lot more than objid.. npcid*100, total items and a few more stuff but it worked lol.

If you convert 72 6A C5 40 to int32 it's 1086679666, probabbly your potion's objectid, isn't it? Smile

24 04 00 00 -> 1060, displayId of your potion.

so it breaks down to:

72 6A C5 40 objid
24 04 00 00 displayid
01 00 00 00 00 00 00 00 amount

mby it's the amount part.

    LUA Programming
function GetItemByName(itemname)
	invList = GetInventory();
	for item in invList.list do
		if item.Name == itemname then
		ShowToClient("obj",tostring(item.objectId))
		ShowToClient("dis",tostring(item.displayId))
			return item.objectId,item.displayId
		end;
	end;
end;
 
 
function SellItemByName(name, amount)
objid,itemid = GetItemByName(name)
packet = PacketBuilder();
packet:AppendInt(0x37,1); -- Packet Id
packet:AppendInt(objid,4) -- objectid
packet:AppendInt(itemid,4) -- displayid
packet:AppendDataFromHexString("01 00 00 00 00 00 00 00")
SendPacket(packet);
end
 
--GetItemByName("Ring of Wisdom")
SellItemByName("Ring of Wisdom",1)



check if that works


I based this on my sellitem packet for h5, and I don't even have infinite odyssey installed... will download it while I'm at work today
(This post was last modified: 07-04-2015 18:55 PM by Vinter.)
07-04-2015 18:52 PM
Find all posts by this user Quote this message in a reply
mandymua Offline
Expired VIP Member
**

Posts: 37
Joined: Dec 2013
Reputation: 2
Version: 1.4.2.142
Post: #8
RE: Packet format for selling item to NPC

I see. Currently I am running Odysses, maybe that's why. Thanks very much for explaining the packet format to me but actually the part I don't understand is D[1].

C[0] = 0x37 <--- packet ID, constant
D[1] = 0x06B87FCF <---- I don't know what this is
D[5] = 0x00000001 <----- the total number of different items to sell
B[9]:
72 6A C5 40 24 04 00 00 01 00 00 00 00 00 00 00

What might "0x06B87FCF" be? It changed every time I sell. For example, 2 consecutive times I sell a healing potion:

C[0] = 0x37
D[1] = 0x06BB2207
D[5] = 0x00000001
B[9]:
C1 89 39 41 24 04 00 00 01 00 00 00 00 00 00 00

C[0] = 0x37
D[1] = 0x0531C352
D[5] = 0x00000001
B[9]:
C1 89 39 41 24 04 00 00 01 00 00 00 00 00 00 00

Everything is the same but D[1].
(This post was last modified: 07-04-2015 19:16 PM by mandymua.)
07-04-2015 19:14 PM
Find all posts by this user Quote this message in a reply
Vinter Offline
Expired VIP Member
**

Posts: 299
Joined: Sep 2013
Reputation: 109
Version: 1.4.1.128
Post: #9
RE: Packet format for selling item to NPC

Because you're using a stacked item, and the stack changes (from 250 to 249 or something), it changes the d1.
07-04-2015 19:27 PM
Find all posts by this user Quote this message in a reply
mandymua Offline
Expired VIP Member
**

Posts: 37
Joined: Dec 2013
Reputation: 2
Version: 1.4.2.142
Post: #10
RE: Packet format for selling item to NPC

I see, but still how do I get the value of D[1]? I still don't think D[1] is the objectID of my healing pot because my healing pot's objectID is stored in B[9] and its value is 0x40C56A72 (yellow text)

C[0] = 0x37 <--- packet ID, constant
D[1] = 0x06B87FCF <---- I don't know what this is
D[5] = 0x00000001 <----- the total number of different items to sell
B[9]:
72 6A C5 40 24 04 00 00 01 00 00 00 00 00 00 00
healing pot's objectID healing pot's displayID sell 1 healing pot
(This post was last modified: 07-04-2015 19:59 PM by mandymua.)
07-04-2015 19:58 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Script item using before hitting mob TMBlack 0 262 01-29-2019 12:24 PM
Last Post: TMBlack
  Weird pickup item capucine 1 1,013 11-23-2018 14:38 PM
Last Post: Fadden
  how do get Daily Mission item for script or plugins? king200527 0 1,023 10-26-2015 17:03 PM
Last Post: king200527
  Sell item to shop doesnt work. mandymua 21 4,243 07-03-2015 01:03 AM
Last Post: mandymua
  Item ID steinerff10 5 1,404 06-10-2015 16:42 PM
Last Post: steinerff9
  Item Use Script/plug gm1904 3 1,473 05-26-2015 19:10 PM
Last Post: plixplox
  Item to Ware necrulex 4 1,612 05-03-2015 15:55 PM
Last Post: bistabil
  It recognises chr's item-hp-skills etc but doesn't work d3adlock 0 1,011 09-30-2014 17:11 PM
Last Post: d3adlock
  Weird pickup item capucine 0 1,057 07-24-2014 22:48 PM
Last Post: capucine
  packet reader error elessar 1 1,563 06-29-2014 09:48 AM
Last Post: nektarios007



User(s) browsing this thread: 1 Guest(s)