IF YOU DID BEFORE POST 140 AND HAVE A PROBLEM LOOK AT THE FIX AT THE BOTTOM OR IN POST 140
IF YOU DID THIS BEFORE POST 86, SEE THIS FIX: http://www.rune-server.org/runescape...ml#post2712349
Well i've had this too long, and its being sold left right and centre which is a bit unfair considering pretty much everyone has it. SO lets get going! (PS this has the dupe fixes)
If you wish to send me some money feel free to at [email protected], all money I receive usually goes towards beer so its a great investment from your point of view, once you do that I usally come on drunk and send me my shit code, so its usually well worth it.
Credits:
Me
Graham (For the default paypal ipn file)(Could never find the download)
Sabsabionline (For leeching / selling it to yall without the dupe fixes )
Few things to keep in mind, I wrote this a long time ago it was one of my first html / php scripts so its kinda shit , If you want my new and improved one visit this thread:
Few things before you start, IF YOU USE A FREE WEBHOST THEY USUALLY DO NOT SUPPORT REMOTE MYSQL SO OPEN A SUPPORT TICKET BEFORE YOU COMPLAIN HERE.
Website Side:
OK there's a few php files to upload but lets start first. In this tutorial I'm going to use CPanel, its the biggest in web management so it should work for all of you.
OK so login to your cpanel on your webhost, and go into "MySQL databases"
In here we will create a new database.
Look for the heading "Create New Database", below here type in your database name, usually something to do with donate, so type in donate and click "Create Database", Once done, click the "go back" button, and you should be back on the previous screen.
Now scroll down to "MySQL Users", in here we will add a new mysql user (NOTE SOME PHP VERSIONS DON'T SUPPORT RANDOMLY GENERATED PASSWORDS, (i.e some symbols), So i recommend you set it yourself.
Then click create user. And write down the username and password (preferably in real life in some kind of notepad as that cant usually be stolen + your friends are prob tards, so they wont have a clue what its for).The scroll down to "Add User To Database" here select your username, and add it to the database you created earlier. The next screen will ask about permissions, just tick all the boxes and click "OK".
Ok now, we will go back to CPanel's main page. Here click into "PhpMyAdmin". Once youve logged into phpMyAdmin, On the left there is a list of all your databases. Click the database you created in the first step. Once in here click the "SQL" tab. This will bring up a dialog box, copy and paste the below code and click the "Go" button.
Code:
CREATE TABLE IF NOT EXISTS `donation` (
`username` varchar(32) NOT NULL,
`time` varchar(100) NOT NULL,
`productid` varchar(100) NOT NULL,
`price` decimal(10,0) NOT NULL,
`tickets` int(11) NOT NULL,
`index` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`index`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Ok nearly done!!!! (With mysql)
Now here is a zip file: http://rs2-server.com/downloads/rune...r_release2.zip
What you must do with this zip file, is upload it to your webhost. And extract it. (ITS BEST TO UPLOAD TO A DIRECTORY CALLED DONATE and extract in there)
Once these files have been extracted we want to edit "db.php", In here we set our database setting from the first few steps. So replace
USERNAME with your USERNAME
PASSWORD with your PASSWORD
DATABASE with your DATABASE
simple enough. Now go back to your CPanel's main page, and click into "Remote MySQL". In here you MUST add your dedicated servers IP, or the hosters IP Address. If you don't do this, nothing will work.....
Server Side
Ok its simple enough. First we create a new class called MadTurnipConnection.java
(IF YOUR USING PI, IT MUST NOT BE PUT IN "package server", so put it in "package server.util")
Below is the following code for Project Insanity, If people want delta just request and ill post it.
Code:
package server.util;
import java.sql.*;
import server.model.players.Client;
public class MadTurnipConnection extends Thread {
public static Connection con = null;
public static Statement stm;
public static void createConnection() {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://website/database", "username", "password");
stm = con.createStatement();
} catch (Exception e) {
e.printStackTrace();
con = null;
stm = null;
}
}
public MadTurnipConnection(){
}
public void run() {
while(true) {
try {
if(con == null)
createConnection();
else
ping();
Thread.sleep(10000);//10 seconds
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void ping(){
try {
String query = "SELECT * FROM donation WHERE username = 'null'";
query(query);
} catch (Exception e) {
e.printStackTrace();
con = null;
stm = null;
}
}
public static void addDonateItems(final Client c,final String name){
if(con == null){
if(stm != null){
try {
stm = con.createStatement();
} catch(Exception e){
con = null;
stm = null;
//put a sendmessage here telling them to relog in 30 seconds
return;
}
} else {
//put a sendmessage here telling them to relog in 30 seconds
return;
}
}
new Thread(){
@Override
public void run()
{
try {
String name2 = name.replaceAll(" ","_");
String query = "SELECT * FROM donation WHERE username = '"+name2+"'";
ResultSet rs = query(query);
boolean b = false;
while(rs.next()){
int prod = Integer.parseInt(rs.getString("productid"));
int price = Integer.parseInt(rs.getString("price"));
if(prod == 1 && price == 3){
c.getItems().addItem(4151,1);
b = true;
} else if(prod == 2 && price == 6){
c.getItems().addItem(4151,1);
b = true;
} else if(prod == 3 && price == 9){
c.getItems().addItem(4151,1);
b = true;
}
}
if(b){
query("DELETE FROM `donation` WHERE `username` = '"+name2+"';");
}
} catch (Exception e) {
e.printStackTrace();
con = null;
stm = null;
}
}
}.start();
}
public static ResultSet query(String s) throws SQLException {
try {
if (s.toLowerCase().startsWith("select")) {
ResultSet rs = stm.executeQuery(s);
return rs;
} else {
stm.executeUpdate(s);
}
return null;
} catch (Exception e) {
e.printStackTrace();
con = null;
stm = null;
}
return null;
}
}
If you use battlescape or delta change (also remove imports)
c.getItems().addItem(4151,1);
to
and
public static void addDonateItems(final Client c,final String name){
to
public static void addDonateItems(final client c,final String name){
Again we must edit this file to the database details we made in the first few steps:
So edit this line
con = DriverManager.getConnection("jdbc:mysql://website/database", "username", "password");
An example for rune-server could be
con = DriverManager.getConnection("jdbc:mysql://www.rune-server.org/database", "username", "password");
Ok now open Server.java declare:
public static MadTurnipConnection md;
in your method
below it add this:
Code:
md = new MadTurnipConnection();
md.start();
also import the file: import server.util.MadTurnipConnection;
also do this in client.java.
Now open client.java and find this method:
below it add
Code:
MadTurnipConnection.addDonateItems(this,playerName);
OK YOUR ALL DONE!!!!! WOO!!!, but wait, thats if you want to send ME money, and only sell whips, for different prices. So read below if you want to add or customize the items!!!!
Ok to create a new item you need 3 things:
Item Name,
Item Id,
Price,
ProductId,
so for example, whip, 4151, $3, 4
Now first open donate.php on your webhost and look for the following code:
Code:
<select name="prod">
<option value="1">Party Hats</option>
<option value="2">barrows</option>
<option value="3">bandos</option>
</select>
in here we put 2 values, the productId, and the Item Name so for our whip we would do, (ProductID 4, Name: Whip)
Code:
<select name="prod">
<option value="1">Party Hats</option>
<option value="2">barrows</option>
<option value="3">bandos</option>
<option value="4">Whip</option>
</select>
We then must edit paypal.php (once opened search for)
change this to your email (Or you can donate to me, I guarantee all donated money will go towards beer and writing more stupid stuff like this)
then below it is
Code:
if($_GET['prod'] == 1)
$price = '3.00';
if($_GET['prod'] == 2)
$price = '6.00';
if($_GET['prod'] == 3)
$price = '9.00';
here we use our ProductId, and Price. so for our whip it is
Code:
if($_GET['prod'] == 1)
$price = '3.00';
if($_GET['prod'] == 2)
$price = '6.00';
if($_GET['prod'] == 3)
$price = '9.00';
if($_GET['prod'] == 4)
$price = '3.00';
Now finaly we edit the serverside code in MadTurnipConnection. Scroll down to:
Code:
if(prod == 1 && price == 3){
c.getItems().addItem(4151,1);
b = true;
} else if(prod == 2 && price == 6){
c.getItems().addItem(4151,1);
b = true;
} else if(prod == 3 && price == 9){
c.getItems().addItem(4151,1);
b = true;
}
here we use our, productId, Price, and itemId, so for a whip it is
Code:
if(prod == 1 && price == 3){
c.getItems().addItem(4151,1);
b = true;
} else if(prod == 2 && price == 6){
c.getItems().addItem(4151,1);
b = true;
} else if(prod == 3 && price == 9){
c.getItems().addItem(4151,1);
b = true;
} else if(prod == 4 && price == 3){
c.getItems().addItem(4151,1);
b = true;
}
Lastly open paypal.php and comment out these 3 lines:
$fh = fopen(".ipn", "a");
fwrite($fh, print_r($p->ipn_data, true));
fclose($fh);
aka changing them to:
//$fh = fopen(".ipn", "a");
//fwrite($fh, print_r($p->ipn_data, true));
// fclose($fh);
Hopefully you learned how it works, I don't really recommend on using it as its done very badly but it works, so enjoy and stop letting all those noobs keep ripping you off!