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!

A command.

<3
Joined
Feb 4, 2011
Messages
481
Reaction score
123
There is no such command, since a release of such a command isn't always useful to everyone (or a lot of people). But it is possible to code it.

Here is my idea of how your code should work for this command:

1) First, get the the characters in the map.
2) Store the characters names in a data structure.
3) Afterwards, create the randomization process for an index in the array that is to be printed out, and then print out which index was selected randomly.

PS: For the data structure, I'd recommend an array. However, if the randomization process is looking for a player that isn't there, then allow it to randomize again, until it finds a player that is within the map. And when it does, print out the IGN.
 
Upvote 0
<3
Joined
Feb 4, 2011
Messages
481
Reaction score
123
I don't want to spoonfed you, but I'd recommend you to read a Java tutorial, and this code snippet should help you a bit.

// This part was written by Veda. It was taken out of the thread that you linked to.
public void mapMessage(String message) {
for (MapleCharacter map : getPlayer().getMap().getCharacters()) {
map.dropMessage(message);
}
}
 
Upvote 0
Initiate Mage
Joined
May 22, 2012
Messages
49
Reaction score
1
Code:
} else if (splitted[0].equals("randomplayer")) {
            for (MapleCharacter chr : player.getMap().getCharacters()) {
                player.mapMessage("The player picked was: " + );
            }

I dont know what to add into randomizer.java
 
Upvote 0
<3
Joined
Feb 4, 2011
Messages
481
Reaction score
123
I dont know what to add into randomizer.java

I've already told you how I'd implement the code, and as I stated earlier, try to pick up some Java before attempting this. Anyways, I've decided to comment the code for you, so you have a basic idea of what you are doing.



'//' are code comments. These are ignored by the compiler, and is meant for human use. So that developers can comment the code and others can pick it up to see what they are doing.
 
Last edited:
Upvote 0
Initiate Mage
Joined
May 22, 2012
Messages
49
Reaction score
1
I've already told you how I'd implement the code, and as I stated earlier, try to pick up some Java before attempting this. Anyways, I've decided to comment the code for you, so you have a basic idea of what you are doing.



'//' are code comments. These are ignored by the compiler, and is meant for human use. So that developers can comment the code and others can pick it up to see what they are doing.
i know that.. I just don't know how to add in the function where it randomizes the player's name
 
Upvote 0
Experienced Elementalist
Joined
Apr 18, 2009
Messages
211
Reaction score
38
PHP:
} else if (sub[0].equalsIgnoreCase("randomplayer")) {
            List<String> list = new ArrayList<String>();
            for (MapleCharacter chr : player.getMap().getCharacters()) {
                list.add(chr.getName());
            }
            String[] availableChar = list.toArray(new String[list.size()]);
            int chosenChar = Randomizer.rand(0, availableChar.length);
            player.getMap().broadcastMessage(MaplePacketCreator.sendYellowTip("The chosen player was " + availableChar[chosenChar] + "."));
 
Upvote 0
Initiate Mage
Joined
May 22, 2012
Messages
49
Reaction score
1
PHP:
} else if (sub[0].equalsIgnoreCase("randomplayer")) {
            List<String> list = new ArrayList<String>();
            for (MapleCharacter chr : player.getMap().getCharacters()) {
                list.add(chr.getName());
            }
            String[] availableChar = list.toArray(new String[list.size()]);
            int chosenChar = Randomizer.rand(0, availableChar.length);
            player.getMap().broadcastMessage(MaplePacketCreator.sendYellowTip("The chosen player was " + availableChar[chosenChar] + "."));

thanks so much :D
 
Upvote 0
Back
Top