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!

!reloadmap <ID>

Junior Spellweaver
Joined
Jan 4, 2010
Messages
123
Reaction score
9
!reloadmap &amp;lt;ID&amp;gt;

Is there a way to make this used for both methods ie:
!reloadmap -reloads the current map
!reloadmap <ID> - reloads the map ID you've requested.

The reason I'm requesting this is because when I spawn an npc that doesn't - it breaks the map.
I'd have to cc in order to finish whatever I am doing on said map...
This would be extremely useful to have.

Obviously I did some digging and couldn't find this anywhere on here...
Maybe because it's simple to implement ??

I'm no vigorous coder so please do fill me in with tips!!


!reloadmap command

package client.command.commands.gm3;

import client.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import server.maps.MapleMap;

import java.util.Collection;

public class ReloadMapCommand extends Command {
{
setDescription("");
}

@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
MapleMap newMap = c.getChannelServer().getMapFactory().resetMap(player.getMapId());
int callerid = c.getPlayer().getId();

Collection<MapleCharacter> characters = player.getMap().getAllPlayers();

for (MapleCharacter chr : characters) {
chr.saveLocationOnWarp();
chr.changeMap(newMap);
if (chr.getId() != callerid)
chr.dropMessage("You have been relocated due to map reloading. Sorry for the inconvenience.");
}
newMap.respawn();
}
}



HeavenMS Source btw.
ANY help is much appreciated.
 
Newbie Spellweaver
Joined
Jul 31, 2013
Messages
30
Reaction score
21
The command only reloads the current map. If you want to reload another map by giving it an ID you'll have to read from the params variable.
If parameters are specified that means the player wants to reload a specific map. If none are available then reload the current map.

Here's an answer I came up with after briefly looking at Heaven's CommandsExecutor.
Like you said, this is pretty simple and I'd suggest trying to figure out the answer yourself before looking at mine with the hint I just gave.

The only thing wrong with this command that I notice right away is the map doesn't reload on all channels (but that might not matter depending on your situation) and the command will throw an error if a non-numerical input is given.

Code:
public void execute(MapleClient c, String[] params) {
    MapleCharacter player = c.getPlayer();

    [COLOR=#ff0000]// if the command is '!reloadmap' then params.length should return 0.
    // if the command is '!reloadmap 10000' then params.length is 1.
    int mapId = params.length == 1 ? Integer.parseInt(params[0]) : player.getMapId();    
    MapleMap newMap = c.getChannelServer().getMapFactory().resetMap(mapId);[/COLOR]
    int callerid = c.getPlayer().getId();

    Collection<MapleCharacter> characters = player.getMap().getAllPlayers();

    for (MapleCharacter chr : characters) {
        chr.saveLocationOnWarp();
        chr.changeMap(newMap);
        if (chr.getId() != callerid)
            chr.dropMessage("You have been relocated due to map reloading. Sorry for the inconvenience.");
    }
    newMap.respawn();
}
 
Upvote 0
Junior Spellweaver
Joined
Jan 4, 2010
Messages
123
Reaction score
9
Thanks for the reply man ! I will go and test this.
Yes I was looking at the !goto <id> command trying to get some insight. This source is definitely coded differently from other sources I've used in the past.
I learn from reading code rather than testing a bunch of things.
I will try to see if I can manipulate what you've suggested.

Also for your code, if I am in lets say Henesys.. and want to reload the FM, would it warp me to the map that I reloaded? That's what it looks like it's doing.

Thanks again!
 
Upvote 0
Newbie Spellweaver
Joined
Jul 31, 2013
Messages
30
Reaction score
21
Good catch, in that case you need to get the map you want to reset, before the reset.
With that you can call getAllPlayers which will return those in that map rather than the one you're in.

Code:
public void execute(MapleClient c, String[] params) {
    MapleCharacter player = c.getPlayer();

    // if the command is '!reloadmap' then params.length should return 0.
    // if the command is '!reloadmap 10000' then params.length is 1.
    int mapId = params.length == 1 ? Integer.parseInt(params[0]) : player.getMapId();
   [COLOR=#ff0000] // get the old map so we can warp players after resetting
    MapleMap oldMap = c.getChannelServer().getMapFactory().getMap(mapId);[/COLOR]
    MapleMap newMap = c.getChannelServer().getMapFactory().resetMap(mapId);
    int callerid = c.getPlayer().getId();

[COLOR=#ff0000]    // get the players from the old map
    Collection<MapleCharacter> characters = oldMap.getAllPlayers();[/COLOR]

    for (MapleCharacter chr : characters) {
        chr.saveLocationOnWarp();
        chr.changeMap(newMap);
        if (chr.getId() != callerid)
            chr.dropMessage("You have been relocated due to map reloading. Sorry for the inconvenience.");
    }
    newMap.respawn();
}
 
Last edited:
Upvote 0
Back
Top