I have less than a year, on and off, with Java so I am new to it but I managed to come up with a few GM Commands which I found pretty useful. My Private server is running OdinMS Rev988 v.55
NXCash: my private server uses an in game cash shop so I made a command which allows every player to convert their mesos into nxCash but you can easily use the code to convert it into maplepoints or gifttokens.
I'll explain how it works, Ignore this section if you can see it from the code
Anything beyond this is not required to get the code to work or instructions
It is just an explaination.
It checks if what is spelt is "!nxcash".
Than it checks if there is anything after "!nxcash"...
... and if there is it will continue and executing and if not it will just return this message which explains the syntax of the command
Than it extracts the number after the command into a variable called nxcash and multiples it by my exchange rate of 1000mesos for 1nxcash and stores it into cost.
Next it checked to make sure that the user has enough mesos to complete the transaction...
...and if it passes this check it executes the deduction of mesos and and increment of the nxCash.
This is the function that edits the CS points its located in
MapleCharacter.java
NXCash: my private server uses an in game cash shop so I made a command which allows every player to convert their mesos into nxCash but you can easily use the code to convert it into maplepoints or gifttokens.
Code:
else if (splitted[0].equals("!nxcash")) {
if (splitted.length == 2) {
int nxcash = Integer.parseInt(splitted[1]);
int cost = nxcash * 1000;
if (player.getMeso() > cost) {
player.gainMeso(-cost, true);
player.modifyCSPoints(0, nxcash);
mc.dropMessage("You now have " + player.returnCSPoints(0) + " nxCash.");
} else {
mc.dropMessage("You do not have enough mesos to do this...");
}
} else {
mc.dropMessage("!nxcash <amount of nxcash> The rate is 1000mesos for every nxCash pt.");
}
}
I'll explain how it works, Ignore this section if you can see it from the code
Anything beyond this is not required to get the code to work or instructions
It is just an explaination.
It checks if what is spelt is "!nxcash".
Code:
if (splitted[0].equals("!nxcash"))
Than it checks if there is anything after "!nxcash"...
Code:
if (splitted.length == 2)
Code:
mc.dropMessage("!nxcash <amount of nxcash> The rate is 1000mesos for every nxCash pt.");
Than it extracts the number after the command into a variable called nxcash and multiples it by my exchange rate of 1000mesos for 1nxcash and stores it into cost.
Code:
int nxcash = Integer.parseInt(splitted[1]);
int cost = nxcash * 1000;
Next it checked to make sure that the user has enough mesos to complete the transaction...
Code:
if (player.getMeso() > cost) {
Code:
//player.gainMeso(-cost, true);
player.modifyCSPoints(0, nxcash);
mc.dropMessage("You now have " + player.returnCSPoints(0) + " nxCash.");
This is the function that edits the CS points its located in
MapleCharacter.java
Code:
public void modifyCSPoints(int type, int quantity) {
if (type == 0) {
this.nxcash += quantity;
} else if (type == 1) {
this.maplepoints += quantity;
} else if (type == 2) {
this.gifttokens += quantity;
}
}