joedezzy1

TradeRequestCheck

Mar 3rd, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package scripts.Merchanter;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.input.Mouse;
  5. import org.tribot.api2007.Interfaces;
  6. import org.tribot.api2007.Player;
  7. import org.tribot.api2007.Walking;
  8. import org.tribot.api2007.types.RSInterfaceChild;
  9. import org.tribot.api2007.types.RSInterfaceComponent;
  10. import org.tribot.api2007.types.RSTile;
  11. import org.tribot.script.Script;
  12.  
  13.  
  14. public class TradeRequestCheck extends Script implements Runnable {
  15.  
  16. public String PlayerTraded;
  17. public RSTile OriginalTile;
  18.  
  19. public void run() {
  20. if(WeBeenTraded())
  21. { OriginalTile = Player.getRSPlayer().getPosition();
  22. println("Trading with: " + PlayerTraded);
  23. Mouse.setSpeed(General.random(130,150));
  24. Mouse.move(General.random(22, 100), General.random(451, 452)); //clicks their name to trade
  25. Mouse.click(1);
  26. sleep(2000, 3000);
  27. OriginalTileCheck();
  28. Mouse.setSpeed(General.random(85, 95)); }
  29. }
  30.  
  31. private boolean WeBeenTraded() {
  32. RSInterfaceChild i = Interfaces.get(137, 2); //chatbox
  33.  
  34. for (int x = 199; x > -1; x--)
  35. { RSInterfaceComponent j = i.getChild(x);
  36.  
  37. if (!j.getText().isEmpty())
  38. if (j.getText().contains(" wishes to trade with you."))
  39. { String Wishes = " wishes to trade with you.";
  40. int Length = j.getText().length() - Wishes.length();
  41. PlayerTraded = j.getText().substring(0, Length);
  42. return true; } }
  43.  
  44. return false;
  45. }
  46.  
  47. private void OriginalTileCheck() {//Complete. It keeps saying wrong area but its wrong. check this
  48.  
  49. if (!Player.getRSPlayer().getPosition().equals(OriginalTile))
  50. { Walking.walkTo(OriginalTile);
  51. sleep(General.random(1403,3064)); }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment