Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. } else if (sub[0].equals("!pnpc")) {
  2. int npcId = Integer.parseInt(sub[1]);
  3. MapleNPC npc = MapleLifeFactory.getNPC(npcId);
  4. int xpos = player.getPosition().x;
  5. int ypos = player.getPosition().y;
  6. int fh = player.getMap().getFootholds().findBelow(player.getPosition()).getId();
  7. if (npc != null && !npc.getName().equals("MISSINGNO")) {
  8. npc.setPosition(player.getPosition());
  9. npc.setCy(ypos);
  10. npc.setRx0(xpos + 50);
  11. npc.setRx1(xpos - 50);
  12. npc.setFh(fh);
  13. npc.setCustom(true);
  14. try {
  15. Connection con = DatabaseConnection.getConnection();
  16. PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
  17. ps.setInt(1, npcId);
  18. ps.setInt(2, 0);
  19. ps.setInt(3, fh);
  20. ps.setInt(4, ypos);
  21. ps.setInt(5, xpos + 50);
  22. ps.setInt(6, xpos - 50);
  23. ps.setString(7, "n");
  24. ps.setInt(8, xpos);
  25. ps.setInt(9, ypos);
  26. ps.setInt(10, player.getMapId());
  27. ps.executeUpdate();
  28. } catch (SQLException e) {
  29. mc.dropMessage("Failed to save NPC to the database");
  30. }
  31. player.getMap().addMapObject(npc);
  32. player.getMap().broadcastMessage(MaplePacketCreator.spawnNPC(npc));
  33. } else {
  34. mc.dropMessage("You have entered an invalid Npc-Id");
  35. }
  36. } else if (sub[0].equals("!pmob")) {
  37. int npcId = Integer.parseInt(sub[1]);
  38. int mobTime = Integer.parseInt(sub[2]);
  39. int xpos = player.getPosition().x;
  40. int ypos = player.getPosition().y;
  41. int fh = player.getMap().getFootholds().findBelow(player.getPosition()).getId();
  42. if (sub[2] == null) {
  43. mobTime = 0;
  44. }
  45. MapleMonster mob = MapleLifeFactory.getMonster(npcId);
  46. if (mob != null && !mob.getName().equals("MISSINGNO")) {
  47. mob.setPosition(player.getPosition());
  48. mob.setCy(ypos);
  49. mob.setRx0(xpos + 50);
  50. mob.setRx1(xpos - 50);
  51. mob.setFh(fh);
  52. try {
  53. Connection con = DatabaseConnection.getConnection();
  54. PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid, mobtime ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
  55. ps.setInt(1, npcId);
  56. ps.setInt(2, 0);
  57. ps.setInt(3, fh);
  58. ps.setInt(4, ypos);
  59. ps.setInt(5, xpos + 50);
  60. ps.setInt(6, xpos - 50);
  61. ps.setString(7, "m");
  62. ps.setInt(8, xpos);
  63. ps.setInt(9, ypos);
  64. ps.setInt(10, player.getMapId());
  65. ps.setInt(11, mobTime);
  66. ps.executeUpdate();
  67. } catch (SQLException e) {
  68. mc.dropMessage("Failed to save MOB to the database");
  69. }
  70. player.getMap().addMonsterSpawn(mob, mobTime);
  71. } else {
  72. mc.dropMessage("You have entered an invalid Npc-Id");
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement