Jump to content

Lone

Lifetime Sponsor
  • Posts

    216
  • Joined

  • Last visited

  • Feedback

    100%

Posts posted by Lone

  1. Trying to get one working to show items collected and time ran. I was following Toms guide: http://osbot.org/forum/topic/83371-dynamic-signature-tutorial-with-pictures/

     

    And I believe I have everything correct except the onExit part of it.

     

    My on exit code

    try {
    			URL submit = new URL("http://heinous.xyz + "/update.php?name="All"
    					+ getClient().getUsername().replace(" ", "_")
    					+ "&time=runTime"
    					+ instance.getExperienceTracker().getElapsed(Skill.WOODCUTTING)
    					+ "&exp="
    					+ instance.getExperienceTracker().getGainedXP(Skill.ATTACK)
    					+ "&premium=" + "YES");
    			
    			URLConnection con = submit.openConnection();
    			instance.log("Submitting statistics...");
    			con.setDoInput(true);
    			con.setDoOutput(true);
    			con.setUseCaches(false);
    			final BufferedReader rd = new BufferedReader(
    					new InputStreamReader(con.getInputStream()));
    			rd.close();
    		} catch (Exception e) {
    			instance.log("Failed to submit print details");
    		} 
    

    My signature.php code:

    <?  
     
     
     
    function formatTime($time){
        $time_seconds = $time / 1000;
        $time_minutes = $time_seconds / 60;
        $time_hours = $time_minutes / 60;
    $time_days = floor($time_hours / 24);
        $seconds = $time_seconds % 60;
        $minutes = $time_minutes % 60;
        $hours = $time_hours % 24;
        
    $days = floor($time_days % 365);
    $years = floor($time_days / 365);
     
    return $years . "y " . $days . "d " .$hours . "h " . $minutes . "m ";
    }
     
     
    $username="my_username_is_right"; //Your MySQL Username. 
    $password="my_password_is_right"; // Your MySQL Pass. 
    $database="my_database_is_right"; // Your MySQL database. 
    $host="localhost"; // Your MySQL host. This is "localhost" or the IP specified by your hosting company. 
     
     
     
    $player_name=$_GET['player_name']; // This gets the player his name from the previous page. 
     
     
    mysql_connect($host,$username,$password); // Connection to the database. 
    @mysql_select_db($database) or die( "Unable to select database. Be sure the databasename exists and online is."); //Selection of the database. If it can't read the database, it'll give an error. 
     
     
    /* To protect MySQL injection. */ 
    $player_name = stripslashes($player_name); 
    $player_name = mysql_real_escape_string($player_name); 
    /*    */
     
     
     
    if($player_name == "ALL"){ // If you want to sum all of your users data, like I have in my signature, you need this.
     
        $query="SELECT SUM(timeran) as timesum FROM Data";
        $result=mysql_query($query); 
        $Timeran1= mysql_fetch_assoc($result);
        $Timeran = $Timeran1[timesum];
     
     
         $query="SELECT SUM(expgained) as expsum FROM Data";
    $result=mysql_query($query); 
         $ExpGained1= mysql_fetch_assoc($result);
    $ExpGained = $ExpGained1[expsum];
     
     
    // Now for the creation of the image.
     
     
     
        header('Content-Type: image/png;'); 
     // Your image must be in the same directory as your PHP Scripts for it to work, otherwise you will need to include a path
        $im = @imagecreatefrompng('tannerbackground.png') or die("Cannot find image, check naming and file location");
     
     
     
        $text_color = imagecolorallocate($im, 255,255,100); // RED, GREEN, BLUE , you can goto http://colorpicker.com to pick a nice colour if you wish. 
     
        $text_username = "ALL"; // This gets the information about player name to be showed in the picture. 
        $text_timeran = formatTime($Timeran); // Same as above ^^ 
        $text_expgained = number_format($ExpGained);
     
     
        $font = 'Calibri.ttf'; //Upload your custum font to the directory where this file is placed if you wish to customise it.
     
    // 18 is the font size, 0 is the angel of the text, 165 is the x coordinate on your image, and 132 is the Y coordinate on your image.
        imagettftext($im, 18, 0, 165, 132, $text_color, $font, 'ALL'); 
        imagettftext($im, 12, 0, 300, 93, $text_color, $font, $text_timeran); 
        imagettftext($im, 14, 0, 130, 93, $text_color, $font, $text_expgained); 
        imagepng($im); 
        imagedestroy($im); 
        return;
    }
     
    // Below is the code for regular players, it will not SUM
     
    $query="SELECT * FROM Data WHERE Username='$player_name'"; // Gets all the information about the player. 
     
    $result=mysql_query($query); 
    $i=mysql_num_rows($result); // Here we are counting how many rows this result gives us. 
     
     
    if ($i == 1) // If the user has been correct, then it'll give us 1 row. If its 1 row, then it'll proceed with the code. 
    { 
     
     
        $Username=mysql_result($result,0,"Username");
        $Timeran=mysql_result($result,0,"timeran");
        $ExpGained=mysql_result($result,0,"expgained");
     
         // Creating of the .png image.  
     
     
     
        header('Content-Type: image/png;'); 
     
     
     
         header('Content-Type: image/png;'); 
    // Your image must be in the same directory as your PHP Scripts for it to work, otherwise you will need to include a path
        $im = @imagecreatefrompng('tannerbackground.png') or die("Cannot find image, check naming and file location");
     
        $text_color = imagecolorallocate($im, 255,255,100); // RED, GREEN, BLUE , you can goto http://colorpicker.com to pick a nice colour if you wish. 
        $text_username = "$Username"; // This gets the information about player name to be showed in the picture.  // This gets the information about player name to be showed in the picture. 
        $text_timeran = formatTime($Timeran); // Same as above ^^ 
        $text_expgained = number_format($ExpGained);
     
        $font = 'Calibri.ttf'; //Upload your custum font to the directory where this file is placed. Then change the name here. 
     
    // 18 is the font size, 0 is the angel of the text, 165 is the x coordinate on your image, and 132 is the Y coordinate on your image.
        imagettftext($im, 12, 0, 138, 130, $text_color, $font, $text_username); 
        imagettftext($im, 12, 0, 300, 93, $text_color, $font, $text_timeran); 
        imagettftext($im, 14, 0, 138, 93, $text_color, $font, $text_expgained); 
     
        
     
        imagepng($im);
        imagedestroy($im); 
     
    } else echo('Username is not in our database. Please try again.'); // If the username doesn't exist (so the row is 0) then it'll give en error. 
     
    mysql_close(); 
     
    ?>
     
    My update.php:

    <?php
    // Connection details
    $servername = "www.heinous.xyz";
    $user = "correct_user";
    $password = "correct_password";
    $dbname = "correct_dbname";
     
    // Your data variables, you can have as many as you want.
    $timetemp = $_GET ['time']; // The total time ran
    $exptemp = $_GET ['exp']; // The total EXP gained
     
    $nametemp = $_GET ['name']; // The username of the botter.
    $premium = $_GET ['premium']; // "YES" if the user is premium, "NO" if they are using the free script
     
     
    // Variable conn is used to determine the new mysql connection for above data
     
    // If you are running this script off the same webserver that the database is stored on, the servername can be NULL.
    $conn = mysqli_connect ($servername, $user, $password, $dbname );
     
    // Checking if the connection is valid, if not, killing the process and throwing a error message
    if ($conn->connect_error) {
    die ( "Connection failed: " . $conn->connect_error );
    }
     
    if (mysqli_connect_errno ()) {
    echo "Failed to connect to the mySQL server ";
    die ();
    }
     
    $setResult = mysqli_query ( $conn, "SELECT * FROM Data WHERE Username='$nametemp'" ); // Selects all fields from the Data table, based on the username supplied
    if ($setResult) { 
     
    /* 
    If the Table already contains some data for this user,
    it will instead ADD the new data onto the old data, then insert it back into the table.
    */
    $resultArray = mysqli_fetch_row($setResult);
    $time = $resultArray[1];
    $exp = $resultArray[2];
     
     
    $exp2 = $exp + $exptemp;
    $time2 = $time + $timetemp;
     
    // Query for inserting the wanted data into the mysql - Where Data is the table name
    $sql = "REPLACE INTO Data (Username, timeran, expgained, premium)
    VALUES ('$nametemp', '$time2',' $exp2', '$premium')";
     
    if (mysqli_query ( $conn, $sql )) {
    echo "Recorded Data";
    } else {
    echo "Error: " . $sql . "<br>" . mysqli_error ( $conn );
    }
    } else{ // If there is currently no user data, it will insert a fresh sample.
        $sql = "INSERT INTO Data (Username, timeran, expgained, premium)
    VALUES ('$nametemp', '$timetemp',' $exptemp', '$premium')";
     
    if (mysqli_query ( $conn, $sql )) {
    echo "Recorded new Data";
    } else {
    echo "Error: " . $sql . "<br>" . mysqli_error ( $conn );
    }
    }
    $conn->close ();
    ?>

     

     

    I really want it to only displayer # of collected items and time but trying to follow the guide as close as I can to make it work first.

     

     

     

  2. So I started my first script by following the tutorials on the osbot youtube channel, but using my own shit for what I want. lol

     

    Though I'm confused as to why some of the code doesn't work. For example in the video he types out,

     Which doesn't register for some reason, so I changed it to,

    instead. Will this work the same?

    Please remember I am new I may be using bad habbits, or harder ways of getting the same outcome!

     

     

    Woke up and wrote this before I have to go to work didn't have a lot of time so its missing a lot of checks that you will want to have when you make yours I.E (do you have coins, do you have enough hides, what to do if it runs into those issues etc..)  Somethings like navigating to Ellis I would change if I had more time. This has got me motivated to make a script that gathers an X amount of hide then tans it looping, might have that done when I get home from work.

     

     

    The script works fine but there are definitely better ways of doing everything hopefully by looking at this you can see that you have to map out what the bot needs to do and write it in a way that exceeds this.

    @ScriptManifest(name = "Tanner", author = "Bradf3rd", version = 1.0, info = "Tans Hide", logo = "") 
    public class LaTanner extends Script {
     
     
    private final Position store = new Position(3279,3191,0);
     
        @Override
        public void onStart() {
            //Put anything you want it to do on start like time etc..  
        }
        
        
        private enum State{
         BANK,WALK2ELLIS
        }
        
        private State getState(){
         if(!inventory.contains(1739)){//IF inventory doesn't contain hide
         return State.BANK; //Goes to bank
         } else {//Else it will
         return State.WALK2ELLIS;//Walk to ellis and tan the hides.
         }
             //Writing it like this basically means ONCE you tan the hides you won't have any remaining in yoru inventory to it switches back to the state BANK.
         }
        
        
        @Override
        public void onExit() {
            //Code here will execute after the script ends
     
     
        }
     
     
       
    @Override
        public int onLoop() throws InterruptedException {
    switch (getState()){
    
    case WALK2ELLIS: 
    
    RS2Widget leather = getWidgets().get(324, 148);//This is defining leather as the Soft Leather option in trade menu for Ellis see more from TFW's Tut http://osbot.org/forum/topic/96505-osbot-scripting-basics-and-snippets/
    walking.webWalk(store); //Walks to the position store which is initiated above.
    NPC ellis = getNpcs().closest("Ellis");//Initiates ellis as npc Ellis
    walking.walk(ellis);  //If ellis is near we walk to her
    sleep(random(300,600));//random sleep between 300 and 600 ms
    ellis.interact("Trade");//Interacts with npc ellis selecting the option trade.
    sleep(random(300,600));//random sleep between 300 and 600 ms
    leather.interact("Tan All");//uses our widget we made above and interacts with it by selecting the option tan all
    sleep(random(300,600));//random sleep between 300 and 600 ms
    break; 
    
    case BANK:
    
    walking.webWalk(Banks.AL_KHARID.getRandomPosition()); //Walks to AL_KHARID bank
    if(Banks.AL_KHARID.contains(myPlayer())){ //if Al kharid bank contains our player...
    sleep(random(300,600));//random sleep between 300 and 600 ms
    bank.open();//Opens bank
    sleep(random(300,600));//random sleep between 300 and 600 ms
    bank.withdraw(1739, 27);//Withdraws(int for our cowhides, number of cowhides)
    }
    break;
    }
     
            return 600; //The amount of time in milliseconds before the loop starts over
        }
     
     
        @Override
        public void onPaint(Graphics2D g) {
            //This is where you will put your code for paint(s)
     
     
     
     
        }
     
     
    }
    • Like 1
  3. You said you are trying to make a script and dont know where to start so why not write down what u are gonna do?

     

    So a tanning script would probably need cowhides + coins. So why not start at the bank

     

    1. Start script at bank check if inventory has hides + coins if not then withdraw them

    2. If invent has hides + coins then walk to tanner and tan it

    3. Now that the inventory has tanned hides go bank them

     

    As for the methods i think they got updated? Im not too sure so the old ones might not work, but try and see if the line u suggested works.

    Very good, I wanted to write something like this for him yesterday but unfortunately got busy. I will help you more op in a little bit.

    • Like 1
  4. Sorry I continue to ask question but I was wondering if someone could show me an example of Mouse.Click()? Say if I want to LEFT click a certain X,Y Cord. would it not be

    Mouse.Click(x,y, true)

    ?

     

     

     

    Is it possible to use getArea()?

     

    So it won't click in the exact same spot?

     

    If someone wouldn't mind showing me a couple examples of those being used when I tried doing it myself I couldn't get it fully working right.

     

    Thanks.

  5. I said that in my first post man. I don't know how to begin. I have the skeleton script, but I don't know where to start. Like do I start at the place I want, or the bank, do I start the walkpath first or? And then I think well how do I add more into this how do I connect this line of code with this line.

    Is what you are trying to make private? I just started yesterday myself so I can try to help you. It will be useful to me too.

  6. What I've noticed in a lot of video tutorials is people will just type out the script, say whatever they're doing and all of a sudden stuff just comes together. Uh how do I explain this better... Like they type out a word and it gets connected to the api some how. I don't know. Just confuses me.

     

    Thanks for the reply by the way.

    Have you attempted making a script before? Or just been watching videos? I would try making one on your own and then get a good understanding of what you can't grasp, that will make it easier to ask questions and get help imo.

  7. Hello everyone, I have been drifting around different forums for a while now really wanting to sit down and get serious about creating and publishing my own scripts. The tutorials on here as well as the supportive community has made my decision super easy. 

     

    Couple things about me:

    1. I'm 21 years old.
    2. Currently in college having taken courses in C#, C++, VB, and HTML.
    3. Been playing runescape for about 10 years.
    4. Started botting back when Rsbots.net was around.

     

    I currently own PerfectWoodcutter and PerfectFisher so if any of you have any suggestions on other great scripts I would love to hear them.

  8. This is due to your interact string being "Chop-down", where the actual one is "Chop down". No hyphen.

     

    The interact event is failing because it can't find the "Chop-down" action, since the actual one doesn't have the hyphen.

     

     

    Make sure to use the correct names smile.png

    Chop-down -> Chop down

    Thank you both! In the guide I saw a snippet of code "stall.interact("Steal-from");" so I thought it all was like that.

    • Like 1
  9. Hi I believe the issue will be in my case CHOP if more code is needed I can post it all just want to keep it simple.

     

    case CHOP:
        RS2Object tree = getObjects().closest("Tree");
        if (tree != null){
        tree.interact("Chop-down");
        }
        break;
     
    kPOugb5.gif
    As you can see it just floats over the object never interacting with it.
  10. i prefer having my bots randomly bring the finished goods to the mule after they go over a certain amount or run out. the mule trades the bot some gold and the bot buys the required supplies on the ge and repeats. the only thing i have to do on the mule is wait for the items to sell at a high price. i've been doing this for quite some time now, good luck with yours

    Are there public scripts like this? Havn't found one on here.

  11.  

    thank you for the kind words, as for the cursor, which cursor, the one with green lines that looks like a crosshair, or the white swirly cursor? By any means, I have all the code for each one so I can easily make some kind of toggle for cursors, like f1 f2 f3 to switch between cursors XD I think it will be a cool change, since I got hotkeys to work. I can even make a hide-paint hotkey and paint size changer

     

    That would be pretty cool because I usually watch my bot and it would make it a bit cooler imo wub.png

×
×
  • Create New...