Buying Selling via chat command

Hey there Im writing a Plugin right now to help out in caravan trading.
For that i wanna buy and sell items via old tradesystem. I read the PhBot API and didnt find a solution
other than using the opcode to send packages. But here Im having troubles getting the data. I wrote a script with a short log for the bot but it doest seem to work. Is it because im trying it in a private server? The login times there are alot shorter so i prefer doing that.
Everything else does work perfectly within the script like automatic teleporting and stuff.
Id be happy if I could get some ideas / help here.
Thanks in advance! :slight_smile:

Youā€™d have to manually send the packets to buy/sell goods. I believe the ā€˜get_pets()ā€™ function now returns the inventory so you can use that to find which slot to sell.

2 Likes

Thanks I feel stupid now that I didnt try that before asking here. If get_pets() is returning the inventory i should be perfectly fine now. But still im interested on why i cant get the informations from the client regarding the opcodes and stuff even though i used the fuctions needed for it. Anyways thanks!

Give it some love to the Gitbook :sleepy:

Unfortunately Gitbook is trash now and annoying to edit things. Thereā€™s no markdown option anymore that I could find which would make it easy.

Well ive done the most basic stuff now. Got a whole list of opcodes i need and first stuff is working but ive got a huge problem I just cant seem to fix.
If I use the Plugin: ā€œxPacketToolā€ and inject the opcode/data to select ā€œbuy/sellā€ everything works fine. But as soon as i inject it in my code it doesnt work. Everything else like taking quests or selecting the NPC works for me. The Data i use is 0x7046 // 21 01 00 00 0C.
I have no idea why it keeps crashing the client (not disconnecting me) but since its the first data with a C in it i kinda think this might be the problem hereā€¦ but since its hexadecimal i have no idea why :smiley: Help me please!

Sorry for spamming here but editing posts is kind of impossible :smiley:
Problem kept being the same even when i skipped the step with selecting buy/sell. If i open the inventory once manually i wont be kicked into clientless. Seems to be a problem with package handling but i have no idea how to solve this.

You canā€™t buy items from an NPC because the client doesnā€™t know which NPC you are in so when it goes to look for the item it crashes.

Well but I selected talk to NPC, he does that without a crash. When I let him select buy/sell it crashes, and if I skip that stepā€¦ I get the item but it crashes. I believe you when you say itā€™s because the client doesnā€™t know which NPC Iā€™m talking to but how am I going to fix that? Iā€™m running out of ideas. Even tried to block response packets from the server but it just doesnā€™t to the job :frowning:

I believe you are able to block the response but you must send the client a packet telling it that an item was picked up in a specific slot.

Thanks for your help man! :slight_smile: Not sure if i will find out the right codes that fast but i guess from here its just try and error :smiley: Wont bother you anymore. I will update this thread one last time once i got it running. Have a nice week!

Okay my last edit for this post! Wow thanks for your help. In the end the fix was quite simple but i would never gotten the Idea to send a Packet to the client with the pickup stuff. :slight_smile: I just bought a whole inventory without a crash so im quite sure im done with it. Logging ALL kind of Opcodes and Datas recieved definetly did the job for me in the end cause the key was to understand how this kind of stuff works! :slight_smile: Happy now ^.^ (PS: I will never curse my console againā€¦ starting the bot to see any result all the time made me waste alot of time and gotten me really mad some times :smiley: )

1 Like

could you please share the plugin so we can all profit <3
i could do it with the info supported but that will take a lot of debugging and i would appreciate it if i could save on some time thanks

Hey :slight_smile: Sorry my friend I was really inactive lately. You wont be having much fun with the tool since some structures differ each private server, so it needs some adjustments (even though it should work now on most of the big ones like electus/ ruby etc.) . Also I dont really wanna bust the last thing that makes a private server fun, which is basically not botting outside of the training area. I might release the tool one day but right now i prefer letting it rust in a corner to not harm the fun any further. As always: Coding is 100% more fun than using this kind of software. If you wanna recreate im always up to give some tips.