alkku15
-
Posts
36 -
Joined
-
Last visited
-
Feedback
0%
Posts posted by alkku15
-
-
@Apaec lol got it working this way but this is really bad code L0L
JComboBox<String> comboBox_1 = new JComboBox<String>(showoptionsforPickpocket); comboBox_1.setBounds(10, 78, 164, 20); ScriptName.add(comboBox_1); JComboBox<String> comboBox_2 = new JComboBox<String>(showoptionsforStalls); comboBox_2.setBounds(10, 78, 164, 20); ScriptName.add(comboBox_2); JComboBox<String> comboBox_3 = new JComboBox<String>(showoptionsforChest); comboBox_3.setBounds(10, 78, 164, 20); ScriptName.add(comboBox_3); comboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (comboBox.getSelectedItem().equals("Pickpocket")) { comboBox_1.setVisible(true); comboBox_2.setVisible(false); comboBox_3.setVisible(false); } else if (comboBox.getSelectedItem().equals("Stalls")) { comboBox_1.setVisible(false); comboBox_2.setVisible(true); comboBox_3.setVisible(false); } else if (comboBox.getSelectedItem().equals("Chests")) { comboBox_1.setVisible(false); comboBox_2.setVisible(false); comboBox_3.setVisible(true); } } });
- 1
-
@Apaec ty ill look into it rn but heres the whole gui code + ty for the fast reply lol
public void JFrame() { JFrame ScriptName; ScriptName = new JFrame(); ScriptName.setTitle("Thiever"); ScriptName.setBounds(100, 100, 200, 230); ScriptName.getContentPane(); ScriptName.setLayout(null); ScriptName.setResizable(false); //LABEL AKA TITLE JLabel lblWhatToThiev = new JLabel("What to thiev?"); lblWhatToThiev.setBounds(54, 1, 78, 14); ScriptName.add(lblWhatToThiev); //COMBOBOX JComboBox<String> comboBox = new JComboBox<String>(new String[] { "None", "Pickpocket", "Stalls", "Chests"}); comboBox.setBounds(10, 22, 164, 20); ScriptName.add(comboBox); //LABEL AKA TITLE JLabel lblOptions = new JLabel("Option"); lblOptions.setHorizontalAlignment(SwingConstants.CENTER); lblOptions.setBounds(54, 53, 78, 14); ScriptName.add(lblOptions); //COMBOBOX //CHECKBOX JCheckBox chckbxNewCheckBox = new JCheckBox("Eat food?"); chckbxNewCheckBox.setBounds(10, 108, 164, 23); ScriptName.add(chckbxNewCheckBox); //START BUTTON JButton btnNewButton = new JButton("START"); btnNewButton.setBounds(10, 158, 164, 23); ScriptName.add(btnNewButton); btnNewButton.addActionListener(new ActionListener() { //this actionlistener checks if start button is pressed public void actionPerformed(ActionEvent e) { //and then sets the visibility of the gui to false (closes gui) ScriptName.setVisible(false); //disappear when clicking on the button ScriptName.dispose(); } }); comboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (comboBox.getSelectedItem().equals("Pickpocket")) { JComboBox<String> comboBox_1 = new JComboBox<String>(showoptionsforPickpocket); comboBox_1.setBounds(10, 78, 164, 20); ScriptName.add(comboBox_1); } else if (comboBox.getSelectedItem().equals("Stalls")) { JComboBox<String> comboBox_1 = new JComboBox<String>(showoptionsforStalls); comboBox_1.setBounds(10, 78, 164, 20); ScriptName.add(comboBox_1); } else if (comboBox.getSelectedItem().equals("Chest")) { JComboBox<String> comboBox_1 = new JComboBox<String>(showoptionsforChest); comboBox_1.setBounds(10, 78, 164, 20); ScriptName.add(comboBox_1); } } }); btnNewButton.addActionListener(e -> npcname = textField.getText()); //gets the text from npc textfield part btnNewButton.addActionListener(e -> stallId = Integer.parseInt(textField.getText())); //gets the text from npc textfield part btnNewButton.addActionListener(e -> EatOrNo = chckbxNewCheckBox.getText()); //gets the text from npc textfield part comboBox.addActionListener(e -> whatoption = (String) comboBox.getSelectedItem()); ScriptName.setVisible(true); }
-
hi im back here again with another problem, so im doing a little thiever, my gui looks like this:
alright so all my actual thieving code is ready, but the problem is in the comboboxes... So for example (if i choose index 1 from the first combobox, i want the options change in the combobox2)... if you didnt get it heres another example ( i have 3 different items in the upper combobox1, items are "pickpocket", "stalls", "chests"... if i choose "pickpocket on the upper combobox, i want to get these items to show up on combobox2 ("man", "dog", "guard")...
this is my actionlistener code
public String[] showoptionsforPickpocket = {"man", "woman", "xddd"}; public String[] showoptionsforStalls = {"cake stall", "stall number 2", "jfefofajfjeofjs stall"}; public String[] showoptionsforChest = {"ardy chest", "chestinmyass", "urmom"}; comboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (comboBox.getSelectedItem().equals("Pickpocket")) { JComboBox<String> comboBox_1 = new JComboBox<String>(showoptionsforPickpocket); comboBox_1.setBounds(10, 78, 164, 20); ScriptName.add(comboBox_1); } else if (comboBox.getSelectedItem().equals("Stalls")) { JComboBox<String> comboBox_1 = new JComboBox<String>(showoptionsforStalls); comboBox_1.setBounds(10, 78, 164, 20); ScriptName.add(comboBox_1); } else if (comboBox.getSelectedItem().equals("Chest")) { JComboBox<String> comboBox_1 = new JComboBox<String>(showoptionsforChest); comboBox_1.setBounds(10, 78, 164, 20); ScriptName.add(comboBox_1); } } });
right now im only listening to the combobox1, do i need another listener? and im trying to do this probs the hard way (just changing the strings in the combobox2)
now if i load this up in osbot & ingame ... at start it doesnt show anything which its supposed to be, then i choose "pickpocket" it shows the stringsforpicckpocket... then after that ii choose any other option in combobox1 it doesnt change the strings in combobox2... how do i get this working
-
@FrostBug thanks alot!
-
i have a textfield... my string is this
public String nameofloot = "";
now i can only type 1 item name (for example "Shark"), if i try to type "Shark, Rune platebody, Air rune", it takes that whole line as 1 item, how to seperate and make the script understand that if i put a "," between 2 words it means 2 different words?
btnNewButton.addActionListener(e -> nameofloot = textField.getText()); //gets the text from food textfield part
and thats how i get the text from the textfield to a string
-
34 minutes ago, Explv said:
Adding an ActionListener to a text field isn't going to work (you would need to use a DocumentListener, but that would be ugly as hell and unnecessary)
The better way to approach it would be to get the text from the text field when the user clicks start.startButton.addActionListener(e -> chat = txtnameOfNpc.getText());
Your GUI code all kinds of fucked up though
ty so much you always helping us noobs out! much love
-
22 minutes ago, ProjectPact said:
Are you sure you are supposed to be using "getSelectedText()"? What happens if you just use getText()?
doesnt work, tried another post too
and all my code here (GUI.JAVA))))))))
public class gui { public void run(main Main) { JFrame jFrame = new JFrame("joujouou"); jFrame.setSize(300, 500); jFrame.setResizable(false); JPanel settingsPanel = new JPanel(); TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); leftBorder.setTitleJustification(TitledBorder.LEFT); settingsPanel.setBorder(leftBorder); settingsPanel.setLayout(null); settingsPanel.setBounds(5, 200, 280, 180); jFrame.add(settingsPanel); JPanel startPanel = new JPanel(); startPanel.setLayout(null); startPanel.setBounds(5, 350, 70, 20); jFrame.add(startPanel); JTextField txtnameOfNpc = new JTextField(); txtnameOfNpc.setHorizontalAlignment(SwingConstants.CENTER); txtnameOfNpc.setText("(name of npc to kill)"); txtnameOfNpc.setBounds(10, 11, 214, 20); settingsPanel.add(txtnameOfNpc); txtnameOfNpc.setColumns(10); txtnameOfNpc.addActionListener(e -> Main.hide = (String) txtnameOfNpc.getText().toString()); JButton startButton = new JButton("Start"); startButton.addActionListener(e -> { synchronized (Main.lock) { Main.lock.notify(); } jFrame.setVisible(false); }); startButton.setBounds(5, 390, 70, 20); startPanel.add(startButton); jFrame.setVisible(true); } }
(MAIN.JAVAAAAAAAAAAAA)
@ScriptManifest(author = "hh", info = "hh", name = "hh", version = 0, logo = "") public class main extends Script { Object lock = new Object(); private gui gui = new gui(); public String hide = ""; @Override public void onStart() { gui.run(this); } @Override public int onLoop() throws InterruptedException { return (random(50, 100)); } @Override public void onExit() { } @Override public void onPaint(Graphics2D g) { g.drawString(hide, 50, 50); <------------ TRYING TO PRINT IT OUT ON SCREEN (if this would work i would start writing aio killer ofc) } }
-
hi im noob and just learned how to make a GUI with eclipse window builder and move it into main.java (so theres no need for another .java file)
current main.java code
@ScriptManifest(author = "gay", info = "gay", name = "gay", version = 69, logo = "") public class Main extends Script { private JPanel ScriptName; public String chat; public void JFrame() { JFrame ScriptName; ScriptName = new JFrame(); ScriptName.setResizable(false); ScriptName.setTitle("AIO FIGHTER"); //your own title ScriptName.setBounds(100, 100, 250, 250); ScriptName.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ScriptName.getContentPane(); ScriptName.setLayout(null); //START BUTTON JButton btnNewButton = new JButton("START!"); btnNewButton.setBounds(10, 177, 214, 23); ScriptName.add(btnNewButton); ScriptName.getContentPane().add(btnNewButton); ScriptName.setVisible(true); //TEXTFIELD JTextField txtnameOfNpc = new JTextField(); txtnameOfNpc.setHorizontalAlignment(SwingConstants.CENTER); txtnameOfNpc.setText("(name of npc to kill)"); txtnameOfNpc.setBounds(10, 11, 214, 20); ScriptName.add(txtnameOfNpc); txtnameOfNpc.setColumns(10); ScriptName.getContentPane().add(btnNewButton); ScriptName.setVisible(true); //makes the button appearing when the script start txtnameOfNpc.addActionListener(e -> chat = (String) txtnameOfNpc.getSelectedText().toString()); } @Override public void onStart() { //log("Let's get started!"); JFrame(); } @Override public int onLoop() throws InterruptedException { return (random(50, 150)); } @Override public void onExit() { //log("Thanks for running my Tea Thiever!"); ScriptName.setVisible(false); } @Override public void onPaint(Graphics2D g) { ///hhhhhhhh nothing } }
so now my problem is that i cant get the string "chat" to work for some reason, i tried some ActionListener things from the post below but couldnt get them to work either
and i dont know whats wrong with this one txtnameOfNpc.addActionListener(e -> chat = (String) txtnameOfNpc.getSelectedText().toString()); ?
help pls! ty!
-
yo how to do this with a textfield? cant get it to work for some reason
tried something like this
JTextField txtnameOfNpc = new JTextField();
txtnameOfNpc.setHorizontalAlignment(SwingConstants.CENTER);
txtnameOfNpc.setText("(name of npc to kill)");
txtnameOfNpc.setBounds(10, 11, 214, 20);
ScriptName.add(txtnameOfNpc);
txtnameOfNpc.setColumns(10);
txtnameOfNpc.addActionListener(e -> chat = (String) txtnameOfNpc.getSelectedText().toString());then at graphics i tried to print the String chat to the screen, didnt work...
then tried it the way you put it there
txtnameOfNpc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ScriptName.setVisible(false); //disappear when clicking on the button ScriptName.dispose(); String chat = txtnameOfNpc.getSelectedText().toString(); //gets the selected item in the combo box log(chat); } });
-
Yo great gui tut bro but i dont think the lock works... i did everything like you did... and added the lock code to the main.java too but nope, when i choose something from the combobox = the string turns into the selected thing = script starts... Do i need to use the lock in the code (for example) right now im using
if (hide == blackdhide) { tan the hides blah blah blah }
do i need to check if the lock is on / off? and if so, how? Thanks!
-
On 5/19/2018 at 10:03 PM, HeyImJamie said:
It's clear that the method you've posted returns an Integer, so you'd check getCurrentDrinkLevel() > 100. The fact you can't figure that out though suggests to me you need to go and read up a little bit more on basic variables / methods.
ye ikr im a noob at coding but why doesn't this work? i drank abs all the way to 450, then ran the script for 1min didnt do anything
if (getCurrentDrinkLevel() < 500) {
inventory.interact("Drink", "Absorption potion(4)", "Absorption potion(3)", "Absorption potion(2)", "Absorption potion(1)");
} -
4 hours ago, PayPalMeRSGP said:
This method reads a RS2Widget for a message, a widget is a UI component in runescape, in this case the widget to be read is the absorption widget in NMZ.
To read a widget you must first get an instance of it. The line RS2Widget widget = getWidgets().get(202, 1, 9) does that. The parameters in the get method are .get(rootID, child+ ID, child++ ID). Every widget can be identified by these 3 parameters, in some cases it can be identified by 2.
It is better to obtain widgets through only the rootID through an API method that can identify widgets via a unique sprite, text, options, ect because child IDs may change over game updates. However I have use the above snippet in my own code for several months and have not seen IDs change yet. If you are just learning widgets don't bother with the better practice and just get it working first.
This image shows an example of the absorption widget's ids and the widget itself's instance variables. The message instance variable contains the player's absorption level.
thanks. i already knew this, i know the basics and i know how to use widgets (for example interacting with them etc etc.), BUT how can i use this snippet what i posted in my code? where do i put it? do i need to do something like if (getCurrentDrinkLevel > 100) ??? thats what i ment... or do i need to put my absorption level number between these " "'s in the snippet? *i tried something stupid like this:
if (widget.getMessage().contains("970")) {
inventory.interact("Drink", "Absorption potion(4)", "Absorption potion(3)", "Absorption potion(2)", "Absorption potion(1)");
} -
how does this work? how can i get some number out of this: yes am a noobie, thanks!
public int getCurrentDrinkLevel() {
RS2Widget widget = getWidgets().get(202, 1, 9);
if (widget != null && widget.isVisible() && widget.getMessage() != null)
return Integer.parseInt(widget.getMessage().replace(",", ""));
return 0;
} -
26 minutes ago, FrostBug said:
It's an instance, which gets loaded in a random "instance slot" in the instance space; hence the changing coordinates.
What you CAN do is create the area by looking at the 'Local coordinates' of the region that the instance is loaded in. Local coordinates are coordinates relative to the region base (the lower left corner of the currently loaded region). Even though the instance is loaded in different places, the local coordinates of objects, npcs and positions will be the same every time. At least until you wander far enough to trigger a new region load.
So upon entering the instance you could make the Area with something like:
Position southWestCorner = new Position(50, 50, 0).translate(getMap().getBaseX(), getMap().getBaseY()); Position northEastCorner = new Position(100, 100, 0).translate(getMap().getBaseX(), getMap().getBaseY()); Area fightArea = new Area(southWestCorner, northEastCorner);
assuming the Area spans from x:50, y:50 to x:100, y:100 in the local region
yes exactly what i was looking for thank you very much!
-
i noticed that the coordinates X n Y aren't stable when playing a minigame like pest control, i would like to make an area in the middle of these 4 towers
i am making myself a pest control / killer / afker bot what would kill these enemies in that area? any help?
-
hey! just got back to osrs after a break n started to write a killing & looting script, i am killing some npcs in deep wilderness and i am scared of pkers... so if i am getting attacked by someone and the attacker is NOT an npc, can the bot send me a notification through windows or something...
-
On 5.4.2018 at 5:15 PM, TrekToop11 said:
Sorry, I didn't realize what you had written as you didn't post any in the original post. You can look into filters, when using the widget debugger you can look at the Item id / spell name / sprite and use those to help you find the widget too.
ye bro all good, thanks
-
11 hours ago, TrekToop11 said:
section 12
yes thanks for the help i already knew this, but as i said the client doesnt support this or then im doing something wrong... nothing happens when im in the interface
RS2Widget makeall = getWidgets().getWidgetContainingText("Make-All");
makeall.interact("Make-All");
EDIT: yes im stupid this worked,
RS2Widget m = getWidgets().get(446, 9);
m.interact("Make-All");Thanks love you boys
- 1
-
i need to interact with this interface... its hard for me! i'm a beginner! I want to make (for example: gold bars, rings, n stuff), but the bot doesn't support the "Make-All" option? -
13 hours ago, geoleo36 said:
what kind of script is that bro?
just wanted to learn how to make a timer
-
yo so i need to make a timer what starts WHEN the script is started, after 10minutes = the script log outs & stops itself
-
1 hour ago, Deceiver said:
add the 2 classes, just copy n paste them.
then follow the example tom put and change it to what ur doing when u interact with the furnace
okay! added them like this:
then got this:
and in the actual .java file where my script is written i get this:
..........................................
why doesn't this interaction work? why is all this shittt needed
RS2Widget smeltinterface = widgets.get(446, 1); smeltinterface.interact("Make-All");
-
5 minutes ago, Deceiver said:
hey thanks for your help BUT, i forgot to mention im a beginner, so what im asking is that is there a more simplier way to add this? im using this skeleton for my script "
or is there a way to do this without adding any extra stuff?
"
-
i looked up some posts but still couldnt get it to work
case CRAFT: if (!smeltarea.contains(myPlayer().getPosition())) { getWalking().webWalk(smeltarea); } else { RS2Object Furnace = getObjects().closest("Furnace"); RS2Widget smeltinterface = widgets.get(446, 1); if (smeltinterface != null && smeltinterface.isVisible()) { smeltinterface.interact("Make-All"); } else { if (Furnace != null && Furnace.exists()) { Furnace.interact("Smelt"); } } } break;
then i tried something like "RS2Object kek = widgets.getWidgetContainingText("Make-All")"
then kek.interact("Make-All" etc etc doesnt work.... (IM TRYING TO SMELT GOLD BARS INTO GOLD RINGS IN AL-KHARID"
getNearestBank();
in Snippets
Posted
why doesnt this work?
getWalking().webWalk(bank);
its not recognizing the "bank" from WebBank enum?