PHP Code:
} else if (splitted[0].equalsIgnoreCase("pmob")) {
int npcId = Integer.parseInt(splitted[1]);
int monsterId;
int mobTime = Integer.parseInt(splitted[2]);
int xpos = player.getPosition().x;
int ypos = player.getPosition().y;
int fh = player.getMap().getFootholds().findBelow(player.getPosition()).getId();
if (splitted[2] == null) {
mobTime = 0;
}
MapleMonster mob = MapleLifeFactory.getMonster(npcId);
if (mob != null && !mob.getName().equalsIgnoreCase("MISSINGNO")) {
mob.setPosition(player.getPosition());
mob.setCy(ypos);
mob.setRx0(xpos + 50);
mob.setRx1(xpos - 50);
mob.setFh(fh);
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid, mobtime ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
ps.setInt(1, npcId);
ps.setInt(2, 0);
ps.setInt(3, fh);
ps.setInt(4, ypos);
ps.setInt(5, xpos + 50);
ps.setInt(6, xpos - 50);
ps.setString(7, "m");
ps.setInt(8, xpos);
ps.setInt(9, ypos);
ps.setInt(10, player.getMapId());
ps.setInt(11, mobTime);
ps.executeUpdate();
} catch (SQLException e) {
player.dropMessage("Failed to save MOB to the database");
}
player.getMap().addMonsterSpawn(mob, mobTime);
} else {
player.dropMessage("You have entered an invalid Npc-Id");
}