Tutorial Dynamic Signatures

Discussion in 'Tutorials & Resources' started by Geashaw, Feb 1, 2015.

  1. This post will be updated when I finish fapping.

    Code snippet one;
    Code (Text):
    1.  
    2. package com.runemate.geashawscripts.dynamicSignatureTutorial;
    3.  
    4. //Imports are all the classes that we are going to use methods from
    5.  
    6. import com.runemate.game.api.hybrid.RuneScape;
    7. import com.runemate.game.api.hybrid.util.StopWatch;
    8. import com.runemate.game.api.script.framework.LoopingScript;
    9.  
    10. import java.io.BufferedReader;
    11. import java.io.InputStreamReader;
    12. import java.net.URL;
    13. import java.net.URLConnection;
    14.  
    15. public class dynamicSignatureTutorial extends LoopingScript {
    16.  
    17.     private String userName;
    18.  
    19.     private final StopWatch runtime = new StopWatch();
    20.     private StopWatch updateTimer = new StopWatch();
    21.     private final int updateInterval = 15000;
    22.  
    23.     private long timeRanSoFar, lastRunTime;
    24.  
    25.     private int xpGained = 0, expGainedSoFar = 0, lastExpGained,
    26.     hidesTanned = 0, hidesTannedSoFar = 0, lastHidesTanned = 0,
    27.     profitMade = 0, profitMadeSoFar = 0, lastProfitMade = 0,
    28.     userId;
    29.  
    30.     @Override
    31.     public void onStart(String...args) {
    32.         // Getting the forum data.
    33.         userId = com.runemate.game.api.hybrid.Environment.getForumId();
    34.         userName = com.runemate.game.api.hybrid.Environment.getForumName();
    35.         // Starting both timers.
    36.         runtime.start();
    37.         updateTimer.start();
    38.         // Standard loop delay little slower than normal.
    39.         setLoopDelay(100, 200);
    40.     }
    41.  
    42.     @Override
    43.     public void onPause() {
    44.         runtime.stop();
    45.     }
    46.  
    47.     @Override
    48.     public void onResume() {
    49.         runtime.start();
    50.     }
    51.  
    52.     @Override
    53.     public void onLoop() {
    54.  
    55.         // Check if the user is logged in.
    56.         if (RuneScape.isLoggedIn()) {
    57.  
    58.             // Update the database.
    59.             if (updateTimer.getRuntime() > updateInterval) {
    60.  
    61.                 timeRanSoFar = (runtime.getRuntime() - lastRunTime) / 1000;
    62.                 expGainedSoFar = xpGained - lastExpGained;
    63.                 profitMadeSoFar = profitMade - lastProfitMade;
    64.                 hidesTannedSoFar = hidesTanned - lastHidesTanned;
    65.  
    66.                 updateDatabase(userId, userName, timeRanSoFar, expGainedSoFar, profitMadeSoFar, hidesTannedSoFar);
    67.  
    68.                 updateTimer.reset();
    69.  
    70.                 // Reset xp gained, profit made and hides tanned.
    71.                 lastRunTime = runtime.getRuntime();
    72.                 lastExpGained = xpGained;
    73.                 lastProfitMade = profitMade;
    74.                 lastHidesTanned = hidesTanned;
    75.             }
    76.         }
    77.     }
    78.  
    79.     private void updateDatabase(int userId, String userName, long time, int exp, int profit, int hidesTanned) {
    80.  
    81.         System.out.println("--- Inserting data into the database ---");
    82.         System.out.println("1. Runtime: " + time);
    83.         System.out.println("2. Experience: " + exp);
    84.         System.out.println("3. Profit made: " + profit);
    85.         System.out.println("4. Hides tanned: " + hidesTanned);
    86.  
    87.         try {
    88.             String website = "http://example.com";
    89.             URL submit = new URL(website + "/update?uid=" + userId + "&username=" + userName + "&runtime=" + (time / 1000) + "&exp=" + exp + "&profit=" + profit + "&hides=" + hidesTanned);
    90.             URLConnection connection = submit.openConnection();
    91.             connection.setDoInput(true);
    92.             connection.setDoOutput(true);
    93.             connection.setUseCaches(false);
    94.             final BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    95.             String line;
    96.  
    97.             while ((line = rd.readLine()) != null) {
    98.                 if (rd.readLine().contains("success")) {
    99.                     System.out.println("Successfully updated!");
    100.                 } else if (line.toLowerCase().contains("fuck off")) {
    101.                     System.out.println("Something is fucked up, couldn't update!");
    102.                 }
    103.                 rd.close();
    104.             }
    105.         } catch (Exception e) {
    106.             e.printStackTrace();
    107.         }
    108.     }
    109. }
    110.  
     
    #1 Geashaw, Feb 1, 2015
    Last edited: Feb 1, 2015
  2. Looks good! Keen to see the rest of the tutorial, dynamic sigs are sweeeet
     
  3. Thanks, will update the php side soon, though I use Drupal... See my signature for the results (that look cached...)
     
  4. Seems like @Geashaw never did finish fapping. RIP
     
    Aria and srpronto like this.
  5. SlashnHax likes this.
  6. I think runemate should implement this :p and not the scripts bots :)
    Like per user what type of xp (like in skills), money made, time ran, what script bot he/she used :)
    @Arbiter
     
  7. RM would need to provide the server, the tables for data for each bot, the API etc. in that case.
    It would be nice though, but it's more feasible for the Bot Authors to do it atm :/
     
  8. inb4runematecontrolappformobilephones
     
  9. yes plz!
     
  10. Would be sweet.
     
  11. now i need to use teamviewer :p an app would be nice xd
     
  12. Haha that would be good for the goldfarmers among us :D
     
  13. Defeat3d and I were working on one for android, tbh we got pretty damn far regarding it, we were able to shut down, pause and resume the bot, request a paint aswell as a canvas update and requesting updates on kills, profit etc.
    But since no one of us has time to spend on scripting atm we don't know if it's ever to come out :/
     

Share This Page

Loading...