Automated Gold Drop

Hey guys,

This is my first attempt at a plugin.

With lots of help from Bunker here’s my first version of Automated Gold Drop.

from phBot import *
import phBotChat
import QtBind
import time
import threading
import struct

gui = QtBind.init(__name__, 'Gold Dropper')

labelGold = QtBind.createLabel(gui, "Gold to drop: ", 10, 50)
labelDelay = QtBind.createLabel(gui, "Delay: ", 10, 69)
textBoxGold = QtBind.createLineEdit(gui, '5', 120, 50, 77, 16)
textBoxDelay = QtBind.createLineEdit(gui, '500', 120, 69, 77, 16)
button1 = QtBind.createButton(gui, 'button_clicked', 'Start dropping gold', 10, 90)
started = False
pName = 'Gold Dropper'
pVersion = '1.0.0'

def button_clicked():
	global started
	
	textDelay = QtBind.text(gui, textBoxDelay)
	textGold = QtBind.text(gui, textBoxGold)
	
	strGold = int(textGold)
	intDelay = int(textDelay)

	if started == True:
		started = False
		QtBind.setText(gui, button1, "Start dropping gold")
	elif started == False:
		started = True
		QtBind.setText(gui, button1, "Stop dropping gold")
		y = threading.Thread(target=dropWorker, args=(intDelay, strGold))
		y.start()


def dropWorker(delay, gold):
	global started
	delay /= 1000
	waitDelay = int(delay)
	packetData = b'\x0A'
	packetData += struct.pack('<I', gold)
	packetData += b'\x00\x00\x00\x00'
	#log(str(' '.join('{:02X}'.format(x) for x in packetData)))
	while started == True:
		inject_joymax(0x7034, packetData, True)
		time.sleep(delay)
		
		
log('Plugin: '+pName+' v'+pVersion+' succesfully loaded')

Made alittle fix for you so it will work with higher amounts of gold :slight_smile: (I edited your post as well).

def dropWorkerTest(delay, gold):
	global started
	delay /= 1000
	waitDelay = int(delay)
	packetData = b'\x0A'
	packetData += struct.pack('<I', gold)
	packetData += b'\x00\x00\x00\x00'
	#log(str(' '.join('{:02X}'.format(x) for x in packetData)))
	while started == True:
		inject_joymax(0x7034, packetData, True)
		time.sleep(delay)

My bad.

Thanks for the edit. I realized this was still my test version. I have changed it to the normal version :slight_smile:

Edit: Also removed some useless variables and imports

1 Like