I need it so that you can warp to people, and warp to maps, but you cannot warp other people other than yourself to maps. Please help?PHP Code:public static class Warp extends CommandExecute {
@Override
public int execute(MapleClient c, String[] splitted) {
MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
if (victim != null && c.getPlayer().getGMLevel() >= victim.getGMLevel() && !victim.inPVP() && !c.getPlayer().inPVP()) {
if (splitted.length == 2) {
c.getPlayer().changeMap(victim.getMap(), victim.getMap().findClosestSpawnpoint(victim.getTruePosition()));
} else {
MapleMap target = ChannelServer.getInstance(c.getChannel()).getMapFactory().getMap(Integer.parseInt(splitted[2]));
if (target == null) {
c.getPlayer().dropMessage(6, "Map does not exist");
return 0;
}
MaplePortal targetPortal = null;
if (splitted.length > 3) {
try {
targetPortal = target.getPortal(Integer.parseInt(splitted[3]));
} catch (IndexOutOfBoundsException e) {
// noop, assume the gm didn't know how many portals there are
c.getPlayer().dropMessage(5, "Invalid portal selected.");
} catch (NumberFormatException a) {
// noop, assume that the gm is drunk
}
}
if (targetPortal == null) {
targetPortal = target.getPortal(0);
}
}
} else {
try {
victim = c.getPlayer();
int ch = World.Find.findChannel(splitted[1]);
if (ch < 0) {
MapleMap target = c.getChannelServer().getMapFactory().getMap(Integer.parseInt(splitted[1]));
if (target == null) {
c.getPlayer().dropMessage(6, "Map does not exist");
return 0;
}
MaplePortal targetPortal = null;
if (splitted.length > 2) {
try {
targetPortal = target.getPortal(Integer.parseInt(splitted[2]));
} catch (IndexOutOfBoundsException e) {
// noop, assume the gm didn't know how many portals there are
c.getPlayer().dropMessage(5, "Invalid portal selected.");
} catch (NumberFormatException a) {
// noop, assume that the gm is drunk
}
}
if (targetPortal == null) {
targetPortal = target.getPortal(0);
}
c.getPlayer().changeMap(target, targetPortal);
} else {
victim = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterByName(splitted[1]);
c.getPlayer().dropMessage(6, "Cross changing channel. Please wait.");
if (victim.getMapId() != c.getPlayer().getMapId()) {
final MapleMap mapp = c.getChannelServer().getMapFactory().getMap(victim.getMapId());
c.getPlayer().changeMap(mapp, mapp.findClosestPortal(victim.getTruePosition()));
}
c.getPlayer().changeChannel(ch);
}
} catch (Exception e) {
c.getPlayer().dropMessage(6, "Something went wrong " + e.getMessage());
return 0;
}
}
return 1;
}
}


Reply With Quote

