Description: To add an hour of time in which players can recieve double exp for everything they do!
Difficulty: 1/10
Assumed Knowledge: Copy+Paste, able to replace a few things
Classes Modified: Server.java, Client.java
Tested on: Czar
Process:
Step 1: Declarations
Open up server.java and under or above
Code:
public static final int cycleTime = 500;
Add:
Code:
public static boolean HappyHour = false;
public static int HHTime = 0;
Step 2: Tell players when happy hour is activated
Save+Close Server.java
Open Client.java
Find your welcome messages
Usually under:
Code:
playerLastConnect = connectedFrom;
Add:
Code:
if (server.HappyHour == true) {
sendMessage("Happy Hour is activated! Hury only " + server.HHTime / 120 + " minutes left!");
} else {
sendMessage("Happy Hour is not activated, maybe [OWNERS NAME] will be nice enough to turn it on?");
}
Replace [OWNERS NAME] with your name
Step 3: Adding the Command
In client.java search:
Code:
customCommand(string command)
under that put:
Code:
if ((command.equalsIgnoreCase("Happy Hour")) && (playerName.equalsIgnoreCase("[OWNERS NAME]"))) {
if (server.HappyHour == false) {
server.HHTime = 7200;
server.HappyHour = true;
sendMessage("Happy Hour Enabled");
PlayerHandler.messageToAll = playerName + " has started Happy Hour! You now get double xp for everything you do!";
} else {
server.HHTime = 0;
server.HappyHour = false;
sendMessage("Happy Hour Disabled");
PlayerHandler.messageToAll = playerName + " has disabled Happy Hour. what did you do?";
}
}
Once again replace [OWNERS NAME] with your name
This checks if it is enabled or disabled if its disabled, it turns it on with a one hour timer, if it is on it shuts it off and removes the timer amount.
Step 4: Making the timer work
In client.java search:
Code:
public void process() {
or
Code:
public boolean process() {
Under it add:
Code:
if ((server.HHTime > 0) && (server.HappyHour == true)) {
server.HHTime -= 1;
} else if ((server.HHTime < 1) && (server.HappyHour == true)) {
server.HappyHour = false;
server.HHTime = 0;
PlayerHandler.messageToAll = "Happy Hour is over! Sorry!";
}
While you're in process you have the option of adding this:
Code:
if (server.HappyHour == true) {
if (misc.random(1000) == 1) {
PlayerHandler.messageToAll = "Time left for happy hour: " + server.HHTime / 120 + " minutes";
}
}
It's a random message, will run about 8 times an hour
Step 5: Fix AddSkillXP
In client.java search:
Code:
playerXP[skill] += amount;
and replace it with:
Code:
if (server.HappyHour == true) {
playerXP[skill] += amount * 2;
} else {
playerXP[skill] += amount;
}
Credits: 100% me!
Errors: Post them here!