Arena

This is an plugin from the old forum that allows you to register for different arena events.

from phBot import *
import struct
from datetime import datetime

log('[Plugin] Succesfully loaded [%s].' % __name__)

ArenaType = ''

def handle_joymax(opcode, data):
	if opcode == 0x34D2:
		if data[0] == 0xFF and data[1] == 0x00 and data[2] == 0x01 and data[3] == 0x01:
			log('[Arena] Successfully registered to arena: %s' % ArenaType)
			stop_bot()
	return True

def arena(arguments):
	NPCID = 0
	Time = datetime.utcnow()
	Hours = int(Time.strftime('%H'))
	Minutes = int(Time.strftime('%M'))
	Seconds = int(Time.strftime('%S'))

	if (Minutes == 35 and Seconds >= 5) or (Minutes > 35 and Minutes < 45):
		NPCs = get_npcs()
		for UniqueID, NPC in NPCs.items():
			if NPC['name'] == 'Arena Manager':
				NPCID = UniqueID
				break

		if NPCID != 0:
			global ArenaType
			ArenaType = ''
			Packet = bytearray()
			Packet.append(0x01)

			# if Hours == 18:
			# 	ArenaType = 'Job Flag'
			# 	Packet.append(0x03)
			# 	Packet.append(0x02)
			# elif Hours == 6:
			# 	ArenaType = 'Job Points'
			# 	Packet.append(0x03)
			# 	Packet.append(0x01)
			if Hours == 1 or Hours == 2 or Hours == 3 or Hours == 4 or Hours == 5 or Hours == 6 or Hours == 7 or Hours == 8 or Hours == 9 or Hours == 10 or Hours == 11 or Hours == 12 or Hours == 13 or Hours == 14 or Hours == 15 or Hours == 16 or Hours == 17 or Hours == 18 or Hours == 19 or Hours == 20 or Hours == 21 or Hours == 22 or Hours == 23 or Hours == 24:
				ArenaType = 'Random Flag'
				Packet.append(0x00)
				Packet.append(0x02)
			elif Hours == 1 or Hours == 2 or Hours == 3 or Hours == 4 or Hours == 5 or Hours == 6 or Hours == 7 or Hours == 8 or Hours == 9 or Hours == 10 or Hours == 11 or Hours == 12 or Hours == 13 or Hours == 14 or Hours == 15 or Hours == 16 or Hours == 17 or Hours == 18 or Hours == 19 or Hours == 20 or Hours == 21 or Hours == 22 or Hours == 23 or Hours == 24:
				ArenaType = 'Random Points'
				Packet.append(0x00)
				Packet.append(0x01)
			elif Hours == 1 or Hours == 2 or Hours == 3 or Hours == 4 or Hours == 5 or Hours == 6 or Hours == 7 or Hours == 8 or Hours == 9 or Hours == 10 or Hours == 11 or Hours == 12 or Hours == 13 or Hours == 14 or Hours == 15 or Hours == 16 or Hours == 17 or Hours == 18 or Hours == 19 or Hours == 20 or Hours == 21 or Hours == 22 or Hours == 23 or Hours == 24:
				ArenaType = 'Party Flag'
				Packet.append(0x01)
				Packet.append(0x02)
			elif Hours == 1 or Hours == 2 or Hours == 3 or Hours == 4 or Hours == 5 or Hours == 6 or Hours == 7 or Hours == 8 or Hours == 9 or Hours == 10 or Hours == 11 or Hours == 12 or Hours == 13 or Hours == 14 or Hours == 15 or Hours == 16 or Hours == 17 or Hours == 18 or Hours == 19 or Hours == 20 or Hours == 21 or Hours == 22 or Hours == 23 or Hours == 24:
				ArenaType = 'Party Points'
				Packet.append(0x01)
				Packet.append(0x01)
			else:
				log('[Arena] Guild arena not supported')
				return 0

			inject_joymax(0x74D3, Packet, False)
	return 500

how does this work can anyone explain i mean how do i use this plugin

1 Like

All you do is put arena in your script when in front of the NPC. It registers for the current active arena type.

1 Like

have way support guild arena ? others work well

1 Like

This plugin is old and not written by me. You have to capture the packet for registering to that event then add it.

I rewrote part of it so you can specify the one you want to register for. Not tested.

Examples:

arena,random flag
arena,party flag
from phBot import *

log('[Plugin] Succesfully loaded [%s]' % __name__)

ArenaType = ''

def handle_joymax(opcode, data):
	if opcode == 0x34D2:
		if data[0] == 0xFF and data[1] == 0x00 and data[2] == 0x01 and data[3] == 0x01:
			log('[Arena] Successfully registered to arena: %s' % ArenaType)
			stop_bot()
	return True

def arena(arguments):
	if len(arguments) != 2:
		log('[Arena] Missing arena type in the script')
		return 0

	t = arguments[1].lower()
	NPCID = 0

	NPCs = get_npcs()
	for UniqueID, NPC in NPCs.items():
		if NPC['name'] == 'Arena Manager':
			NPCID = UniqueID
			break

	if NPCID != 0:
		global ArenaType
		ArenaType = ''

		Packet = bytearray()
		Packet.append(0x01)

		if t == 'job flag':
		 	ArenaType = 'Job Flag'
		 	Packet.append(0x03)
		 	Packet.append(0x02)
		elif t == 'job points':
		 	ArenaType = 'Job Points'
		 	Packet.append(0x03)
		 	Packet.append(0x01)
		elif t == 'random flag':
			ArenaType = 'Random Flag'
			Packet.append(0x00)
			Packet.append(0x02)
		elif t == 'random points':
			ArenaType = 'Random Points'
			Packet.append(0x00)
			Packet.append(0x01)
		elif t == 'party flag':
			ArenaType = 'Party Flag'
			Packet.append(0x01)
			Packet.append(0x02)
		elif t == 'party points':
			ArenaType = 'Party Points'
			Packet.append(0x01)
			Packet.append(0x01)
		else:
			log('[Arena] Guild arena not supported')
			return 0

		inject_joymax(0x74D3, Packet, False)
		return 500

	return 0
3 Likes

Please, I need remove check hour of script, in my server the arena has every 15 minutes, what i need to make that register ?? any can help me?

And if arena is SCORE?
I copy lines of other arena registrate and change name for Score?

Hello :slight_smile: Just wanted to use the plugin but I dont really know how. I did the plugin, and its loading successfully in phbot. What do I have to do after I log in to the game? Its not registering automatically for me, but when click on map, and choose manually to register battle arena it works. Looking forward for response :slight_smile:

This plugin is for scripts. You can use it like this in any script:

arena,party points

https://forum.projecthax.com/t/arena/346/7

1 Like

What do You mean that its for scripts? I have to record script for town or?

Thats correct. You must make a script (Town, or Training) and add the line above from Ryan

When I made a new script and put there only : arena,party points
It loops the town and stop botting saying that :

[12:24:18] Script: You loaded the wrong script for this town, stopping bot

[12:24:18] Bot stopped. Botting time [1 minute]
@EDIT
I think Ive got to capture packets for my servers also, right?

You need more than just that command. You must first click in the center of town spawn then walk to the arena NPC and then add the arena command.

The bot keeps looping. when he finishes with npcs(blacksmithg, storage etc.) he goes to my cordinates I have put (city center and next npc manager) and then again looping city. Should it be like this?


@EDIT

try :
walk,-16112,48,1535
walk,-16123,45,1537
arena,party points
i dont use so idont know i-f right cmd but i think you have to make a return to the line after each coordinate

The script is working fine, I mean, no need to write it in new lines ( I used phbot to record script ). Pls look above, I uploaded new SS.
@EDIT Maybe I can find some1 who will do this for some $ for me? :frowning: Im really lost :confused:

Hello,
I have the problem with this plugin. the bot says that: command arena not found. Do U know what issue may it be?

You have to install the plugin for that to work.

could U send me the link? I think I have this already installed :frowning:
@EDIT It worked for me before but after I changed script ( deleted walking ) didnt work anymore lol. And now when I returned these walking coordinates its not working :confused:

It’s in this thread. You have to copy the contents into a .py file and store that in the Plugins folder.