Lone Posted May 2, 2016 Share Posted May 2, 2016 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. Quote Link to comment Share on other sites More sharing options...
FrostBug Posted May 2, 2016 Share Posted May 2, 2016 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"); that shouldn't even compile try: URL submit = new URL("http://heinous.xyz/update.php?name=" + getClient().getUsername().replace(" ", "_") + "&time=" + instance.getExperienceTracker().getElapsed(Skill.WOODCUTTING) + "&exp=" + instance.getExperienceTracker().getGainedXP(Skill.ATTACK) + "&premium=YES"); Quote Link to comment Share on other sites More sharing options...