Character Select / Creator


#1

This plugin can be used to select the first character that appears in the listing. This plugin will not function until 21.2.1 or 16.1.6.

from phBot import *

def character_listing(args):
    for name in args:
        if not name.startswith('*'):
            log('Selecting %s' % name)
            select_character(name)
            break
    return 0

log('[%s] Loaded' % __name__)

#2

This plugin creates a character with a random name if no other characters exist on the account - otherwise it will auto select the first one in the listing.

Change ‘CH’ to ‘EU’ to create a European character. This will not function until 21.2.2 / 16.1.6.

from phBot import *
from struct import pack
import string
import random

CHARACTER_TYPE = 'CH'

create = False
request_listing = False

def create_character(name):
    global CHARACTER_TYPE

    if CHARACTER_TYPE == 'CH':
        c_model = get_monster_string('CHAR_CH_MAN_ADVENTURER')['model']
        chest = get_item_string('ITEM_CH_M_HEAVY_01_BA_A_DEF')['model']
        legs = get_item_string('ITEM_CH_M_HEAVY_01_LA_A_DEF')['model']
        shoes = get_item_string('ITEM_CH_M_HEAVY_01_FA_A_DEF')['model']
        weapon = get_item_string('ITEM_CH_SWORD_01_A_DEF')['model']
    elif CHARACTER_TYPE == 'EU':
        c_model = get_monster_string('CHAR_EU_MAN_NOBLE')['model']
        chest = get_item_string('ITEM_EU_M_HEAVY_01_BA_A_DEF')['model']
        legs = get_item_string('ITEM_EU_M_HEAVY_01_LA_A_DEF')['model']
        shoes = get_item_string('ITEM_EU_M_HEAVY_01_FA_A_DEF')['model']
        weapon = get_item_string('ITEM_EU_DAGGER_01_A_DEF')['model']
    else:
        log('Invalid character type (CH or EU)')
        return

    if c_model == 0 or chest == 0 or legs == 0 or shoes == 0 or weapon == 0:
        log('Could not retrieve item models')
        return

    log('Creating character with name %s and type %s' % (name, CHARACTER_TYPE))

    p = b'\x01'
    p += pack('H', len(name))
    p += name.encode('ascii')
    p += pack('I', c_model)
    p += pack('B', 0)
    p += pack('I', chest)
    p += pack('I', legs)
    p += pack('I', shoes)
    p += pack('I', weapon)
    inject_joymax(0x7007, p, False)

    request_listing = True

def character_listing(args):
    global create

    if len(args) == 0:
        create = True
    else:
        for name in args:
            if not name.startswith('*'):
                log('Selecting %s' % name)
                select_character(name)
                break
    return 0

def event_loop():
    global create, request_listing

    if create:
        create = False
        name = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10))
        create_character(name)
    elif request_listing:
        request_listing = False
        inject_joymax(0x7007, b'\x02', False)

log('[%s] Loaded' % __name__)

pinned #3

#4

Hi, I’ve never used plugin before, can you pls walk me through it?
like how to use or where to add and how to use in manager… etc? ^^
thanks in advance.


#5

It is explained pretty well above. To use it you must install the Python plugin APIs from here: Download


#6

Is there a way to create and select 2nd or 3rd char ?


#7

Possible. It is using like condition : “Not having any character at the account”

Replace this function only and this will create characters “if the account is not full of chars at deleting mode” or that’s what I think :slight_smile:

def character_listing(args):
    global create
    if len(args) == 0:
        create = True
    else:
        deleting = 0
        for name in enumerate(args):
            if not name.startswith('*'):
                log('Selecting %s' % name)
                select_character(name)
                deleting = -1
                break
            else:
                deleting += 1
        if deleting != -1 and deleting < 4:
            create = True
        else:
            log('Account full, all your chars are at deleting mode')
    return 0

A better condition will be like “if the character to select is level > 39” but require more editing than this…


#8

This pluging work for academy?


#9

That’s what it’s meant for, yes.


#10

Also this select characters <39?


#11

No. There is no level data in the API I provide. It just lists the characters.


#12

some way to know when level 40 and eliminate it.


#13

It’s in the packet. I’d have to add that info to the API.


#14

Could you do it ?, I would like to have a complete plugins for the academy


#15

@Ryan when you will add to the API this packet?


#16

No idea.


#17

does this still work? It say creating character and gets stuck on the char selecting window


#18

It should.


#19

Ok thought I could help with something, but it seems that “inject_joymax” is set to GatewayServer until a character is selected and joined_game() is triggered. :sweat_smile:


#20

That’s not accurate. If you are sending that the instant you get the character listing packet it’s possible the server is not allowing it. The bot sends whatever packet you inject no matter if you are in game or not.

Edit: I don’t think you’re sending the name length in the delete character function.