Kennelz
August 5th, 2011, 02:48
Hello and welcome to Kennelz Kreations, the posts that pertain to adding unique features to your server in an easy, spoon-fed way. In this tutorial, you will hopefully be able to add the Double Experience Mode as it is known in the Call of Duty series to your server.
KEEP IN MIND:
-My tutorials could be shortened/extended due to my skill in java compared to others.
-My tutorials may have been redone in the past by others, I may have improved it detail-wise.
-I try to make useful, unique tutorials of things I made myself and have rarely seen posted.
-I am no pro, I still consider myself a rookie.
How to add Double Experience Mode:
Purpose: Similar to Bonus Experience on Runescape, with this mode, players on your server can gain X2 the normal experience when skilling or training.
Difficulty: */***** (Beginner)
Tested on: Pur3zscape source, but any 508-525 should do, maybe even higher/lower.
Files modified: Player.java, RS2LoginProtocol.java
Procedure: Copy and Paste, Text changing.
What you will learn: Booleans.
Step 1.
Open player.java. Along with the other public ints and booleans, add this to the group:
public boolean doubleExperience = unknown;
This is what you will change when you want to enable or disable Double Experience on your server. Change the word "unknown" to "false" to disable Double Experience. Change "unknown" to "true" to enable Double Experience. If your not going to want Double Experience to be left on, leave it "false".
Step 2.
CTRL + F. Search for:
public void appendExperience
This is the section of code that deals with adding experience to a skill, along with the level-up messages. Look for:
if (skillXP[skillId] > 200000000) {
return;
}
skillXP[skillId] += amount;
After the "}", add this directly under it:
if (doubleExperience) {
skillXP[skillId] += amount;
}
It should look like this when done correctly:
if (skillXP[skillId] > 200000000) {
return;
}
if (doubleExperience) {
skillXP[skillId] += amount;
}
skillXP[skillId] += amount;
When the value for doubleExperience is "true", it adds the player's earned experience to the skill in which the player gets experience for. With the skillXP line repeated again, it will add the experience again, giving the Double Experience effect. If doubleExperience is "false", the whole skillXP line is ignored and is done once.
Here's what I mean more easily explained.
If you cut a basic tree for 50 exp. when you have doubleExperience set to false, total exp. earned is 50.
If you cut a basic tree for 50 exp. when you have doubleExperience set to true, total exp. earned is 100.
Save and exit player.java.
Step 3. (optional)
You can skip this, but its always nice to let players know its double experience time. So go to your login messages by opening RS2LoginProtcol.java and search for one of them.
Here's mine:
p.getActionSender().sendMessage(p, "Welcome Back To Unitedpk ZETA, " + p.username.substring(0, 1).toUpperCase()+p.username.substring(1));
p.getActionSender().sendMessage(p, "<col=336600>Your Status: Server Ranking: "+p.serverpoints+".");
p.getActionSender().sendMessage(p, "<col=336600>Time Played: "+p.day+" Days "+p.hr+" Hours "+p.min+" Minutes "+p.sec+" Seconds.");
p.getActionSender().sendMessage(p, "<col=FF0000>Its Double Experience Days!");
All you need to do is add this line under any of the messages you send. These show up in the chatbox in the order you add them:
p.getActionSender().sendMessage(p, "<col=FF0000>Its Double Experience Days!");
col=FF0000 is an HTML color code, you can either change it or delete from < to >. If your not enabling double experience on your server yet, comment out the line when your not using it by adding "//" in front of the line. That way people won't see your server saying that its double experience, when its really not. Delete the "//" in front when you want it to resay it when your trying to make it Double Experience again.
Save and exit RS2Protocol.java.
Step 4.
Compile and restart your server. Test it out!
~Special notes for advanced coders~
It doesnt have to be just double experience, it can be more such as X3 or X10, or even bonuses of 1500, 4000, or more. To do this, modify this line inside the if statement:
skillXP[skillId] += amount;
~Learn Something New with Java~
Boolean statements check for a true or false condition. Depending on the desired outcome, something else may go into effect. Look at the examples below:
public boolean tired = false;
public boolean awake = true;
public boolean hungry;
public int ate = 1;
public int didnt = 0;
if(tired) {
gotoSleep;
}
else if(awake) {
play;
}
if(ate == 1) {
hungry = false;
}
else if(didnt == 1) {
hungry = true;
}
~END OF TUTORIAL~
Thanks for viewing!
KEEP IN MIND:
-My tutorials could be shortened/extended due to my skill in java compared to others.
-My tutorials may have been redone in the past by others, I may have improved it detail-wise.
-I try to make useful, unique tutorials of things I made myself and have rarely seen posted.
-I am no pro, I still consider myself a rookie.
How to add Double Experience Mode:
Purpose: Similar to Bonus Experience on Runescape, with this mode, players on your server can gain X2 the normal experience when skilling or training.
Difficulty: */***** (Beginner)
Tested on: Pur3zscape source, but any 508-525 should do, maybe even higher/lower.
Files modified: Player.java, RS2LoginProtocol.java
Procedure: Copy and Paste, Text changing.
What you will learn: Booleans.
Step 1.
Open player.java. Along with the other public ints and booleans, add this to the group:
public boolean doubleExperience = unknown;
This is what you will change when you want to enable or disable Double Experience on your server. Change the word "unknown" to "false" to disable Double Experience. Change "unknown" to "true" to enable Double Experience. If your not going to want Double Experience to be left on, leave it "false".
Step 2.
CTRL + F. Search for:
public void appendExperience
This is the section of code that deals with adding experience to a skill, along with the level-up messages. Look for:
if (skillXP[skillId] > 200000000) {
return;
}
skillXP[skillId] += amount;
After the "}", add this directly under it:
if (doubleExperience) {
skillXP[skillId] += amount;
}
It should look like this when done correctly:
if (skillXP[skillId] > 200000000) {
return;
}
if (doubleExperience) {
skillXP[skillId] += amount;
}
skillXP[skillId] += amount;
When the value for doubleExperience is "true", it adds the player's earned experience to the skill in which the player gets experience for. With the skillXP line repeated again, it will add the experience again, giving the Double Experience effect. If doubleExperience is "false", the whole skillXP line is ignored and is done once.
Here's what I mean more easily explained.
If you cut a basic tree for 50 exp. when you have doubleExperience set to false, total exp. earned is 50.
If you cut a basic tree for 50 exp. when you have doubleExperience set to true, total exp. earned is 100.
Save and exit player.java.
Step 3. (optional)
You can skip this, but its always nice to let players know its double experience time. So go to your login messages by opening RS2LoginProtcol.java and search for one of them.
Here's mine:
p.getActionSender().sendMessage(p, "Welcome Back To Unitedpk ZETA, " + p.username.substring(0, 1).toUpperCase()+p.username.substring(1));
p.getActionSender().sendMessage(p, "<col=336600>Your Status: Server Ranking: "+p.serverpoints+".");
p.getActionSender().sendMessage(p, "<col=336600>Time Played: "+p.day+" Days "+p.hr+" Hours "+p.min+" Minutes "+p.sec+" Seconds.");
p.getActionSender().sendMessage(p, "<col=FF0000>Its Double Experience Days!");
All you need to do is add this line under any of the messages you send. These show up in the chatbox in the order you add them:
p.getActionSender().sendMessage(p, "<col=FF0000>Its Double Experience Days!");
col=FF0000 is an HTML color code, you can either change it or delete from < to >. If your not enabling double experience on your server yet, comment out the line when your not using it by adding "//" in front of the line. That way people won't see your server saying that its double experience, when its really not. Delete the "//" in front when you want it to resay it when your trying to make it Double Experience again.
Save and exit RS2Protocol.java.
Step 4.
Compile and restart your server. Test it out!
~Special notes for advanced coders~
It doesnt have to be just double experience, it can be more such as X3 or X10, or even bonuses of 1500, 4000, or more. To do this, modify this line inside the if statement:
skillXP[skillId] += amount;
~Learn Something New with Java~
Boolean statements check for a true or false condition. Depending on the desired outcome, something else may go into effect. Look at the examples below:
public boolean tired = false;
public boolean awake = true;
public boolean hungry;
public int ate = 1;
public int didnt = 0;
if(tired) {
gotoSleep;
}
else if(awake) {
play;
}
if(ate == 1) {
hungry = false;
}
else if(didnt == 1) {
hungry = true;
}
~END OF TUTORIAL~
Thanks for viewing!