- Joined
- Apr 10, 2008
- Messages
- 4,087
- Reaction score
- 1,264
Pandora Box.
Hello Everyone.
CAUTION: IF YOU HAVE NO IDEA WHAT IS IT, GO TO PANDORA BOX ON FACEBBOOK. YOU GET AN ITEM EVERY DAY, THAT PEOPLE ADDED.
CM.ADDPANDORAITEM(1)//1 - equip 2- use 5 - cash
and it adds the first slot item tothe database
Video:
[ame="http://www.youtube.com/watch?v=bFM4vT87fJE"]YouTube- MapleStory - Pandora Box[/ame]
This is a system I made a while ago with RMZero213.
Every day you have 2 pandora uses. With that, you
can gain an item that people added to the Pandora Box.
You can add a item for the Pandora Box (Cash item,
Use item, ETC, or Equip), and other people will gain
it.
Guide how to add this.
Excute all theese mysql scripts.
Add theese in MapleCharacter.java.
Add theese in your NPCCoversationManager.java:
Now, how to use each command, for the NPC.
If you want the NPC to have a log for each item,
do this:
Hello Everyone.
CAUTION: IF YOU HAVE NO IDEA WHAT IS IT, GO TO PANDORA BOX ON FACEBBOOK. YOU GET AN ITEM EVERY DAY, THAT PEOPLE ADDED.
CM.ADDPANDORAITEM(1)//1 - equip 2- use 5 - cash
and it adds the first slot item tothe database
Video:
[ame="http://www.youtube.com/watch?v=bFM4vT87fJE"]YouTube- MapleStory - Pandora Box[/ame]
This is a system I made a while ago with RMZero213.
Every day you have 2 pandora uses. With that, you
can gain an item that people added to the Pandora Box.
You can add a item for the Pandora Box (Cash item,
Use item, ETC, or Equip), and other people will gain
it.
Guide how to add this.
Excute all theese mysql scripts.
Code:
CREATE TABLE `pandoralog` (
`pandoralogid` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`characterid` INTEGER UNSIGNED NOT NULL,
`itemid` VARCHAR(20) NOT NULL,
`lastattempt` TIMESTAMP NOT NULL,
PRIMARY KEY (`pandoralogid`)
)
CREATE TABLE `pandoraitem` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`itemid` INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (`id`)
)
Add theese in MapleCharacter.java.
Code:
public int getPandoraLog(String itemid) {
Connection con1 = DatabaseConnection.getConnection();
try {
int ret_count = 0;
PreparedStatement ps;
ps = con1.prepareStatement("select count(*) from pandoralog where characterid = ? and itemid = ? and lastattempt >= subtime(current_timestamp, '1 0:0:0.0')");
ps.setInt(1, id);
ps.setString(2, itemid);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret_count = rs.getInt(1);
} else {
ret_count = -1;
}
rs.close();
ps.close();
return ret_count;
} catch (Exception Ex) {
System.out.print("Error reading Pandora Log.");
return -1;
}
}
Code:
public void setPandoraLog(String itemid) {
Connection con1 = DatabaseConnection.getConnection();
try {
PreparedStatement ps;
ps = con1.prepareStatement("insert into pandoralog (characterid, itemid) values (?,?)");
ps.setInt(1, id);
ps.setString(2, itemid);
ps.executeUpdate();
ps.close();
} catch (Exception Ex) {
System.out.print("Error setting the Pandora Log.");
}
}
Add theese in your NPCCoversationManager.java:
Code:
public int getMaxItems() {
int ret = 0;
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT MAX(id) FROM pandoraitems");
ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret = rs.getInt(1);
}
rs.close();
ps.close();
} catch (SQLException e) {
}
return ret;
}
Code:
public int getPandoraItem(int id) {
int ret = 0;
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT itemid FROM pandoraitems WHERE id = ?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret = rs.getInt("itemid");
}
rs.close();
ps.close();
} catch (SQLException e) {
}
return ret;
}
Code:
public void addPandoraItem(int inv) {
MapleInventoryType type = MapleInventoryType.getByType((byte) inv);
IItem pan = c.getPlayer().getInventory(type).getItem((byte) 0);
if (type == null || pan == null) {
return;
}
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO pandoraitems(itemid) VALUES (?)");
ps.setInt(1, pan.getItemId());
ps.executeUpdate();
ps.close();
} catch (SQLException e) {
System.out.print("Error excuting MySQL.");
return;
}
MapleInventoryManipulator.removeFromSlot(c, type, (byte) 0, pan.getQuantity(), false);
}
Code:
public int getPandoraLog(String itemid)
{
return getPlayer().getPandoraLog(itemid);
}
public void setBossLog(String itemid)
{
getPlayer().setPandoraLog(itemid);
}
Now, how to use each command, for the NPC.
If you want the NPC to have a log for each item,
do this:
Code:
if (cm.getBossLog('PANDORA') < 1) {
cm.gainItem(cm.getPandoraItem(Math.floor(Math.random() * cm.getMaxItems()) + 1)); // Gains a random item.
cm.setPandoraLog('PANDORA');
cm.dispose();
} else {
cm.sendNext("You've used all your uses. Please come back tommrow!);
cm.dispose();
Last edited: