Jump to content

Gambling / Dicing Bot - Need Help Coding


imJordanB

Recommended Posts

Hello,

 

I am new to Java, I have some experience of programming in Python and C#, but Java is new to me.

 

I am looking to create a basic gambling bot, the outline of the bot is as follows:

 

1. Detect User Input ingame

2. Based on the users input (e.g. !58x2), it will randomly generate the appropriate numbers (in this case, a number between 1-100)

3. Output into the Runescape Chat what the bot generated

 

This seems like an easy bot to code, however, with my little knowledge of Java, I came to this community for help. Any help is appreciated, if its just listing some of the commands I need to use, or whether its a bit more in-depth.

 

I understand there is one on the OSBot Store, however, i would like to customise and make my own, as well as improve on my little knowledge of Java.

 

Thank you for your time,

 

Jordan

 

edit: yes, I have the JDK and Eclipse installed :P

Edited by imJordanB
Link to comment
Share on other sites

Java is pretty similar to C# actually, so you shouldn't have much trouble

 

1. To detect user input, you will need to implement the onMessage method in your class that extends Script. Method overriding works the same in Java as it does in C#.

The onMessage method will be called whenever a new message (be it a game message or a player message) appears in your chatbox.

 

2. To parse the inputted string, you could simply break the message into parts.

Given your example "!58x2", you could first check if the message starts with "!" ( stringMsg.startsWith("!") )

Then you could proceed to split the remainder of the string on the "x" delimiter, and read each value.

To generate a random number, you can use the built in osbot method MethodProvider.random(minValue, maxValue)

 

3. To let your character write stuff in the chat, you can use the OSBot keyboard API.

example: getKeyboard().typeString("You rolled a " + num);

Note that the getKeyboard method is located in the MethodProvider class, so it may only be used from the Script class, since Script inherits from MethodProvider

 

  • Like 2
Link to comment
Share on other sites

Java is pretty similar to C# actually, so you shouldn't have much trouble

 

1. To detect user input, you will need to implement the onMessage method in your class that extends Script. Method overriding works the same in Java as it does in C#.

The onMessage method will be called whenever a new message (be it a game message or a player message) appears in your chatbox.

 

2. To parse the inputted string, you could simply break the message into parts.

Given your example "!58x2", you could first check if the message starts with "!" ( stringMsg.startsWith("!") )

Then you could proceed to split the remainder of the string on the "x" delimiter, and read each value.

To generate a random number, you can use the built in osbot method MethodProvider.random(minValue, maxValue)

 

3. To let your character write stuff in the chat, you can use the OSBot keyboard API.

example: getKeyboard().typeString("You rolled a " + num);

Note that the getKeyboard method is located in the MethodProvider class, so it may only be used from the Script class, since Script inherits from MethodProvider

 

 

 

Thank you very much for this post, I will follow as you say and hopefully I'll have something up and running very soon! Once again, thanks for your help, I appreciate it smile.png

Edited by imJordanB
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...