Files edited: Client.java
Difficulty: 1/10
Procedure:Open your Client.java and search for:
- Code:
-
private void customCommand
This is the list of all the commands. We will add all of our created commands under this.
Teleport Commands:This section will teach you about commands that will teleport you to a set of coords.
Procedure:We are going to start our 'if' statement.
- Code:
-
if (command.equalsIgnoreCase(“train”)) {
Explaining – This first line of code is very simple. Command.equalsIgnoreCase means that if the command is equal to “train” then the rest of our command will initialize. This is different from command.startswith which is mostly used in 2 parted commands such as ::banuser username. (“train”) is the command name.
- Code:
-
&& playerRights >= 0
is not needed unless you are setting it for mod or higher use only.
Now that we have our if statement we need to create the body for it.
- Code:
-
toX = 3333;
toY = 3333;
Explaining – This is also very straight forward. If you do ::train it will teleport you to the x and y coords listed. toX and toY are our variables for teleporting.
Now we need to close the command by adding a closing bracket.
- Code:
-
}
So this is our teleport command:
- Code:
-
if (command.equalsIgnoreCase(“train”)) {
toX = 3333;
toY = 3333;
}
If you want you can also add a message that will be sent to the player when using the command.
Before the closing bracket add:
- Code:
-
sM(“you teleport to train”);
Explaining – sM is our variable for sending messages to the user via the chat. It will not open as an interface. Inside (“”) goes the message you want.
Add item Commands:This section will teach you about commands that with add items to the players inventory.
Procedure:We are going to start our 'if' statement. - Code:
-
if (command.equalsIgnoreCase(“items”)) {
Explaining – This first line of code is very simple. Command.equalsIgnoreCase means that if the command is equal to “items” then the rest of our command will initialize. This is different from command.startswith which is mostly used in 2 parted commands such as ::banuser username. (
“items”) is the command name.
- Code:
-
&& playerRights >= 0
is not needed unless you are setting it for mod or higher use only.
Now we need to add a body to it.
- Code:
-
addItem(1050 ,1);
Explaining – addItem is the variable that will place the item and amount listed inside the set of () to the player inventory. Inside the parenthesis follows this: (item ID, amount).
Now just close the command using a -
[code]Explaining – addItem is the variable that will place the item and amount listed inside the set of () to the player inventory. Inside the parenthesis follows this: (item ID, amount).
Now just close the command using a -
- Quote :
- }
Note: Add additional -
[code]addItem(item ID, amount);[/code]
for the more items you want the command to give.
Give Skill exp Commands:This section will teach about creating a command that will add Experience a skill(s).
Procedure (using an integer):We are going to start our 'if' statement.
- Quote :
- if (command.equalsIgnoreCase(“pure”)) {
Explaining – This first line of code is very simple. Command.equalsIgnoreCase means that if the command is equal to “pure” then the rest of our command will initialize. This is different from command.startswith which is mostly used in 2 parted commands such as ::banuser username. (“pure”) is the command name.
- Quote :
- && playerRights >= 0
is not needed unless you are setting it for mod or higher use only.
Next we need to create a body.
- Quote :
- for (int i = 0; i < 22; i++)
{
if (i != 1 && i!= 5)
addSkillXP(15000000, i);
}
}
Explaining – this creates the integer for “i”. i < 22 means that “I” will be equal to 21 and lower. This makes it stand for every skill from 1-21. Then it isolates the skills numbers you want/don’t want. != 1 means NOT equal to 1, therefore it will not add to skill 1. && i! = 5, once again it will not add to skill 5. addSkillXP is the variable for adding skill exp. It is used in the format:
[code]addSkillXP(Exp amount, skill number[/code]
In this case our skill number is “i” which represents multiple skills.
Now close our command using a -
- Quote :
- }
Procedure (listing every skill):We are going to start our 'if' statement.
- Quote :
- if (command.equalsIgnoreCase(“pure”)) {
Explaining – This first line of code is very simple. Command.equalsIgnoreCase means that if the command is equal to “pure” then the rest of our command will initialize. This is different from command.startswith which is mostly used in 2 parted commands such as ::banuser username. (“pure”) is the command name.
- Quote :
- && playerRights >= 0
is not needed unless you are setting it for mod or higher use only.
Next we need to create a body.
- Quote :
- addSkillXP(15000000, 0);
addSkillXP(15000000, 2);
addSkillXP(15000000, 3);
addSkillXP(15000000, 4);
addSkillXP(15000000, 6);
Explaining – addSkillXP is the variable for adding exp to a skill. It follows the format of
- Quote :
- addSkillXP(exp amount, skill number);
Each skill has a corresponding number.
Now we close our command using a -
- Quote :
- }
Changing Player-Rights Commands:This section will teach you how to add commands to change a players rights.
Player-rights:
0 = Normal Player
1 = Moderator
2 = Administrator
3 = Owner/Co-Owner
4 = Hidden Owner/Admin
Procedure:We are going to start our 'if' statement.
- Quote :
- if (command.startswith(“makemod”) && playerRights >= 2) {
Explaining – This first line of code is very simple. Command.startswith means that if the command is starts with “makemode” then the rest of our command will initialize. Command.startsWith is used when you are creating a command that is used upon a different player or uses a substring. This is different from command.equalsIgnoreCase which is mostly in commands that give items, add skill xp, or teleport you somewhere. (“makemod”) is the command name.
- Quote :
- && playerRights >= 2
means that only players that have 2 or higher rights can use this command.
Now we need to create a body.
- Quote :
- String otherPName = command.substring(;
int otherPIndex = PlayerHandler.getPlayerID(otherPName);
client p = (client) server.playerHandler.players[otherPIndex];
p.rights = 1
p.sM(
"You are now a Moderator);
} else {
sM("The name doesnt exist.");
}
} catch (Exception e) {
sM("Try entering a name you want to make a mod..");
Explaining – the command.substring(
represents where the command ends and where the username begins. The substring must be equal to the command name (not the :: before it when you type it in-game) and the space after it. otherPIndex is an integer that is equal to PlayerHandler.getPlayerID(otherPName);. This is used to check if that username exists. Now we need to temporarily create the variable used, client p. This says that it will not change rights but will change the other players rights. If the playername does not exist it will send a message (sM) telling you that it does not.
Now we need to close our command with a -
- Quote :
- }
NOTE: Edit the commands to your needs and wants. They are just used as a base to show you what it is like.
I did not write this, I give full credits to -
100% - Darkning
~Kevin.