Advertisement
joedezzy1

Check

Mar 12th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.66 KB | None | 0 0
  1. package scripts.autoMerchanter;
  2.  
  3. import org.tribot.api2007.Interfaces;
  4. import org.tribot.api2007.Inventory;
  5. import org.tribot.api2007.Player;
  6. import org.tribot.api2007.types.RSInterface;
  7. import org.tribot.api2007.types.RSItem;
  8. import org.tribot.api2007.types.RSTile;
  9.  
  10. public class Check {
  11.  
  12.     public final String WAITING_MESSAGE = "Waiting for other player";
  13.     public final String OTHER_ACCEPTED = "Other player has accepted.";
  14.    
  15.     public int buyingPrice;
  16.     public int sellingPrice;
  17.     public int startSellingSwitch;
  18.     public int nextGoldAmount;
  19.     public int totalTrades;
  20.     public int profit = 0;
  21.     public int exchanges = 0;
  22.     public int itemsSold = 0;
  23.     public int initialCoins = 0;
  24.    
  25.     public long startTime;
  26.  
  27.     public String status;
  28.     public String currently;
  29.     public String buyingMessage;
  30.     public String sellingMessage;
  31.     public String itemName;
  32.     public String advertMessage;
  33.     public String state;
  34.     public String playerTraded;  
  35.        
  36.     public String[] scamMessage = {
  37.             "nope","wtf","lol kid","??", "nice",
  38.             "almost got me lol", "You're cool dude",
  39.             "Chenope"
  40.     }; 
  41.    
  42.     public String[] successMessage = {
  43.             "ty", "thanks", "ty:)", ":)",
  44.             "ty dude", "tyyyy"
  45.     };
  46.  
  47.     public RSTile originalTile;
  48.    
  49.     public Check() { }
  50.  
  51.     public String getPlayerTraded() {  
  52.         for (int l = 199; l > -1; l--) {
  53.             RSInterface chatbox = Interfaces.get(137, 2).getChild(l);          
  54.             if (chatbox.getText().contains("wishes to trade with you.")) {  
  55.                 int nameLength = chatbox.getText().length() - 26; //players name who has traded            
  56.                 return chatbox.getText().substring(0, nameLength);                          
  57.             }
  58.         }            
  59.         return null;
  60.     }
  61.    
  62.  
  63.     public String getStatus() {        
  64.         return buying() ? "buying" : "selling";
  65.     }
  66.    
  67.     public String getMessage() {
  68.         return buying() ? buyingMessage : sellingMessage;
  69.     }
  70.    
  71.     public boolean inTrade() {     
  72.         return Interfaces.isInterfaceValid(335) || Interfaces.isInterfaceValid(334);   
  73.     }
  74.  
  75.     public boolean inOriginalPosition() {      
  76.         return Player.getRSPlayer().getPosition().equals(originalTile);
  77.     }  
  78.    
  79.     private boolean buying() {
  80.         //*
  81.         /* Determines if we are buying or selling
  82.          */
  83.         RSItem[] coins = Inventory.find(995);
  84.         RSItem[] itemsToSell = Inventory.find(itemName);        
  85.         return  (coins.length > 0
  86.                  ? coins[0].getStack() >= buyingPrice
  87.                  && coins[0].getStack() >= startSellingSwitch : false)
  88.                  && itemsToSell.length <= 0;                   
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement