Since there is not API for the Unique Spawns I have to use the 0x300C opcode to detect unique spawns.
My current problem is the data.
It looks something like b’\x06\x0c\xc8\xa1\x00\x00\x08\x00Mszecsod’.
How do I convert it to a ascii or utf-8 string?
I have tried many things but nothing actually worked.
EVENT_UNIQUE_SPAWN = 0 # data = monster name
EVENT_HUNTER_SPAWN = 1 # data = player name (includes traders)
EVENT_THIEF_SPAWN = 2 # data = player name
EVENT_TRANSPORT_DIED = 3 # data = transport id (includes horses)
EVENT_PLAYER_ATTACKING = 4 # data = player name
EVENT_RARE_DROP = 5 # data = item model (equippable only)
EVENT_ITEM_DROP = 6 # data = item model (equippable only)
EVENT_DIED = 7 # data = empty string
EVENT_ALCHEMY_FINISHED = 8 # data = empty string
def handle_event(t, data):
if t == EVENT_UNIQUE_SPAWN:
log('%s spawned' % (data))
Well been running this now for 35min and not a single log yet … even tho a lot of uniques appeared already. What am I doing wrong?
from phBot import *
# Called for specific events. data field will always be a string.
def handle_event(t, data):
if t == EVENT_UNIQUE_SPAWN:
log('%s spawned' % (data))
log('Loaded plugin!')
from phBot import *
SERVER_NOTICE_UNIQUE_UPDATE = 0x300C
# All packets received from Silkroad will be passed to this function
# Returning True will keep the packet and False will not forward it to the game server
def handle_joymax(opcode, data):
if opcode == SERVER_NOTICE_UNIQUE_UPDATE:
byte type
if type == 5:
byte unkByte
uint uniqueModelID
// Do stuffs
unique = get_monster(int(uniqueModelID))
log("["+unique['name']+"] appeared.")
elif type == 6:
byte unkByte
uint uniqueModelID
ushort killerNameLength
ascii killerName
// Do stuffs
unique = get_monster(int(uniqueModelID))
log("["+unique['name']+"] killed by ["+killerName+"]")
return True
It doesn’t work actually, but you will figure out all the rest, I left at my sources examples about how to.
However the next step is sending it to Discord via a webhook.
Somehow whenever I wanna import anything within my script then it is not loading anymore by phbot.
For example if i write import aiohttp on top of the script then it is failing to load
I guess aiohttp is not available in the phbot python lib.
If it is not available, you need to install it yourself.
Check the following post of lucius, may it helps you.