!pmob/!pnpc for LocalMS v83

Results 1 to 3 of 3
  1. #1
    Member sunbinyuan is offline
    MemberRank
    Mar 2009 Join Date
    On EarthLocation
    53Posts

    !pmob/!pnpc for LocalMS v83

    In AdminCommand.java or w/e:
    !pmob
    PHP Code:
            } else if (splitted[0].equals("pmob")) {
                
    int npcId Integer.parseInt(splitted[1]);
                
    int mobTime Integer.parseInt(splitted[2]);
                if (
    splitted[2] == null) {
                    
    mobTime 0;
                }
                
    int xpos player.getPosition().x;
                
    int ypos player.getPosition().y;
                
    int fh player.getMap().getFootholds().findBelow(player.getPosition()).getId();
                
                
    MapleMonster mob MapleLifeFactory.getMonster(npcId);
                if (
    mob != null && !mob.getName().equals("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(1npcId);
                        
    ps.setInt(20);
                        
    ps.setInt(3fh);
                        
    ps.setInt(4ypos);
                        
    ps.setInt(5xpos 50);
                        
    ps.setInt(6xpos 50);
                        
    ps.setString(7"m");
                        
    ps.setInt(8xpos);
                        
    ps.setInt(9ypos);
                        
    ps.setInt(10player.getMapId());
                        
    ps.setInt(11mobTime);
                        
    ps.executeUpdate();
                    } catch (
    SQLException e) {
                        
    player.dropMessage("Failed to save MOB to the database");
                    }
                                final 
    Point position mob.getPosition();
                                final 
    boolean mobile mob.isMobile();
                                
    player.getMap().addMonsterSpawn(mob.getId(), mobTimepositionmobile);
                } else {
                    
    player.dropMessage("You have entered an invalid Npc-Id");
                } 
    !pnpc
    PHP Code:
    } else if (splitted[0].equals("pnpc")) {
                
    int npcId Integer.parseInt(splitted[1]);
                
    MapleNPC npc MapleLifeFactory.getNPC(npcId);
                
    int xpos player.getPosition().x;
                
    int ypos player.getPosition().y;
                
    int fh player.getMap().getFootholds().findBelow(player.getPosition()).getId();
                if (
    npc != null && !npc.getName().equals("MISSINGNO")) {
                    
    npc.setPosition(player.getPosition());
                    
    npc.setCy(ypos);
                    
    npc.setRx0(xpos 50);
                    
    npc.setRx1(xpos 50);
                    
    npc.setFh(fh);
                    try {
                        
    Connection con DatabaseConnection.getConnection();
                        
    PreparedStatement ps con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
                        
    ps.setInt(1npcId);
                        
    ps.setInt(20);
                        
    ps.setInt(3fh);
                        
    ps.setInt(4ypos);
                        
    ps.setInt(4ypos);
                        
    ps.setInt(5xpos 50);
                        
    ps.setInt(6xpos 50);
                        
    ps.setString(7"n");
                        
    ps.setInt(8xpos);
                        
    ps.setInt(9ypos);
                        
    ps.setInt(10player.getMapId());
                        
    ps.executeUpdate();
                    } catch (
    SQLException e) {
                        
    player.dropMessage("Failed to save NPC to the database");
                    }
                    
    player.getMap().addMapObject(npc);
                    
    player.getMap().broadcastMessage(MaplePacketCreator.spawnNPC(npc));
                } else {
                    
    player.dropMessage("You have entered an invalid Npc-Id");
                } 
    In MapleMapFactory.java
    Add:
    PHP Code:
                try
            {
                                    
    Connection con DatabaseConnection.getConnection();
                                    
    PreparedStatement ps con.prepareStatement("SELECT * FROM spawns WHERE mid = ?");
                                    
    ps.setInt(1omapid);
                                    
    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(idfhidefhcyrx0rx1xytype);

                                            if(
    type.equals("n"))
                                            {
                                                
    map.addMapObject(myLife);
                                            }
                                           else if (
    type.equals("m")) {

                                                
    MapleMonster monster = (MapleMonstermyLife;
                                                final 
    Point position monster.getPosition();
                                                final 
    boolean mobile monster.isMobile();
                                                
    map.addMonsterSpawn(monster.getId(), mobTimepositionmobile);
                                            }
                                        }
                                    } catch(
    SQLException e) {
                                    } 
    After
    PHP Code:
                    if (mapData.getChildByPath("area") != null) {
                        for (
    MapleData area mapData.getChildByPath("area")) {
                            
    int x1 MapleDataTool.getInt(area.getChildByPath("x1"));
                            
    int y1 MapleDataTool.getInt(area.getChildByPath("y1"));
                            
    int x2 MapleDataTool.getInt(area.getChildByPath("x2"));
                            
    int y2 MapleDataTool.getInt(area.getChildByPath("y2"));
                            
    map.addMapleArea(new Rectangle(x1y1, (x2 x1), (y2 y1)));
                        }
                    } 
    Then add
    PHP Code:
        private AbstractLoadedMapleLife giveLife(int idint fboolean hideint fhint cyint rx0int rx1int xint yString type) {
            
    AbstractLoadedMapleLife myLife MapleLifeFactory.getLife(idtype);
            
    myLife.setCy(cy);
            
    myLife.setF(f);
            
    myLife.setFh(fh);
            
    myLife.setRx0(rx0);
            
    myLife.setRx1(rx1);
            
    myLife.setPosition(new Point(xy));
            
    myLife.setHide(hide);
            return 
    myLife;
        } 
    After
    PHP Code:
        public boolean isMapLoaded(int mapId) {
            return 
    maps.containsKey(mapId);
        } 
    And here is the SQL file:
    PHP Code:
    SET FOREIGN_KEY_CHECKS=0;
    -- ----------------------------
    -- 
    Table structure for spawns
    -- ----------------------------
    DROP TABLE IF EXISTS `spawns`;
    CREATE TABLE `spawns` (
      `
    idint(11NOT NULL auto_increment,
      `
    iddint(11NOT NULL,
      `
    fint(11NOT NULL,
      `
    fhint(11NOT NULL,
      `
    typevarchar(1NOT NULL,
      `
    cyint(11NOT NULL,
      `
    rx0int(11NOT NULL,
      `
    rx1int(11NOT NULL,
      `
    xint(11NOT NULL,
      `
    yint(11NOT NULL,
      `
    mobtimeint(11) default '1000',
      `
    midint(11NOT NULL,
      
    PRIMARY KEY  (`id`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1;

    -- ----------------------------
    -- 
    Records 
    -- ---------------------------- 
    Enjoy!~
    Last edited by sunbinyuan; 02-12-10 at 07:03 PM.


  2. #2
    Omega TriumpH is offline
    MemberRank
    May 2004 Join Date
    HU/PL/DELocation
    5,360Posts

    Re: !pmob/!pnpc for LocalMS v83

    keep it clean nabnutz, its a valid release so it stays. Normal posts only that contribute something or i just ban all of your asses.

  3. #3
    Member boltez1 is offline
    MemberRank
    Jun 2009 Join Date
    SEALocation
    65Posts

    Re: !pmob/!pnpc for LocalMS v83

    Tested and working?



Advertisement