• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Pandora Box | Daily item winning.

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.

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:
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
I little confusing Loool
 
Experienced Elementalist
Joined
Apr 6, 2009
Messages
224
Reaction score
65
Wouldn't this only give you crappy items since mostly people don't want to throw their good stuff away? 0.o
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
Maybe a GM will put a GM hat in there occasionally :p
Just prevent them o.o
if (getItem == Gm Hat ID) {
return;
}

or

if (haveItem == Gm Hat ID) {
return;
}

Not sure which works or close to working (just an idea)

Added to Library
 
Zzzz...
Loyal Member
Joined
Dec 26, 2008
Messages
781
Reaction score
225
Just prevent them o.o
if (getItem == Gm Hat ID) {
return;
}

or

if (haveItem == Gm Hat ID) {
return;
}

Not sure which works or close to working (just an idea)

Added to Library

I meant GM's could hide prizes in there most normal players wouldn't so it'd be kind of like a lottery
 
Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,264
Wouldn't this only give you crappy items since mostly people don't want to throw their good stuff away? 0.o

In my server, The people adds good stuff because
that way they can get that items again, and everyday
a good item [and maybe ur item duplicated!]

---------- Post added at 07:31 PM ---------- Previous post was at 07:29 PM ----------

You don't recieve random item..
cm.addPandoraItem(1, for equip, 2 for use, 5 for cash)
so if u want the npc to take the first slot item
of equi categorey, do cm.addPandoraItem(1);
 
Junior Spellweaver
Joined
Nov 12, 2009
Messages
163
Reaction score
7
Wouldn't this only give you crappy items since mostly people don't want to throw their good stuff away? 0.o

well in the video, the item that he added to the pandora box was still in his inventory afterward.....
 
Newbie Spellweaver
Joined
Jan 28, 2010
Messages
32
Reaction score
1
I meant GM's could hide prizes in there most normal players wouldn't so it'd be kind of like a lottery

Thats actually a smart idea, Like a Item Godly and Low Precentage That they will get it and When A Player Gets It A Auto Congrats Pops up Saying (blahblahablahblah)
 
Zzzz...
Loyal Member
Joined
Dec 26, 2008
Messages
781
Reaction score
225
I did something like that on my old server with a casino-like NPC, gave you an event ticket thing that you can trade a GM for a prize
 
Newbie Spellweaver
Joined
Nov 7, 2008
Messages
88
Reaction score
1
If the selection 1 to gain an item would it be

Code:
 if (selection == 0) {
	  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();
 
return null;
Loyal Member
Joined
Dec 21, 2008
Messages
805
Reaction score
130
You should prevent people from adding tons of crap so all other people will get their crap
 
Newbie Spellweaver
Joined
Nov 7, 2008
Messages
88
Reaction score
1
Any one know how to fix my selection?

Code:
if (selection == 0) {
	  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();

THANK YOU :D
 
Back
Top