imJordanB Posted September 25, 2015 Share Posted September 25, 2015 (edited) 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 September 25, 2015 by imJordanB Quote Link to comment Share on other sites More sharing options...
FrostBug Posted September 25, 2015 Share Posted September 25, 2015 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 2 Quote Link to comment Share on other sites More sharing options...
imJordanB Posted September 26, 2015 Author Share Posted September 26, 2015 (edited) 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 Edited September 26, 2015 by imJordanB Quote Link to comment Share on other sites More sharing options...