020020020 发表于 2018-8-3 19:52:36

續發布的TMS113 關於PNPC的修復法

找到MapleMapFactory.java

try
                              {
                                        Connection con = DatabaseConnection.getConnection();
                                        PreparedStatement ps = con.prepareStatement("SELECT * FROM spawns WHERE mid = ?");
                                        ps.setInt(1, omapid);
                                        ResultSet rs = ps.executeQuery();
                                        while (rs.next()) {
                                                int id = rs.getInt("idd");
                                                int f = rs.getInt("f");
                                                boolean hide = false;
                                                String type = rs.getString("type");
                                                int _fh = rs.getInt("fh");
                                                int cy = rs.getInt("cy");
                                                int rx0 = rs.getInt("rx0");
                                                int rx1 = rs.getInt("rx1");
                                                int x = rs.getInt("x");
                                                int y = rs.getInt("y");
                                                int mobTime = rs.getInt("mobtime");

                                                AbstractLoadedMapleLife myLife = loadLife(id, f, hide, _fh, cy, rx0, rx1, x, y, type);

                                                if(type.equals("n"))
                                                {
                                                      map.addMapObject(myLife);
                                                }
                                        }
                              } catch(SQLException e) {
                              }
                              


改成

try
{
                  PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT * FROM spawns WHERE mid = ?");
                  ps.setInt(1, omapid);
                  ResultSet rs = ps.executeQuery();
                  while (rs.next()) {
                        int sqlid = rs.getInt("idd");
                        int sqlf = rs.getInt("f");
                        boolean sqlhide = false;
                        String sqltype = rs.getString("type");
                        int sqlfh = rs.getInt("fh");
                        int sqlcy = rs.getInt("cy");
                        int sqlrx0 = rs.getInt("rx0");
                        int sqlrx1 = rs.getInt("rx1");
                        int sqlx = rs.getInt("x");
                        int sqly = rs.getInt("y");
                        int sqlmobTime = rs.getInt("mobtime");
                        AbstractLoadedMapleLife sqlmyLife = loadLife(sqlid, sqlf, sqlhide, sqlfh, sqlcy, sqlrx0, sqlrx1, sqlx, sqly, sqltype);
                        switch (sqltype) {
                            case "n":
                              map.addMapObject(sqlmyLife);
                              break;
                            case "m":
                              MapleMonster monster = (MapleMonster) sqlmyLife;
                              map.addMonsterSpawn(monster, sqlmobTime, (byte) -1, null);
                              break;
                        }
                  }
                } catch (SQLException e){
                              }

沒意外的話這樣子加上去之後也能把固定spawn怪物的功能寫到command裡面

因為原來的問題應該是開server的時候抓不到sql

宗達 发表于 2019-3-2 01:53:58

我是這篇文的作者 :P
页: [1]
查看完整版本: 續發布的TMS113 關於PNPC的修復法