First you need to identify the ID of the npc you want to interact with. You can do so with something like this:
def getNPCID():
npcs = get_npcs()
for id, npc in npcs.items():
npc_name = npc['name']
if npc_name[:5] == 'Daily':
return id
return
Then you need to generate a struct with that NPC ID that you will inject to joymax. Like this:
p = struct.pack('I',npc_id)
inject_joymax(0x7045,p,False)
Injecting that will open the NPC dialog window with your desired NPC if you are within range of it.
You will then want to keep adding to that struct with the id of the option you want to select from the NPC dialog window, like this:
p += struct.pack('B',2)
inject_joymax(0x7046,p,False)
For more info on the inject_joymax function check out the phBot API documentation here: Packet Injection - phBot Plugins
If you are struggling to build your packets to inject, I’d recommend using PacketLogger or xPacketTool and manually checking what packets are sent to the server when you click on the desired dialog options from the NPC.
Hope it was useful.
If you want more info, maybe you will find it helpful to check out the code of this plugin i created to get and return the daily SP quests: phBot-plugins/EasySPplugin.py at main · joranro1997/phBot-plugins · GitHub