PlayerNPCs fix in ThePack ll
PHP Code:
/*Player NPCs*/
DROP TABLE IF EXISTS `odinms`.`playernpcs`;
CREATE TABLE `odinms`.`playernpcs` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(13) NOT NULL,
`hair` int(11) NOT NULL,
`face` int(11) NOT NULL,
`skin` int(11) NOT NULL,
`x` int(11) NOT NULL,
`cy` int(11) NOT NULL default '0',
`map` int(11) NOT NULL,
`ScriptId` int(10) unsigned NOT NULL default '0',
`Foothold` int(11) NOT NULL default '0',
`rx0` int(11) NOT NULL default '0',
`rx1` int(11) NOT NULL default '0',
`gender` int(11) NOT NULL default '0',
`dir` int(11) NOT NULL default'0',
PRIMARY KEY USING BTREE (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `odinms`.`playernpcs_equip`;
CREATE TABLE `odinms`.`playernpcs_equip` (
`id` int(11) NOT NULL auto_increment,
`NpcId` int(11) NOT NULL default '0',
`equipid` int(11) NOT NULL,
`equippos` int(11) NOT NULL default '0',
`type` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
I take full credits, tested and works.
Flame shield: off.
Re: PlayerNPCs fix in ThePack ll
what exactly is a player npc? 0_0
Re: PlayerNPCs fix in ThePack ll
Re: PlayerNPCs fix in ThePack ll
Re: PlayerNPCs fix in ThePack ll
Lies? It works 100%.. I just tested.
Re: PlayerNPCs fix in ThePack ll
How can you take full credits when you don't know what a player NPC is?
Re: PlayerNPCs fix in ThePack ll
Did you seriously belive that I don't know what playernpcs are o_o?
Re: PlayerNPCs fix in ThePack ll
This is just for the sql...Here's the command (taken from xotic and modified rx1 because it was wrong):
PHP Code:
} else if (splitted[0].equalsIgnoreCase("!playernpc")) {
int scriptId = Integer.parseInt(splitted[2]);
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
int npcId;
if (splitted.length != 3) {
mc.dropMessage("Pleaase use the correct syntax. !playernpc <char name> <script name>");
} else if (scriptId < 9901000 || scriptId > 9901319) {
mc.dropMessage("Please enter a script name between 9901000 and 9901319");
} else if (victim == null) {
mc.dropMessage("The character is not in this channel");
} else {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE ScriptId = ?");
ps.setInt(1, scriptId);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
mc.dropMessage("The script id is already in use !");
rs.close();
} else {
rs.close();
ps = con.prepareStatement("INSERT INTO playernpcs (name, hair, face, skin, x, cy, map, ScriptId, Foothold, rx0, rx1, gender, dir) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
ps.setString(1, victim.getName());
ps.setInt(2, victim.getHair());
ps.setInt(3, victim.getFace());
ps.setInt(4, victim.getSkinColor().getId());
ps.setInt(5, player.getPosition().x);
ps.setInt(6, player.getPosition().y);
ps.setInt(7, player.getMapId());
ps.setInt(8, scriptId);
ps.setInt(9, player.getMap().getFootholds().findBelow(player.getPosition()).getId());
ps.setInt(10, player.getPosition().x + 50); // I should really remove rx1 rx0. Useless piece of douche
ps.setInt(11, player.getPosition().y - 50);
ps.setInt(12, victim.getGender());
ps.setInt(13, player.isFacingLeft() ? 0 : 1);
ps.executeUpdate();
rs = ps.getGeneratedKeys();
rs.next();
npcId = rs.getInt(1);
ps.close();
ps = con.prepareStatement("INSERT INTO playernpcs_equip (NpcId, equipid, equippos) VALUES (?, ?, ?)");
ps.setInt(1, npcId);
for (IItem equip : victim.getInventory(MapleInventoryType.EQUIPPED)) {
ps.setInt(2, equip.getItemId());
ps.setInt(3, equip.getPosition());
ps.executeUpdate();
}
ps.close();
rs.close();
ps = con.prepareStatement("SELECT * FROM playernpcs WHERE ScriptId = ?");
ps.setInt(1, scriptId);
rs = ps.executeQuery();
rs.next();
PlayerNPCs pn = new PlayerNPCs(rs);
for (ChannelServer channel : ChannelServer.getAllInstances()) {
MapleMap map = channel.getMapFactory().getMap(player.getMapId());
map.broadcastMessage(MaplePacketCreator.SpawnPlayerNPC(pn));
map.broadcastMessage(MaplePacketCreator.getPlayerNPC(pn));
map.addMapObject(pn);
}
}
ps.close();
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
Equips still do not work. Thanks for the fix =) Had it already,my playernpcs started working by using this command I just posted.
Re: PlayerNPCs fix in ThePack ll
Oops I'm sorry... I can't detect sarcasm on the internet...
Re: PlayerNPCs fix in ThePack ll
Quote:
Originally Posted by
Lejgolacsz
This is just for the sql...Here's the command (taken from xotic and modified rx1 because it was wrong):
PHP Code:
} else if (splitted[0].equalsIgnoreCase("!playernpc")) {
int scriptId = Integer.parseInt(splitted[2]);
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
int npcId;
if (splitted.length != 3) {
mc.dropMessage("Pleaase use the correct syntax. !playernpc <char name> <script name>");
} else if (scriptId < 9901000 || scriptId > 9901319) {
mc.dropMessage("Please enter a script name between 9901000 and 9901319");
} else if (victim == null) {
mc.dropMessage("The character is not in this channel");
} else {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE ScriptId = ?");
ps.setInt(1, scriptId);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
mc.dropMessage("The script id is already in use !");
rs.close();
} else {
rs.close();
ps = con.prepareStatement("INSERT INTO playernpcs (name, hair, face, skin, x, cy, map, ScriptId, Foothold, rx0, rx1, gender, dir) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
ps.setString(1, victim.getName());
ps.setInt(2, victim.getHair());
ps.setInt(3, victim.getFace());
ps.setInt(4, victim.getSkinColor().getId());
ps.setInt(5, player.getPosition().x);
ps.setInt(6, player.getPosition().y);
ps.setInt(7, player.getMapId());
ps.setInt(8, scriptId);
ps.setInt(9, player.getMap().getFootholds().findBelow(player.getPosition()).getId());
ps.setInt(10, player.getPosition().x + 50); // I should really remove rx1 rx0. Useless piece of douche
ps.setInt(11, player.getPosition().y - 50);
ps.setInt(12, victim.getGender());
ps.setInt(13, player.isFacingLeft() ? 0 : 1);
ps.executeUpdate();
rs = ps.getGeneratedKeys();
rs.next();
npcId = rs.getInt(1);
ps.close();
ps = con.prepareStatement("INSERT INTO playernpcs_equip (NpcId, equipid, equippos) VALUES (?, ?, ?)");
ps.setInt(1, npcId);
for (IItem equip : victim.getInventory(MapleInventoryType.EQUIPPED)) {
ps.setInt(2, equip.getItemId());
ps.setInt(3, equip.getPosition());
ps.executeUpdate();
}
ps.close();
rs.close();
ps = con.prepareStatement("SELECT * FROM playernpcs WHERE ScriptId = ?");
ps.setInt(1, scriptId);
rs = ps.executeQuery();
rs.next();
PlayerNPCs pn = new PlayerNPCs(rs);
for (ChannelServer channel : ChannelServer.getAllInstances()) {
MapleMap map = channel.getMapFactory().getMap(player.getMapId());
map.broadcastMessage(MaplePacketCreator.SpawnPlayerNPC(pn));
map.broadcastMessage(MaplePacketCreator.getPlayerNPC(pn));
map.addMapObject(pn);
}
}
ps.close();
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
Equips still do
not work. Thanks for the fix =) Had it already,my playernpcs started working by using this command I just posted.
ThePack II already has the !playernpc, and this won't work for it..
Re: PlayerNPCs fix in ThePack ll
Try it. With the old playernpc command it didn't,because it set rx1 wrong I believe or whatever. It worked for me with this command from xotic.
Re: PlayerNPCs fix in ThePack ll
It works with the one that it comes with as well, that's the one I used to make this playernpc.
Re: PlayerNPCs fix in ThePack ll
well for me it didn't. But equips do not work for you also? I wonder if the command would affect that much.
Re: PlayerNPCs fix in ThePack ll
Quote:
Originally Posted by
mspirate217
what exactly is a player npc? 0_0
that's if you create an NPC that exactly looks like a player you want :tongue:
Re: PlayerNPCs fix in ThePack ll
Quote:
Originally Posted by
Lejgolacsz
well for me it didn't. But equips do not work for you also? I wonder if the command would affect that much.
It worked perfectly for me with ThePack II's command and this SQL.