Guest User

Untitled

a guest
Jun 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.71 KB | None | 0 0
  1. package com.scripts;
  2.  
  3.  
  4. import java.awt.*;
  5. import java.awt.event.KeyListener;
  6. import java.awt.event.KeyEvent;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.ActionEvent;
  9.  
  10. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  11. import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
  12. import com.kbot2.scriptable.Script;
  13. import com.kbot2.scriptable.methods.wrappers.NPC;
  14. import com.kbot2.scriptable.methods.wrappers.Player;
  15.  
  16. import javax.swing.*;
  17.  
  18. public class CapeXTaker extends Script implements PaintListener, ServerMessageListener {
  19.  
  20.  
  21. int status = 0;
  22. int CASHCHK = 0;
  23. int CASHCHK2 = 0;
  24. int CAPE = 0;
  25. int SEND = 0;
  26. int cape1 = 4379;
  27. int cape2 = 4359;
  28. int cape3 = 4399;
  29. int cape4 = 4319;
  30. int cape5 = 4339;
  31.  
  32. private String charName;
  33.  
  34. private boolean _active;
  35.  
  36.  
  37. public boolean active() {
  38. return true;
  39. }
  40.  
  41. public void onServerMessage(String trade) {
  42. if (trade.contains("You cannot buy that item right now")) {
  43. CAPE++; } }
  44.  
  45. @Override
  46. public boolean onStart() {
  47. charName = null;
  48.  
  49. JFrame frame = new JFrame("iEssWalker");
  50. frame.setLayout(new GridBagLayout());
  51.  
  52. GridBagConstraints c = new GridBagConstraints();
  53. c.fill = GridBagConstraints.BOTH;
  54. c.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
  55. c.gridx = 0;
  56. c.gridy = 0;
  57. c.gridheight = 1;
  58. c.gridwidth = 1;
  59.  
  60. JTextField textField = new JTextField();
  61. textField.setText("Character's name here");
  62. textField.addKeyListener(new KeyListener() {
  63. public void keyTyped(KeyEvent e){
  64. }
  65.  
  66. public void keyPressed(KeyEvent e){
  67. }
  68.  
  69. public void keyReleased(KeyEvent e){
  70. charName = ((JTextField) e.getSource()).getText();
  71. }
  72. });
  73. frame.add(textField, c);
  74.  
  75. c.gridheight = 2;
  76. c.gridy = 0;
  77. c.gridx = 1;
  78. JButton button = new JButton("Start\nScript");
  79. button.addActionListener(new ActionListener() {
  80.  
  81. public void actionPerformed(ActionEvent e) {
  82. if(charName == null) {
  83. JOptionPane.showMessageDialog(null, "You have to enter a Characters name");
  84. return;
  85. }
  86. Container c = ((JButton) e.getSource()).getParent();
  87. while(c.getParent() != null)
  88. c = c.getParent();
  89. c.setVisible(false);
  90.  
  91. _active = true;
  92. }
  93. });
  94. frame.add(button, c);
  95.  
  96. frame.pack();
  97. frame.setVisible(true);
  98. return true;
  99. }
  100.  
  101.  
  102.  
  103.  
  104. public int loop() {
  105. switch (status) {
  106.  
  107. case 0://checks if we can start
  108. if(_active) {
  109. status = 1; }
  110.  
  111. return random(300, 500);
  112.  
  113. case 1:
  114. if (inventory.contains(cape1, cape2, cape3, cape4, cape5)) {
  115. status = 2; }
  116. if (!inventory.contains(cape1, cape2, cape3, cape4, cape5)) {
  117. status = 4; }
  118.  
  119.  
  120.  
  121. return random(200, 300);
  122.  
  123. case 2:
  124. CASHCHK = inventory.getCount(true, 995);
  125. if (!inventory.contains(cape1, cape2, cape3, cape4, cape5)) {
  126. status = 3; }
  127. if (interfaces.interfaceExists(335, 18)) {
  128. if (interfaces.getInterface(335, 18).getAbsoluteX() > 2.0) {
  129. inventory.atItem("Offer-All", cape1, cape2, cape3, cape4, cape5); } }
  130. if (inventory.contains(cape1, cape2, cape3, cape4, cape5)) {
  131. Player noob = null;
  132. for (Player player : players.getPlayers()) {
  133. if(player.getName().toLowerCase().contains(charName)){
  134. noob = player;
  135. break; } }
  136. if (noob != null) {
  137. if (walking.atTile(noob.getLocation(), "Trade with "+ noob.getName())) {
  138. sleep(2000, 3000);} } }
  139.  
  140.  
  141. return random(200, 300);
  142.  
  143. case 3:
  144. CASHCHK2 = inventory.getCount(true, 995);
  145. if (CASHCHK < CASHCHK2) {
  146. CASHCHK = 0;
  147. CASHCHK2 = 0;
  148. status = 1; }
  149. if (interfaces.interfaceExists(335, 16)) {
  150. if (interfaces.getInterface(335, 18).getAbsoluteX() > 2.0) {
  151. interfaces.getInterface(335, 16).doAction("Accept");
  152. sleep(1400, 2000); } }
  153. if (interfaces.interfaceExists(334, 20)) {
  154. if (interfaces.getInterface(334, 20).getAbsoluteX() > 2.0) {
  155. interfaces.getInterface(334, 20).doAction("Accept");
  156. sleep(500, 800); } }
  157. if (!interfaces.interfaceExists(335, 16)) {
  158. status = 1; }
  159.  
  160.  
  161. return random(200, 300);
  162.  
  163. case 4:
  164. NPC Larry = npcs.getClosest(10, 1780);
  165. if (!inventory.contains(cape1, cape2, cape3, cape4, cape5)) {
  166. Larry.doAction("Trade");
  167. sleep(800, 1200); }
  168. if (interfaces.interfaceExists(620, 7)) {
  169. status = 5; }
  170.  
  171.  
  172.  
  173. return random(200, 300);
  174.  
  175. case 5:
  176. int RAND = random(27, 99);
  177. if (SEND > 0) {
  178. sleep(800, 1200);
  179. sendText("" +RAND, true);
  180. SEND = 0; }
  181. if (CAPE > 4) {
  182. CAPE = 0; }
  183. if (inventory.contains(cape1, cape2, cape3, cape4, cape5)) {
  184. interfaces.getInterface(620, 7).doAction("Close");
  185. status = 1; }
  186. else if (interfaces.interfaceExists(620, 24)) {
  187. sleep(600, 800);
  188. if (SEND == 0) {
  189. interfaces.getInterface(620, 24).getChild(0).doAction("Buy X");
  190. SEND++; }
  191. if (SEND == 1) {
  192. interfaces.getInterface(620, 24).getChild(1).doAction("Buy X");
  193. SEND++; }
  194. if (SEND == 2) {
  195. interfaces.getInterface(620, 24).getChild(2).doAction("Buy X");
  196. SEND++; }
  197. if (SEND == 3) {
  198. interfaces.getInterface(620, 24).getChild(3).doAction("Buy X");
  199. SEND++;}
  200. if (SEND == 4) {
  201. interfaces.getInterface(620, 24).getChild(4).doAction("Buy X");
  202. SEND++;} }
  203.  
  204.  
  205. return random(200, 300);
  206. }
  207. return random(200, 300);
  208.  
  209. }
  210.  
  211. void clickMouse(int x, int y, int randx, int randy, boolean button) {
  212. mouse.moveMouse(x, y, randx, randy);
  213. sleep(100);
  214. mouse.clickMouse(button);
  215.  
  216. }
  217.  
  218. public String getName() {
  219. return "CapeXTaker";
  220. }
  221.  
  222. public String getAuthor() {
  223. return "Ryan";
  224. }
  225.  
  226. public String getDescription() {
  227. return "xfers through capes";
  228. }
  229.  
  230. public void onRepaint(Graphics w) {
  231.  
  232. }
  233. }
Add Comment
Please, Sign In to add comment