laylaylom 5 Posted May 26, 2017 I was doing this tutorial (it's very old), I made my own script similar to Computor's basic woodcutter. https://dreambot.org/forums/index.php/topic/2555-video-tutorial-series-dreambot-scripting-request-scripting-tutorials-here/ Now I'm not getting any errors but my script doesn't appear at the script panel of DreamBot. What could be the reason? My code is here: import org.dreambot.api.methods.Calculations; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.interactive.NPC; import javax.imageio.ImageIO; import java.awt.*; import java.io.IOException; import java.net.URL; /** * Created by burak on 26-05-17. */ @ScriptManifest(name = "ProKiller", author = "Laylaylom", description = "Kills anything you want", version = 2.0, category = Category.COMBAT) public class ProKiller extends AbstractScript { private boolean startScript; private ProKillerGui gui; private Image mainPaint = getImage("http://imgur.com/xHeQyjX"); @Override public void onStart() { gui = new ProKillerGui(this); gui.setVisible(true); } @Override public int onLoop() { if (startScript) { killIt(gui.getMobName()); // eatSomeFood(gui.getFoodType()); } return 400; } public void killIt(String nameOfMob){ NPC mob = getNpcs().closest(nameOfMob); if (mob != null && !mob.isInCombat() && mob.canAttack()){ if (mob.interact("Attack")){ sleepUntil(() -> mob.getHealthPercent() <= 0, Calculations.random(5500,8500)); } }else{ sleepUntil(() -> mob.exists() && mob.canAttack(), Calculations.random(1500,3500)); } } // public void eatSomeFood(String foodName){ // here comes food code // } public void setStartScript(boolean startScript) { this.startScript = startScript; } @Override public void onPaint(Graphics2D g) { g.drawImage(mainPaint, 0, 340, null); } private Image getImage(String url){ try { return ImageIO.read(new URL(url)); }catch (IOException e){ return null; } } } GUI code: import java.awt.*; import java.awt.event.*; import javax.swing.*; /* * Created by JFormDesigner on Fri May 26 00:19:36 CEST 2017 */ /** * @[member='Authorities'] unknown */ public class ProKillerGui extends JFrame { private ProKiller ctx; public ProKillerGui(ProKiller main){ this.ctx = main; initComponents(); } private void button1ActionPerformed(ActionEvent e) { ctx.setStartScript(true); this.setVisible(false); } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Burak kemal button1 = new JButton(); comboBox1 = new JComboBox<>(); label1 = new JLabel(); label2 = new JLabel(); label3 = new JLabel(); textField1 = new JTextField(); //======== this ======== setTitle("ProKiller GUI"); Container contentPane = getContentPane(); contentPane.setLayout(null); //---- button1 ---- button1.setText("Start"); button1.addActionListener(e -> button1ActionPerformed(e)); contentPane.add(button1); button1.setBounds(55, 120, 165, button1.getPreferredSize().height); //---- comboBox1 ---- comboBox1.setModel(new DefaultComboBoxModel<>(new String[] { "None", "Shrimp", "Cooked chicken", "Sardine", "Cooked meat", "Herring", "Trout", "Salmon", "Tuna", "Lobster" })); comboBox1.setBackground(new Color(69, 73, 74)); contentPane.add(comboBox1); comboBox1.setBounds(new Rectangle(new Point(140, 15), comboBox1.getPreferredSize())); //---- label1 ---- label1.setText("Choose your food"); label1.setBackground(new Color(51, 255, 0)); label1.setForeground(new Color(51, 204, 0)); contentPane.add(label1); label1.setBounds(new Rectangle(new Point(10, 20), label1.getPreferredSize())); //---- label2 ---- label2.setText("Which mob do"); label2.setForeground(new Color(51, 204, 0)); contentPane.add(label2); label2.setBounds(new Rectangle(new Point(10, 60), label2.getPreferredSize())); //---- label3 ---- label3.setText("you want to kill?"); label3.setForeground(new Color(51, 204, 0)); contentPane.add(label3); label3.setBounds(new Rectangle(new Point(10, 75), label3.getPreferredSize())); //---- textField1 ---- textField1.setBackground(new Color(69, 73, 74)); contentPane.add(textField1); textField1.setBounds(140, 70, 130, textField1.getPreferredSize().height); contentPane.setPreferredSize(new Dimension(280, 165)); pack(); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents } public String getFoodType() { return comboBox1.getSelectedItem().toString(); } public String getMobName() { return textField1.getText().toString(); } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // Generated using JFormDesigner Evaluation license - Burak kemal private JButton button1; private JComboBox<String> comboBox1; private JLabel label1; private JLabel label2; private JLabel label3; private JTextField textField1; // JFormDesigner - End of variables declaration //GEN-END:variables } Here the .JAR file https://uploadfiles.io/fm46j Someone told me that the code is broken, I also tried Computor's woodcutter script. The script doesn't appear. Maybe DreamBot doesn't support JFrames anymore or something? Okay here the problem; At Artifacts > add > JAR you get 2 options, Empty or From modules with dependencies In the tutorial of Computor he did the second option, but it has to be the first option "Empty". they are 2 different things as I understood ( executable and runnable ) Thanks to @hastag he solved this problem
Recommended Posts
Archived
This topic is now archived and is closed to further replies.