Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Mesos to nxCash Command

Status
Not open for further replies.
Newbie Spellweaver
Joined
Jul 17, 2008
Messages
29
Reaction score
0
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.
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)
... 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
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) {
...and if it passes this check it executes the deduction of mesos and and increment of the nxCash.
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;
		}
	}
 
Newbie Spellweaver
Joined
Jul 17, 2008
Messages
29
Reaction score
0
My server is running Odin most of my Sql scripts are from ragezone.
It's the least I can do :p

Oh sorry guys I updated it. I has some of the code commented out so the deduction and checks are not applied to a GM.
 
Master Summoner
Loyal Member
Joined
Nov 30, 2007
Messages
511
Reaction score
0
Change
Code:
 if (player.getMeso() > cost) {
to
Code:
 if (player.getMeso() >= cost) {
Or the player won't be able to do it if they have exactly the right amount. ;o
 
Legendary Battlemage
Joined
May 23, 2008
Messages
628
Reaction score
4
Uhm... I have a question :p
Will this duplicate your nx or something? Because last time i set up an NPC that sold nx and i found a bug that duplicates your nx when you buy a lot of nx
 
Legendary Battlemage
Joined
May 23, 2008
Messages
628
Reaction score
4
1 problem tho...
you can always type in @nxcash -10000
Which will give them mesos :)
 
Newbie Spellweaver
Joined
Aug 26, 2005
Messages
58
Reaction score
1
hi, i always wondered if i should release this command but now some1 did, with a huge huge mistake.. :O

let me correct it,
PHP:
else if (splitted[0].equals("@buynx")) {
                   int nxcash;
                    nxcash = Integer.parseInt(splitted[1]);
                    
                    int cost = nxcash * 6666;
                    nxcash = Integer.parseInt(splitted[1]);
                    MapleCharacter player = c.getPlayer();
                    if ( player.getMeso() < cost ) {
                        mc.dropMessage("Insufficient Mesos");
                    }else if(nxcash <= 0){
                    mc.dropMessage("Don't even think about it ;) ");
                    }
                    
                    else if(nxcash > 30000) {
                      mc.dropMessage("Max 30k at a time.");
                    }
                    
                    else if (player.getMeso() >= cost && nxcash <= 30000 && nxcash > 0) {
                           player.gainMeso(-cost, true);
                    player.modifyCSPoints(0, nxcash);
                  
                    mc.dropMessage("You now have " + player.returnCSPoints(0) + " nxCash.");
                } else {
                    mc.dropMessage("Usage: @buynx <amount> where amount = your desired cash. 1NX = 6666Mesos");
}
                
            }

For 0.60/0.59 ONLY, put this After any command in ur playercommands.java, remember it, and at the bottom put this or it will not work.
PHP:
new CommandDefinition("buynx", "", "Buys NX", 0),

So if you put it after @rebirth, put it like this

PHP:
new CommandDefinition("rebirth", "", "Rebirths", 0),
new CommandDefinition("buynx", "", "Buys NX", 0),
 
Newbie Spellweaver
Joined
Jun 1, 2008
Messages
91
Reaction score
0
I know its been a year but wouldnt he be the first to post a correct working one?
If he isnt the first I apologize in advance but atleast his post was to contribute to the forums.
 
Newbie Spellweaver
Joined
Sep 29, 2008
Messages
21
Reaction score
0
Thanks so much. I've been looking for one of these. Anyone tested it yet? Btw where can I learn java. I really want to code stuff myself.
 
Elite Diviner
Joined
Apr 24, 2008
Messages
416
Reaction score
2
nice new function lol i heard some1 has it in their server already
 
Newbie Spellweaver
Joined
Aug 26, 2005
Messages
58
Reaction score
1
Thanks so much. I've been looking for one of these. Anyone tested it yet? Btw where can I learn java. I really want to code stuff myself.

"tested" (i made it :O) and used in my server for 3 months now =]
CDSMs.
 
Status
Not open for further replies.
Back
Top