Creat autosort in plugin

Hi guys.
Help me please.
How to write autosort command in a plugin?

I wrote a plugin for myself where I am fusing tablets. After each fused tablet I am moving the newly created stone on a slot with the same stone:
Here is the code I am using for the injection to move a stone.
I only tested it on a private server, but for me it seems like the inventory move packet is built the following way:
xx = slot in the inventory of the source item
yy = target slot
bb and aa = the amount of items in the source slot as hex value, but somehow the amount is written in a reversed way. E.g. amount of 1 = 01 00 instead of 00 01, 255 would be FF 00 instead of 00 FF, and 5000 would be 88 13 instead of 13 88
00 xx yy bb aa

You get the slot and the amount of items in the slot from get_inventory().
I hope this will help you to write your plugin.
Maybe you can share it once you´re finished. :slight_smile:

def inject_stone_move():
	Packet = bytearray()
	append_string_packet_data(Packet, "00".split())
	append_string_packet_data(Packet, "01 00".split())
		log('Plugin '+pName+': Moving stone from inventory slot '+ str(sourceStoneSlot)+' to slot ' +str(targetStoneSlot)+'.')	

def append_string_packet_data(packet, data):
	i = 0
	while(i < len(data)):
		i += 1
1 Like

Thank. It’s good.
But I do not know how to make autosort in the plugin after creating the stones.
Can anyone tell me?

Packet Structure :

00 byte = inventory type (pet, storage, character, even transport I think)
0D byte = slot (from)
06 byte = slot (to)
00 00 ushort = quantity moved (If his max. stack is 1 then doesn’t matter as this case)


import struct
Packet = struct.pack('B', 0)
Packet += struct.pack('B', slotFrom)
Packet += struct.pack('B', slotTo)
Packet += struct.pack('H', quantityMoved)

I left a lot of examples at my sources about how to read/write packet data from python.

1 Like

Using strings is so VB6.

Thanks alot!
I just started learning python like 2 weeks ago. Good to know that struct is the way to go :slight_smile:

Can I ask you how you figured out the packet structure? Is there any API documentation about it?

did it work ?