[Release]Real PlayerNPC SQL fix
PHP Code:
--
-- Definition of table `playernpcs`
--
DROP TABLE IF EXISTS `playernpcs`;
CREATE TABLE `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,
`map` int(11) NOT NULL,
`ScriptId` int(11) NOT NULL,
`Foothold` int(11) NOT NULL,
`rx0` int(11) NOT NULL,
`rx1` int(11) NOT NULL,
`gender` int(11) NOT NULL DEFAULT 0,
`dir` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `playernpcs`
--
/*!40000 ALTER TABLE `playernpcs` DISABLE KEYS */;
/*!40000 ALTER TABLE `playernpcs` ENABLE KEYS */;
--
-- Definition of table `playernpcs_equip`
--
DROP TABLE IF EXISTS `playernpcs_equip`;
CREATE TABLE `playernpcs_equip` (
`id` int(11) NOT NULL auto_increment,
`npcid` int(11) NOT NULL,
`equipid` int(11) NOT NULL,
`equippos` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `playernpcs_equip`
--
/*!40000 ALTER TABLE `playernpcs_equip` DISABLE KEYS */;
/*!40000 ALTER TABLE `playernpcs_equip` ENABLE KEYS */;
Have fun.
Re: [Release]Real PlayerNPC SQL fix
MsDartz is the player npc fixed now ?
Re: [Release]Real PlayerNPC SQL fix
MsDartz, so do you know how to make it load up the npc once the server restart?
Re: [Release]Real PlayerNPC SQL fix
Quote:
Originally Posted by
kokrong
MsDartz is the player npc fixed now ?
Gtfo out my thread.
Quote:
Originally Posted by
kingpimptony
MsDartz, so do you know how to make it load up the npc once the server restart?
It should auto do that. I don't play maple, or dev for it anymore.
Re: [Release]Real PlayerNPC SQL fix
[quote=msdartz;4920398
It should auto do that. I don't play maple, or dev for it anymore.[/quote]
noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
how could you leave me :*:
Re: [Release]Real PlayerNPC SQL fix
Quote:
Originally Posted by
FantiStory<3
noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
how could you leave me :*:
Fuck you, no one cares about you.
Re: [Release]Real PlayerNPC SQL fix
Quote:
Originally Posted by
iGoofy
Fuck you, no one cares about you.
Holy fuck.
I soiled myself.
Re: [Release]Real PlayerNPC SQL fix
Lol =P! I knew that when I was reading the PlayerNPC thing in Xotics xP! and ThePack II...wierd, how I read it today
Re: [Release]Real PlayerNPC SQL fix
That will entirely bug player npcs, Player npcs are treated as normal npcs so they need x and y and their default values to be 0..
Re: [Release]Real PlayerNPC SQL fix
this is the playernpc file \src\net\sf\odinms\server\life
PHP Code:
package org.rise.server.life;
import java.awt.Point;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import org.rise.client.MapleCharacter;
import org.rise.client.MapleClient;
import org.rise.database.DatabaseConnection;
import org.rise.net.channel.ChannelServer;
import org.rise.server.maps.MapleMapFactory;
import org.rise.tools.MockIOSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PlayerNPC {
private static Logger log = LoggerFactory.getLogger(MapleMapFactory.class);
private int id;
private int facingleft;
private Point pos;
private int mapid;
private int cid;
public PlayerNPC(MapleCharacter base, int mapid, Point pos) {
this.id = 0;
this.cid = base.getId();
this.facingleft = base.isFacingLeft() ? 0 : 1;
this.mapid = mapid;
this.pos = pos;
saveToDB();
}
public PlayerNPC(int id, int cid, int dir, int mapid, Point pos) {
this.id = id;
this.cid = cid;
this.facingleft = dir;
this.mapid = mapid;
this.pos = pos;
saveToDB();
}
public static PlayerNPC loadFromData(int id) {
PlayerNPC ret = null;
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE id = ?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret = new PlayerNPC(id, rs.getInt("characterid"), rs.getInt("dir"), rs.getInt("map"), new Point(rs.getInt("x"), rs.getInt("y")));
}
rs.close();
ps.close();
} catch (Exception e) {
log.error("Error loading PlayerNPC from data", e);
}
return ret;
}
public static List<PlayerNPC> loadFromMap(int map) {
List<PlayerNPC> npcs = new ArrayList<PlayerNPC>();
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE map = ?");
ps.setInt(1, map);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
npcs.add(loadFromData(rs.getInt("id")));
}
rs.close();
ps.close();
} catch (Exception se) {
log.error("Error loading PlayerNPCs from map", se);
}
return npcs;
}
public void saveToDB() {
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE id = ?");
ps.setInt(1, this.getId());
ResultSet rs = ps.executeQuery();
PreparedStatement psup;
if (rs.next()) {
psup = con.prepareStatement("UPDATE playernpcs SET characterid = ?, dir = ?, x = ?, y = ?, map = ? WHERE id = ?");
psup.setInt(1, this.getCharId());
psup.setInt(2, this.getDir());
psup.setInt(3, this.getPos().x);
psup.setInt(4, this.getPos().y);
psup.setInt(5, this.getMapId());
psup.setInt(6, this.getId());
psup.executeUpdate();
psup.close();
} else {
//generate a new id because cid sucks like that
psup = con.prepareStatement("INSERT INTO playernpcs(characterid, dir, x, y, map) VALUES (?, ?, ?, ?, ?)");
psup.setInt(1, this.getCharId());
psup.setInt(2, this.getDir());
psup.setInt(3, this.getPos().x);
psup.setInt(4, this.getPos().y);
psup.setInt(5, this.getMapId());
psup.executeUpdate();
ResultSet rsup = psup.getGeneratedKeys();
if (rsup.next()) {
setId(rsup.getInt(1));
}
psup.close();
}
rs.close();
ps.close();
} catch (Exception se) {
log.error("Error saving PlayerNPC", se);
}
}
public int getId() {
return id;
}
public int getCharId() {
return cid;
}
public int getMapId() {
return mapid;
}
public Point getPos() {
return pos;
}
public int getDir() {
return facingleft;
}
public void setId(int id) {
this.id = id;
}
public void setCharId(int cid) {
this.cid = cid;
}
public void setMapId(int name) {
this.mapid = name;
}
public void setPos(Point name) {
this.pos = name;
}
public MapleCharacter getBase() {
for (ChannelServer cserv : ChannelServer.getAllInstances()) {
if (cserv.getPlayerStorage().getCharacterById(cid) != null) {
return cserv.getPlayerStorage().getCharacterById(cid);
}
}
try {
return MapleCharacter.loadCharFromDB(cid, new MapleClient(null, null, new MockIOSession()), false);
} catch (Exception e) {
log.error("Error loading base from PlayerNPC", e);
}
return null;
}
}
How do i fix it to make it work properly?
I think this cause the problem the npc won't load up because it doesnt match the sql.
My apology if this is too troublesome for you =(
Re: [Release]Real PlayerNPC SQL fix
Quote:
Originally Posted by
kingpimptony
this is the playernpc file \src\net\sf\odinms\server\life
PHP Code:
package org.rise.server.life;
import java.awt.Point;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import org.rise.client.MapleCharacter;
import org.rise.client.MapleClient;
import org.rise.database.DatabaseConnection;
import org.rise.net.channel.ChannelServer;
import org.rise.server.maps.MapleMapFactory;
import org.rise.tools.MockIOSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PlayerNPC {
private static Logger log = LoggerFactory.getLogger(MapleMapFactory.class);
private int id;
private int facingleft;
private Point pos;
private int mapid;
private int cid;
public PlayerNPC(MapleCharacter base, int mapid, Point pos) {
this.id = 0;
this.cid = base.getId();
this.facingleft = base.isFacingLeft() ? 0 : 1;
this.mapid = mapid;
this.pos = pos;
saveToDB();
}
public PlayerNPC(int id, int cid, int dir, int mapid, Point pos) {
this.id = id;
this.cid = cid;
this.facingleft = dir;
this.mapid = mapid;
this.pos = pos;
saveToDB();
}
public static PlayerNPC loadFromData(int id) {
PlayerNPC ret = null;
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE id = ?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret = new PlayerNPC(id, rs.getInt("characterid"), rs.getInt("dir"), rs.getInt("map"), new Point(rs.getInt("x"), rs.getInt("y")));
}
rs.close();
ps.close();
} catch (Exception e) {
log.error("Error loading PlayerNPC from data", e);
}
return ret;
}
public static List<PlayerNPC> loadFromMap(int map) {
List<PlayerNPC> npcs = new ArrayList<PlayerNPC>();
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE map = ?");
ps.setInt(1, map);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
npcs.add(loadFromData(rs.getInt("id")));
}
rs.close();
ps.close();
} catch (Exception se) {
log.error("Error loading PlayerNPCs from map", se);
}
return npcs;
}
public void saveToDB() {
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE id = ?");
ps.setInt(1, this.getId());
ResultSet rs = ps.executeQuery();
PreparedStatement psup;
if (rs.next()) {
psup = con.prepareStatement("UPDATE playernpcs SET characterid = ?, dir = ?, x = ?, y = ?, map = ? WHERE id = ?");
psup.setInt(1, this.getCharId());
psup.setInt(2, this.getDir());
psup.setInt(3, this.getPos().x);
psup.setInt(4, this.getPos().y);
psup.setInt(5, this.getMapId());
psup.setInt(6, this.getId());
psup.executeUpdate();
psup.close();
} else {
//generate a new id because cid sucks like that
psup = con.prepareStatement("INSERT INTO playernpcs(characterid, dir, x, y, map) VALUES (?, ?, ?, ?, ?)");
psup.setInt(1, this.getCharId());
psup.setInt(2, this.getDir());
psup.setInt(3, this.getPos().x);
psup.setInt(4, this.getPos().y);
psup.setInt(5, this.getMapId());
psup.executeUpdate();
ResultSet rsup = psup.getGeneratedKeys();
if (rsup.next()) {
setId(rsup.getInt(1));
}
psup.close();
}
rs.close();
ps.close();
} catch (Exception se) {
log.error("Error saving PlayerNPC", se);
}
}
public int getId() {
return id;
}
public int getCharId() {
return cid;
}
public int getMapId() {
return mapid;
}
public Point getPos() {
return pos;
}
public int getDir() {
return facingleft;
}
public void setId(int id) {
this.id = id;
}
public void setCharId(int cid) {
this.cid = cid;
}
public void setMapId(int name) {
this.mapid = name;
}
public void setPos(Point name) {
this.pos = name;
}
public MapleCharacter getBase() {
for (ChannelServer cserv : ChannelServer.getAllInstances()) {
if (cserv.getPlayerStorage().getCharacterById(cid) != null) {
return cserv.getPlayerStorage().getCharacterById(cid);
}
}
try {
return MapleCharacter.loadCharFromDB(cid, new MapleClient(null, null, new MockIOSession()), false);
} catch (Exception e) {
log.error("Error loading base from PlayerNPC", e);
}
return null;
}
}
How do i fix it to make it work properly?
I think this cause the problem the npc won't load up because it doesnt match the sql.
My apology if this is too troublesome for you =(
are you using zerofusion source?
Re: [Release]Real PlayerNPC SQL fix
Quote:
Originally Posted by
kokrong
MsDartz is the player npc fixed now ?
Do you understand the motherfucking meaning of GET THE BLOODY FUCK OUT? You stupid fucked up fucker
Go fuck yourself you stupid lil cunt
Quote:
Originally Posted by
FantiStory<3
noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
how could you leave me :*:
GTFO no one cares about you either
Re: [Release]Real PlayerNPC SQL fix
Quote:
Originally Posted by
iGoofy
Fuck you, no one cares about you.
Word of god here people, word of god.
Re: [Release]Real PlayerNPC SQL fix
Quote:
Originally Posted by
lmaoXitsXqtard
are you using zerofusion source?
Nope, but i found that file inside the source so i was wondering if that file can be fix to match the sql.
Because the problem is after you restart the server the playernpc won't load up.
Re: [Release]Real PlayerNPC SQL fix
Quote:
Originally Posted by
xQuasar
Do you understand the motherfucking meaning of GET THE BLOODY FUCK OUT? You stupid fucked up fucker
Go fuck yourself you stupid lil cunt
GTFO no one cares about you either
I praise you.