BuyCSItemHandler.java
MapleClient.javaCode:else if (action == 8) { //Buy Extra Character Slot Coupon? slea.skip(1); int useNX = slea.readInt(); int snCS = slea.readInt(); CashItemInfo item = CashItemFactory.getItem(snCS); if (c.getPlayer().getCSPoints(useNX) >= item.getPrice()) { if (c.getCSlots() < 6) { c.getPlayer().modifyCSPoints(useNX, -item.getPrice()); c.gainCSlot(); c.getPlayer().dropMessage(1, "Your character slots have been increased to " + c.getCSlots() + "."); } else { c.getPlayer().dropMessage(1, "You can not have more than 6 character slots."); } } else { c.getSession().write(MaplePacketCreator.enableActions()); return; } //MapleInventoryManipulator.addById(c, item.getId(), (short) item.getCount()); c.getSession().write(MaplePacketCreator.showBoughtCSItem(item.getId())); c.getSession().write(MaplePacketCreator.showNXMapleTokens(c.getPlayer())); c.getSession().write(MaplePacketCreator.enableCSUse0()); c.getSession().write(MaplePacketCreator.enableCSUse1(c)); c.getSession().write(MaplePacketCreator.enableCSUse2()); c.getSession().write(MaplePacketCreator.enableActions()); }
Code:private int charslots = 3;SQLCode:public int getCSlots() { try { Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("SELECT * FROM character_slots WHERE accid = ?"); ps.setInt(1, accId); ResultSet rs = ps.executeQuery(); if (rs.next()) { charslots = rs.getInt("charslots"); rs.close(); } else { ps = con.prepareStatement("INSERT INTO character_slots (accid, worldid, charslots) VALUES (?, ?, ?)"); ps.setInt(1, accId); ps.setInt(2, world); ps.setInt(3, charslots); ps.execute(); } ps.close(); } catch (SQLException sqlE) { System.out.print("Could not load Character Slots : " + sqlE); } return charslots; } public void gainCSlot() { charslots += 1; try { Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("UPDATE character_slots SET charslots = ? WHERE worldid = ? AND accid = ?"); ps.setInt(1, charslots); ps.setInt(2, world); ps.setInt(3, accId); ps.executeUpdate(); ps.close(); } catch (SQLException sqlE) { System.out.print("Could not save Character Slots : " + sqlE); } }
Code:-- -- Definition of table `character_slots` -- DROP TABLE IF EXISTS `character_slots`; CREATE TABLE `character_slots` ( `id` int(11) NOT NULL AUTO_INCREMENT, `accid` int(11) NOT NULL DEFAULT '0', `worldid` int(11) NOT NULL DEFAULT '0', `charslots` int(11) NOT NULL DEFAULT '3', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `character_slots` -- /*!40000 ALTER TABLE `character_slots` DISABLE KEYS */; /*!40000 ALTER TABLE `character_slots` ENABLE KEYS */;



Reply With Quote



