-
[Release]: MTS by traitor fixed by redred from valhalladev
Credits go to traitor, redred
If this happens to get on ragezone, don't flame the topic creator, or really post any negative things in it. Thanks by Traitor
Let's clear up something
This MTS is orginally made by traitor not bassoe and was posted on valhalladev forum and fixed by redred and sadiq.
Quote:
Sale items: Completed
Cart : Completed
One item in transfer, being able to transfer items right after buying them, etc : Completed
Fixes error 38: Completed ( Look at Justsomeone fix)
Fixes MTSHandler.java: Completed
Replace your EnterMTSHandler.java with this:
traitor private pastebin - collaborative debugging tool
Create a MTSHandler.java in net.sf.odinms.net.channel.handler package:
traitor private pastebin - collaborative debugging tool
Modify your warpCS function to look like so:
traitor private pastebin - collaborative debugging tool
In maplepacketcreator.java, add this import:
Code:
import net.sf.odinms.server.MTSItemInfo;
Add these two functions above warpCS:
Code:
public static MaplePacket warpCS(MapleClient c) {
return warpCS(c, false);
}
public static MaplePacket warpMTS(MapleClient c) {
return warpCS(c, true);
}
Add these functions somewhere in maplepacketcreator.java
traitor private pastebin - collaborative debugging tool
Create a MTSItemInfo.java in net.sf.odinms.server:
Code:
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.odinms.server;
import net.sf.odinms.client.IItem;
import java.util.*;
/**
*
* @author Traitor
*/
public class MTSItemInfo {
private int price;
private IItem item;
private String seller;
private int id;
private int cid;
private int year, month, day = 1;
public MTSItemInfo(IItem item, int price, int id, int cid, String seller, String date) {
this.item = item;
this.price = price;
this.seller = seller;
this.id = id;
this.cid = cid;
this.year = Integer.parseInt(date.substring(0, 4));
this.month = Integer.parseInt(date.substring(5, 7));
this.day = Integer.parseInt(date.substring(8, 10));
}
public IItem getItem() {
return item;
}
public int getPrice() {
return price;
}
public int getRealPrice() {
return price + getTaxes();
}
public int getTaxes() {
return 110 + (int)(price * 0.1);
}
public int getID() {
return id;
}
public int getCID() {
return cid;
}
public long getEndingDate() {
Calendar now = Calendar.getInstance();
now.set(year, month - 1, day);
return now.getTimeInMillis();
}
public String getSeller() {
return seller;
}
}
Execute this sql on your db:
Code:
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for mts_cart
-- ----------------------------
DROP TABLE IF EXISTS `mts_cart`;
CREATE TABLE `mts_cart` (
`id` int(11) NOT NULL auto_increment,
`cid` int(11) NOT NULL,
`itemid` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Table structure for mts_items
-- ----------------------------
DROP TABLE IF EXISTS `mts_items`;
CREATE TABLE `mts_items` (
`id` int(10) unsigned NOT NULL auto_increment,
`tab` int(11) NOT NULL default '0',
`type` int(11) NOT NULL default '0',
`itemid` int(10) unsigned NOT NULL default '0',
`quantity` int(11) NOT NULL default '1',
`seller` int(11) NOT NULL default '0',
`price` int(11) NOT NULL default '0',
`bid_incre` int(11) default '0',
`buy_now` int(11) default '0',
`position` int(11) default '0',
`upgradeslots` int(11) default '0',
`level` int(11) default '0',
`str` int(11) default '0',
`dex` int(11) default '0',
`int` int(11) default '0',
`luk` int(11) default '0',
`hp` int(11) default '0',
`mp` int(11) default '0',
`watk` int(11) default '0',
`matk` int(11) default '0',
`wdef` int(11) default '0',
`mdef` int(11) default '0',
`acc` int(11) default '0',
`avoid` int(11) default '0',
`hands` int(11) default '0',
`speed` int(11) default '0',
`jump` int(11) default '0',
`locked` int(11) default '0',
`isequip` int(1) default '0',
`owner` varchar(16) default '',
`sellername` varchar(16) NOT NULL,
`sell_ends` varchar(16) NOT NULL,
`transfer` int(2) default '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records
-- ----------------------------
In SendPacketOpcode.java:
Add:
Code:
MTS_OPEN,
MTS_OPERATION,
MTS_OPERATION2,
after:
Code:
CS_OPEN,
CS_UPDATE,
CS_OPERATION,
In RecvPacketOpcode.java:
add:
after
Add this in your recvops.properties:
Code:
# MTS
MTS_OP = 0xD9
Add this in your sendops.properties:
Code:
MTS_OPERATION = 0x0114
MTS_OPERATION2 = 0x0113
MTS_OPEN = 0x5D
In packetprocessor.java, add this:
Code:
registerHandler(RecvPacketOpcode.MTS_OP, new MTSHandler());
after
Code:
registerHandler(RecvPacketOpcode.COUPON_CODE, new CouponCodeHandler());
edit:
thanks to redred for these
goto ChannelServer.java
find
Code:
private boolean cashshop;
add below
Code:
private boolean mts;
find
Code:
cashshop = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.cashshop", "false"));
add below
Code:
mts = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.mts", "false"));
Agin:
find
Code:
cashshop = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.cashshop", "false"));
add below
Code:
mts = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.mts", "false"));
find
Code:
public boolean allowCashshop() {
return cashshop;
}
add below
Code:
public boolean allowMTS() {
return mts;
}
open MapleCharacter:
find
Code:
private boolean incs;
add below
Code:
private boolean inmts;
find
add below
find
Code:
public boolean inCS() {
return this.incs;
}
add below
Code:
public void setInMTS(boolean yesno) {
this.inmts = yesno;
}
public boolean inMTS() {
return this.inmts;
}
add in world.prop
Code:
net.sf.odinms.world.mts=true
Some more fixes:
This will fix being able to have more than one item in transfer, being able to transfer items right after buying them, etc.
Replace your TransferInventory function with this:
Code:
public static MaplePacket TransferInventory(List<MTSItemInfo> items) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendPacketOpcode.MTS_OPERATION.getValue());
mplew.write(0x21);
mplew.writeInt(items.size());
int i = 0;
if(items.size() != 0) {
for(MTSItemInfo item : items)
{
addItemInfo(mplew, item.getItem(), true, true);
mplew.writeInt(item.getID()); //id
mplew.writeInt(item.getTaxes()); //taxes
mplew.writeInt(item.getPrice()); //price
mplew.writeLong(0);
mplew.writeInt(KoreanDateUtil.getQuestTimestamp(item.getEndingDate()));
mplew.writeMapleAsciiString(item.getSeller()); //account name (what was nexon thinking?)
mplew.writeMapleAsciiString(item.getSeller()); //char name
for(int ii = 0; ii < 28; ii++)
mplew.write(0);
i++;
}
}
mplew.write(0xD0 + i);
mplew.write(HexTool.getByteArrayFromHexString("FF FF FF 00"));
return mplew.getPacket();
}
Also, for more fixes replace your MTSHandler.java with this:
traitor private pastebin - collaborative debugging tool
And your MTSItemInfo.java with this:
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.sf.odinms.server;
import net.sf.odinms.client.IItem;
import java.util.*;
/**
*
* @author Traitor
*/
public class MTSItemInfo {
private int price;
private IItem item;
private String seller;
private int id;
private int cid;
private int year, month, day = 1;
public MTSItemInfo(IItem item, int price, int id, int cid, String seller, String date) {
this.item = item;
this.price = price;
this.seller = seller;
this.id = id;
this.cid = cid;
this.year = Integer.parseInt(date.substring(0, 4));
this.month = Integer.parseInt(date.substring(5, 7));
this.day = Integer.parseInt(date.substring(8, 10));
}
public IItem getItem() {
return item;
}
public int getPrice() {
return price;
}
public int getRealPrice() {
return price + getTaxes();
}
public int getTaxes() {
return 100 + (int)(price * 0.1);
}
public int getID() {
return id;
}
public int getCID() {
return cid;
}
public long getEndingDate() {
Calendar now = Calendar.getInstance();
now.set(year, month - 1, day);
return now.getTimeInMillis();
}
public String getSeller() {
return seller;
}
}
And add these in MapleCharacter:
Code:
//mts stuff
private int currentPage, currentType = 0;
private int currentTab = 1;
Same with these:
Code:
public void changePage(int page) {
this.currentPage = page;
}
public void changeTab(int tab) {
this.currentTab = tab;
}
public void changeType(int type) {
this.currentType = type;
}
public int getCurrentPage() {
return currentPage;
}
public int getCurrentTab() {
return currentTab;
}
public int getCurrentType() {
return currentType;
}
And finally, replace your EnterMTSHandler.java with this:
traitor private pastebin - collaborative debugging tool
edit: another fix
In MTSHandler.java, replace your if(op == 9){ block with this
Code:
} else if (op == 9) { //add to cart
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
try
{
PreparedStatement ps = con.prepareStatement("SELECT id FROM mts_cart WHERE cid = ? AND itemid = ?");
ps.setInt(1, id);
ps.setInt(2, c.getPlayer().getId());
ResultSet rs = ps.executeQuery();
if(!rs.next())
{
PreparedStatement pse = con.prepareStatement("INSERT INTO mts_cart (cid, itemid) VALUES (?, ?)");
pse.setInt(1, c.getPlayer().getId());
pse.setInt(2, id);
pse.executeUpdate();
pse.close();
}
rs.close();
ps.close();
} catch(SQLException e) {
log.error("SqlErr12: ", e);
}
c.getSession().write(getMTS(c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage()));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.enableActions());
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
}
And I think that is it. Any bugs you find, report them.
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
the bug with not being able to carry more than 1 item in the TRANSFER panel. other than that its perfect. if the mods keep deleting these post ill have mental come look and deal with the issue going on in this forum, this shit is starting to get way out hand.
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
the bug error is it fixed?
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
i dunno where its coming from, either packet creator or the MTS handler. its the transfer panel. u cant have more than 1 item in it.
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
nope from underground valhalldev
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
can u help me fix it ?lol
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
yea its the srouce to the error 38 and the bug where u enter MTS and maple closes.
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
maybe traitors mts got some problem?? y dont try use the normal mts the one "The 100% MTS de" and try mix traitor's with bassoe's??
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
u need both patches for this system to work, u cant mix them. lol unless theres a post i dont know about. this post simply adds the buy sell feature. the other one is a simple open and close.
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
Quote:
u need both patches for this system to work, u cant mix them. lol unless theres a post i dont know about. this post simply adds the buy sell feature. the other one is a simple open and close.
i hop bassoe will release his...
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
for that last thing, mts is supposed to use cash card nx, not paypal nx.
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
my MTS uses maple points.
anyways the error 38 is in this packet
public static MaplePacket TransferInventory(List<MTSItemInfo> items) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendPacketOpcode.MTS_OPERATION.getValue());
mplew.write(0x21);
mplew.writeInt(items.size());
int i = 1;
if(items.size() != 0) {
for(MTSItemInfo item : items)
{
addItemInfo(mplew, item.getItem(), true, true);
mplew.writeInt(item.getID()); //id
mplew.writeInt(item.getTaxes()); //this + below = price
mplew.writeInt(item.getPrice()); //price
mplew.writeLong(0);
mplew.writeInt(KoreanDateUtil.getQuestTimestamp(item.getEndingDate()));
mplew.writeMapleAsciiString(item.getSeller()); //account name (what was nexon thinking?)
mplew.writeMapleAsciiString(item.getSeller()); //char name
for(int ii = 0; ii < 28; ii++)
mplew.write(0);
mplew.write(0xD0 + (byte)i);
mplew.write(HexTool.getByteArrayFromHexString("FF FF FF 00"));
i++;
}
} else {
mplew.write(HexTool.getByteArrayFromHexString("D0 FF FF FF 00"));
}
return mplew.getPacket();
}
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
Because I'm feeling nice, here's the fix:
Replace your TransferInventory function with this:
Code:
public static MaplePacket TransferInventory(List<MTSItemInfo> items) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendPacketOpcode.MTS_OPERATION.getValue());
mplew.write(0x21);
mplew.writeInt(items.size());
if(items.size() != 0) {
for(MTSItemInfo item : items)
{
addItemInfo(mplew, item.getItem(), true, true);
mplew.writeInt(item.getID()); //id
mplew.writeInt(item.getTaxes()); //taxes
mplew.writeInt(item.getPrice()); //price
mplew.writeLong(0);
mplew.writeInt(KoreanDateUtil.getQuestTimestamp(item.getEndingDate()));
mplew.writeMapleAsciiString(item.getSeller()); //account name (what was nexon thinking?)
mplew.writeMapleAsciiString(item.getSeller()); //char name
for(int ii = 0; ii < 28; ii++)
mplew.write(0);
}
}
mplew.write(0xD0 + items.size());
mplew.write(HexTool.getByteArrayFromHexString("FF FF FF 00"));
return mplew.getPacket();
}
Also, for more fixes replace your MTSHandler.java with this:
Code:
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.odinms.net.channel.handler;
import net.sf.odinms.client.*;
import net.sf.odinms.database.DatabaseConnection;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.net.MaplePacket;
import net.sf.odinms.net.channel.ChannelServer;
import net.sf.odinms.server.MapleInventoryManipulator;
import net.sf.odinms.server.MapleItemInformationProvider;
import net.sf.odinms.server.MTSItemInfo;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MTSHandler extends AbstractMaplePacketHandler {
private static Logger log = LoggerFactory.getLogger(DistributeSPHandler.class);
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if (slea.available() > 0) {
byte op = slea.readByte();
if (op == 2) { //put item up for sale
//D9 00
//02
//02
//D8 E5 3C 00
//00 00
//80 05 BB 46 E6 17 02
//01 00
//07 00
//54 72 61 69 74 6F 72
//00 00
//01 00 00 00
//01 00 00 00
//57 04 00 00
//07 01
byte itemtype = slea.readByte();
int itemid = slea.readInt();
slea.readShort();
slea.skip(7);
if (itemtype == 1) {
slea.skip(32); //item stats, but we don't need them (can be exploited!)
} else {
slea.readShort();
}
slea.readMapleAsciiString(); //another useless thing (owner)
if(itemtype == 1)
slea.readInt();
else
slea.readShort();
byte slot = 1;
short quantity = 1;
if(itemtype != 1)
slot = (byte)slea.readInt();
else
quantity = (short)slea.readInt();
if(itemtype == 1)
slea.readShort();
if(itemtype != 1)
quantity = (short)slea.readInt();
else
slot = (byte)slea.readInt();
if(itemtype == 1)
slea.readInt();
int price = slea.readInt();
if(itemtype == 1)
quantity = 1;
MapleInventoryType type = MapleItemInformationProvider.getInstance().getInventoryType(itemid);
IItem i = c.getPlayer().getInventory(type).getItem(slot).copy();
if(i != null && c.getPlayer().getMeso() >= 5000) {
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps;
Calendar calendar = Calendar.getInstance();
int year = 2008; //sad sad date for all of us ;-(
int month = 6; //sad sad date for all of us ;-(
int day = 17; //sad sad date for all of us ;-(
int oldmax = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int oldday = calendar.get(Calendar.DAY_OF_MONTH) + 7;
if(oldmax < oldday)
{
if(calendar.get(Calendar.MONTH) + 2 > 12) {
year = calendar.get(Calendar.YEAR) + 1;
month = 1;
calendar.set(year, month, 1);
day = oldday - oldmax;
} else {
month = calendar.get(Calendar.MONTH) + 2;
year = calendar.get(Calendar.YEAR);
calendar.set(year, month, 1);
day = oldday - oldmax;
}
} else {
day = calendar.get(Calendar.DAY_OF_MONTH) + 7;
month = calendar.get(Calendar.MONTH);
year = calendar.get(Calendar.YEAR);
}
String date = year + "-";
if(month < 10)
date += "0" + month + "-";
else
date += month + "-";
if(day < 10)
date += "0" + day;
else
date += day + "";
if(i.getType() == 2)
{
Item item = (Item)i;
ps = con.prepareStatement("INSERT INTO mts_items (tab, type, itemid, quantity, seller, price, owner, sellername, sell_ends) VALUES " +
"(?, ?, ?, ?, ?, ?, ?, ?, ?)");
ps.setInt(1, 1);
ps.setInt(2, (int)type.getType());
ps.setInt(3, item.getItemId());
ps.setInt(4, quantity);
ps.setInt(5, c.getPlayer().getId());
ps.setInt(6, price);
ps.setString(7, item.getOwner());
ps.setString(8, c.getPlayer().getName());
ps.setString(9, date);
} else {
Equip equip = (Equip)i;
ps = con.prepareStatement("INSERT INTO mts_items (tab, type, itemid, quantity, seller, price, upgradeslots, level, str, dex, `int`, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump, locked, owner, sellername, sell_ends) VALUES " +
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
ps.setInt(1, 1);
ps.setInt(2, (int)type.getType());
ps.setInt(3, equip.getItemId());
ps.setInt(4, quantity);
ps.setInt(5, c.getPlayer().getId());
ps.setInt(6, price);
ps.setInt(7, equip.getUpgradeSlots());
ps.setInt(8, equip.getLevel());
ps.setInt(9, equip.getStr());
ps.setInt(10, equip.getDex());
ps.setInt(11, equip.getInt());
ps.setInt(12, equip.getLuk());
ps.setInt(13, equip.getHp());
ps.setInt(14, equip.getMp());
ps.setInt(15, equip.getWatk());
ps.setInt(16, equip.getMatk());
ps.setInt(17, equip.getWdef());
ps.setInt(18, equip.getMdef());
ps.setInt(19, equip.getAcc());
ps.setInt(20, equip.getAvoid());
ps.setInt(21, equip.getHands());
ps.setInt(22, equip.getSpeed());
ps.setInt(23, equip.getJump());
ps.setInt(24, equip.getLocked());
ps.setString(25, equip.getOwner());
ps.setString(26, c.getPlayer().getName());
ps.setString(27, date);
}
ps.executeUpdate();
ps.close();
MapleInventoryManipulator.removeFromSlot(c, type, slot, quantity, false);
}
catch(SQLException e) {
log.error("SQLErr4: " + e);
}
c.getPlayer().gainMeso(-5000, false);
c.getSession().write(MaplePacketCreator.MTSConfirmSell());
c.getSession().write(getMTS(1, 0, 0));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
}
} else if (op == 3) { //send offer for wanted item
} else if (op == 4) { //list wanted item
int itemid = slea.readInt();
int price = slea.readInt();
int quantity = slea.readInt();
slea.readShort();
String message = slea.readMapleAsciiString();
} else if (op == 5) { //change page/tab
//tabs
//1 = for sale
//2 = wanted
//3 = auction
//4 = my page
//5 = guide
//types (wanted & auction)
//0 = all
//1 = equip
//2 = use
//3 = setup
//4 = etc
//types (my page)
//0 = cart
//1 = offers
//2 = history
//3 = auction
int tab = slea.readInt();
int type = slea.readInt();
int page = slea.readInt();
c.getPlayer().changeTab(tab);
c.getPlayer().changeType(type);
c.getPlayer().changePage(page);
if(tab == 4 && type == 0)
c.getSession().write(getCart(c.getPlayer().getId()));
else
c.getSession().write(getMTS(tab, type, page));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
} else if (op == 6) { //search
//D9 00
//06
//01 00 00 00
//00 00 00 00
//00 00 00 00
//00 00 00 00
//09 00 -search len
//6C 6F 6C 73 65 61 72 63 68 -search
slea.readInt();
slea.readInt();
slea.readInt();
slea.readInt();
String search = slea.readMapleAsciiString();
} else if (op == 7) { //cancel sale
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("UPDATE mts_items SET transfer = 1 WHERE id = ? AND seller = ?");
ps.setInt(1, id);
ps.setInt(2, c.getPlayer().getId());
ps.executeUpdate();
ps.close();
}
catch(SQLException e) {
log.error("SQLErr4: " + e);
}
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(getMTS(c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage()));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
} else if (op == 8) { //transfer item from transfer inv.
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE seller = ? AND transfer = 1 ORDER BY id DESC");
ps.setInt(1, c.getPlayer().getId());
rs = ps.executeQuery();
if (rs.next()) {
IItem i;
if(rs.getInt("type") != 1)
{
Item ii = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
ii.setOwner(rs.getString("owner"));
ii.setPosition(c.getPlayer().getInventory(MapleItemInformationProvider.getInstance().getInventoryType(rs.getInt("itemid"))).getNextFreeSlot());
i = ii.copy();
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
equip.setPosition(c.getPlayer().getInventory(MapleItemInformationProvider.getInstance().getInventoryType(rs.getInt("itemid"))).getNextFreeSlot());
i = equip.copy();
}
PreparedStatement pse = con.prepareStatement("DELETE FROM mts_items WHERE id = ? AND seller = ? AND transfer = 1");
pse.setInt(1, id);
pse.setInt(2, c.getPlayer().getId());
pse.executeUpdate();
pse.close();
MapleInventoryManipulator.addFromDrop(c, i, "MTS transfer", false);
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(getMTS(c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage()));
c.getSession().write(MaplePacketCreator.MTSConfirmTransfer(i.getQuantity(), i.getPosition()));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err8: " + e);
}
} else if (op == 9) { //add to cart
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
try
{
PreparedStatement ps = con.prepareStatement("SELECT id FROM mts_cart WHERE cid = ? AND itemid = ?");
ps.setInt(1, id);
ps.setInt(2, c.getPlayer().getId());
ResultSet rs = ps.executeQuery();
if(!rs.next())
{
PreparedStatement pse = con.prepareStatement("INSERT INTO mts_cart (cid, itemid) VALUES (?, ?)");
pse.setInt(1, c.getPlayer().getId());
pse.setInt(2, id);
pse.executeUpdate();
}
ps.executeUpdate();
} catch(SQLException e) {
log.error("SqlErr12: ", e);
}
c.getSession().write(getMTS(c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage()));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.enableActions());
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
} else if (op == 10) { //delete from cart
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
try
{
PreparedStatement ps = con.prepareStatement("DELETE FROM mts_cart WHERE itemid = ? AND cid = ?");
ps.setInt(1, id);
ps.setInt(2, c.getPlayer().getId());
ps.executeUpdate();
} catch(SQLException e) {
log.error("SqlErr12: ", e);
}
c.getSession().write(getCart(c.getPlayer().getId()));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
} else if (op == 12) { //put item up for auction
int itemid = slea.readInt();
} else if (op == 12) { //cancel wanted cart thing
} else if (op == 14) { //buy auction item now
} else if (op == 16) { //buy
//transaction fees: 100NX + 10% of item price
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE id = ? ORDER BY id DESC");
ps.setInt(1, id);
rs = ps.executeQuery();
if (rs.next()) {
int price = rs.getInt("price") + 100 + (int)(rs.getInt("price") * 0.1); //taxes
if(c.getPlayer().getCSPoints(4) >= price) {
boolean alwaysnull = true;
for(ChannelServer cserv : ChannelServer.getAllInstances()) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterById(rs.getInt("seller"));
if(victim != null) {
victim.modifyCSPoints(4, rs.getInt("price"));
alwaysnull = false;
}
}
if(alwaysnull) {
PreparedStatement pse = con.prepareStatement("SELECT accountid FROM characters WHERE id = ?");
pse.setInt(1, rs.getInt("seller"));
ResultSet rse = pse.executeQuery();
if(rse.next()) {
PreparedStatement psee = con.prepareStatement("UPDATE accounts SET cardNX = cardNX + ? WHERE id = ?");
psee.setInt(1, rs.getInt("price"));
psee.setInt(2, rse.getInt("accountid"));
psee.executeUpdate();
psee.close();
}
pse.close();
rse.close();
}
PreparedStatement pse = con.prepareStatement("UPDATE mts_items SET seller = ?, transfer = 1 WHERE id = ?");
pse.setInt(1, c.getPlayer().getId());
pse.setInt(2, id);
pse.executeUpdate();
pse.close();
c.getPlayer().modifyCSPoints(4, -price);
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(getMTS(c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage()));
c.getSession().write(MaplePacketCreator.MTSConfirmBuy());
c.getSession().write(MaplePacketCreator.showMTSCash(c.getPlayer()));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.enableActions());
} else {
c.getSession().write(MaplePacketCreator.MTSFailBuy());
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
c.getSession().write(MaplePacketCreator.MTSFailBuy());
log.error("Err8: " + e);
}
} else if (op == 17) { //buy from cart
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE id = ? ORDER BY id DESC");
ps.setInt(1, id);
rs = ps.executeQuery();
if (rs.next()) {
int price = rs.getInt("price") + 100 + (int)(rs.getInt("price") * 0.1);
if(c.getPlayer().getCSPoints(4) >= price) {
for(ChannelServer cserv : ChannelServer.getAllInstances()) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterById(rs.getInt("seller"));
if(victim != null) {
victim.modifyCSPoints(4, rs.getInt("price"));
} else {
PreparedStatement pse = con.prepareStatement("SELECT accountid FROM characters WHERE id = ?");
pse.setInt(1, rs.getInt("seller"));
ResultSet rse = pse.executeQuery();
if(rse.next()) {
PreparedStatement psee = con.prepareStatement("UPDATE accounts SET cardNX = cardNX + ? WHERE id = ?");
psee.setInt(1, rs.getInt("price"));
psee.setInt(2, rse.getInt("accountid"));
psee.executeUpdate();
psee.close();
}
pse.close();
rse.close();
}
}
PreparedStatement pse = con.prepareStatement("UPDATE mts_items SET seller = ?, transfer = 1 WHERE id = ?");
pse.setInt(1, c.getPlayer().getId());
pse.setInt(2, id);
pse.executeUpdate();
pse.close();
pse = con.prepareStatement("DELETE FROM mts_cart WHERE itemid = ? AND cid = ?");
pse.setInt(1, id);
pse.setInt(2, c.getPlayer().getId());
pse.executeUpdate();
pse.close();
c.getPlayer().modifyCSPoints(4, -price);
c.getSession().write(getCart(c.getPlayer().getId()));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.MTSConfirmBuy());
c.getSession().write(MaplePacketCreator.showMTSCash(c.getPlayer()));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
} else {
c.getSession().write(MaplePacketCreator.MTSFailBuy());
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
c.getSession().write(MaplePacketCreator.MTSFailBuy());
log.error("Err8: " + e);
}
} else {
log.info("Unhandled OP(MTS): " + op + " Packet: " + slea.toString());
}
} else {
c.getSession().write(MaplePacketCreator.showMTSCash(c.getPlayer()));
}
}
public List<MTSItemInfo> getNotYetSold(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE seller = ? AND transfer = 0 ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err8: " + e);
}
return items;
}
public MaplePacket getCart(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
int pages = 0;
try
{
ps = con.prepareStatement("SELECT * FROM mts_cart WHERE cid = ? ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
PreparedStatement pse = con.prepareStatement("SELECT * FROM mts_items WHERE id = ?");
pse.setInt(1, rs.getInt("itemid"));
ResultSet rse = pse.executeQuery();
if (rse.next()) {
if(rse.getInt("type") != 1)
{
Item i = new Item(rse.getInt("itemid"), (byte)0, (short)rse.getInt("quantity"));
i.setOwner(rse.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rse.getInt("price"), rse.getInt("id"), rse.getInt("seller"), rse.getString("sellername"), rse.getString("sell_ends")));
} else {
Equip equip = new Equip(rse.getInt("itemid"), (byte) rse.getInt("position"), -1);
equip.setOwner(rse.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rse.getInt("acc"));
equip.setAvoid((short) rse.getInt("avoid"));
equip.setDex((short) rse.getInt("dex"));
equip.setHands((short) rse.getInt("hands"));
equip.setHp((short) rse.getInt("hp"));
equip.setInt((short) rse.getInt("int"));
equip.setJump((short) rse.getInt("jump"));
equip.setLuk((short) rse.getInt("luk"));
equip.setMatk((short) rse.getInt("matk"));
equip.setMdef((short) rse.getInt("mdef"));
equip.setMp((short) rse.getInt("mp"));
equip.setSpeed((short) rse.getInt("speed"));
equip.setStr((short) rse.getInt("str"));
equip.setWatk((short) rse.getInt("watk"));
equip.setWdef((short) rse.getInt("wdef"));
equip.setUpgradeSlots((byte) rse.getInt("upgradeslots"));
equip.setLocked((byte) rse.getInt("locked"));
equip.setLevel((byte) rse.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rse.getInt("price"), rse.getInt("id"), rse.getInt("seller"), rse.getString("sellername"), rse.getString("sell_ends")));
}
}
}
rs.close();
ps.close();
ps = con.prepareStatement("SELECT COUNT(*) FROM mts_cart WHERE cid = ?");
ps.setInt(1, cid);
rs = ps.executeQuery();
if (rs.next()) {
pages = (int) Math.ceil(rs.getInt(1) / 16);
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err8: " + e);
}
return MaplePacketCreator.sendMTS(items, 4, 0, 0, pages);
}
public List<MTSItemInfo> getTransfer(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE transfer = 1 AND seller = ? ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err7: " + e);
}
return items;
}
public MaplePacket getMTS(int tab, int type, int page)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
int pages = 0;
try
{
if(type != 0)
ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = ? AND type = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
else
ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
ps.setInt(1, tab);
if(type != 0)
{
ps.setInt(2, type);
ps.setInt(3, page * 16);
} else {
ps.setInt(2, page * 16);
}
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
if(type != 0)
ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items WHERE tab = ? AND type = ? AND transfer = 0");
else
ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items WHERE tab = ? AND transfer = 0");
ps.setInt(1, tab);
if(type != 0)
ps.setInt(2, type);
rs = ps.executeQuery();
if (rs.next()) {
pages = (int) Math.ceil(rs.getInt(1) / 16);
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err6: " + e);
}
return MaplePacketCreator.sendMTS(items, tab, type, page, pages);
}
}
And your MTSItemInfo.java with this:
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.sf.odinms.server;
import net.sf.odinms.client.IItem;
import java.util.*;
/**
*
* @author Traitor
*/
public class MTSItemInfo {
private int price;
private IItem item;
private String seller;
private int id;
private int cid;
private int year, month, day = 1;
public MTSItemInfo(IItem item, int price, int id, int cid, String seller, String date) {
this.item = item;
this.price = price;
this.seller = seller;
this.id = id;
this.cid = cid;
this.year = Integer.parseInt(date.substring(0, 4));
this.month = Integer.parseInt(date.substring(5, 7));
this.day = Integer.parseInt(date.substring(8, 10));
}
public IItem getItem() {
return item;
}
public int getPrice() {
return price;
}
public int getRealPrice() {
return price + getTaxes();
}
public int getTaxes() {
return 100 + (int)(price * 0.1);
}
public int getID() {
return id;
}
public int getCID() {
return cid;
}
public long getEndingDate() {
Calendar now = Calendar.getInstance();
now.set(year, month - 1, day);
return now.getTimeInMillis();
}
public String getSeller() {
return seller;
}
}
And add these in MapleCharacter:
Code:
//mts stuff
private int currentPage, currentType = 0;
private int currentTab = 1;
Same with these:
Code:
public void changePage(int page) {
this.currentPage = page;
}
public void changeTab(int tab) {
this.currentTab = tab;
}
public void changeType(int type) {
this.currentType = type;
}
public int getCurrentPage() {
return currentPage;
}
public int getCurrentTab() {
return currentTab;
}
public int getCurrentType() {
return currentType;
}
And finally, replace your EnterMTSHandler.java with this:
Code:
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.odinms.net.channel.handler;
import java.rmi.RemoteException;
import net.sf.odinms.client.*;
import net.sf.odinms.client.messages.ServernoticeMapleClientMessageCallback;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.net.channel.ChannelServer;
import net.sf.odinms.net.world.remote.WorldChannelInterface;
import net.sf.odinms.server.MTSItemInfo;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
import net.sf.odinms.database.DatabaseConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EnterMTSHandler extends AbstractMaplePacketHandler {
private static Logger log = LoggerFactory.getLogger(DistributeSPHandler.class);
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if (c.getChannelServer().allowMTS()) {
if (c.getPlayer().getNoPets() > 0) {
c.getPlayer().unequipAllPets();
}
try {
WorldChannelInterface wci = ChannelServer.getInstance(c.getChannel()).getWorldInterface();
wci.addBuffsToStorage(c.getPlayer().getId(), c.getPlayer().getAllBuffs());
wci.addCooldownsToStorage(c.getPlayer().getId(), c.getPlayer().getAllCooldowns());
} catch (RemoteException e) {
c.getChannelServer().reconnectWorld();
}
c.getPlayer().getMap().removePlayer(c.getPlayer());
c.getSession().write(MaplePacketCreator.warpMTS(c));
c.getPlayer().setInMTS(true);
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.MTSWantedListingOver(0, 0));
c.getSession().write(MaplePacketCreator.showMTSCash(c.getPlayer()));
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
int pages = 0;
try
{
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = 1 AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
ps.setInt(1, 0);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo(i, rs.getInt("price") + 100 + (int)(rs.getInt("price") * 0.1), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price") + 100 + (int)(rs.getInt("price") * 0.1), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items");
rs = ps.executeQuery();
if (rs.next()) {
pages = (int) Math.ceil(rs.getInt(1) / 16);
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err1: " + e);
}
c.getSession().write(MaplePacketCreator.sendMTS(items, 1, 0, 0, pages));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
c.getPlayer().saveToDB(true);
} else {
new ServernoticeMapleClientMessageCallback(5, c).dropMessage("The Trade System is unavailable right now");
c.getSession().write(MaplePacketCreator.enableActions());
}
}
public List<MTSItemInfo> getNotYetSold(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE seller = ? AND transfer = 0 ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err8: " + e);
}
return items;
}
public List<MTSItemInfo> getTransfer(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE transfer = 1 AND seller = ? ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err7: " + e);
}
return items;
}
}
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
u bastard lol, i spent 10 hours trying to fix this lol
2 more bugs i found, with lag u can dupe items, and if u put stars in slot 2 u can split the sets.
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
Quote:
Originally Posted by
JustSomeone
Because I'm feeling nice, here's the fix:
Replace your TransferInventory function with this:
Code:
public static MaplePacket TransferInventory(List<MTSItemInfo> items) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendPacketOpcode.MTS_OPERATION.getValue());
mplew.write(0x21);
mplew.writeInt(items.size());
if(items.size() != 0) {
for(MTSItemInfo item : items)
{
addItemInfo(mplew, item.getItem(), true, true);
mplew.writeInt(item.getID()); //id
mplew.writeInt(item.getTaxes()); //taxes
mplew.writeInt(item.getPrice()); //price
mplew.writeLong(0);
mplew.writeInt(KoreanDateUtil.getQuestTimestamp(item.getEndingDate()));
mplew.writeMapleAsciiString(item.getSeller()); //account name (what was nexon thinking?)
mplew.writeMapleAsciiString(item.getSeller()); //char name
for(int ii = 0; ii < 28; ii++)
mplew.write(0);
}
}
mplew.write(0xD0 + items.size());
mplew.write(HexTool.getByteArrayFromHexString("FF FF FF 00"));
return mplew.getPacket();
}
Also, for more fixes replace your MTSHandler.java with this:
Code:
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.odinms.net.channel.handler;
import net.sf.odinms.client.*;
import net.sf.odinms.database.DatabaseConnection;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.net.MaplePacket;
import net.sf.odinms.net.channel.ChannelServer;
import net.sf.odinms.server.MapleInventoryManipulator;
import net.sf.odinms.server.MapleItemInformationProvider;
import net.sf.odinms.server.MTSItemInfo;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MTSHandler extends AbstractMaplePacketHandler {
private static Logger log = LoggerFactory.getLogger(DistributeSPHandler.class);
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if (slea.available() > 0) {
byte op = slea.readByte();
if (op == 2) { //put item up for sale
//D9 00
//02
//02
//D8 E5 3C 00
//00 00
//80 05 BB 46 E6 17 02
//01 00
//07 00
//54 72 61 69 74 6F 72
//00 00
//01 00 00 00
//01 00 00 00
//57 04 00 00
//07 01
byte itemtype = slea.readByte();
int itemid = slea.readInt();
slea.readShort();
slea.skip(7);
if (itemtype == 1) {
slea.skip(32); //item stats, but we don't need them (can be exploited!)
} else {
slea.readShort();
}
slea.readMapleAsciiString(); //another useless thing (owner)
if(itemtype == 1)
slea.readInt();
else
slea.readShort();
byte slot = 1;
short quantity = 1;
if(itemtype != 1)
slot = (byte)slea.readInt();
else
quantity = (short)slea.readInt();
if(itemtype == 1)
slea.readShort();
if(itemtype != 1)
quantity = (short)slea.readInt();
else
slot = (byte)slea.readInt();
if(itemtype == 1)
slea.readInt();
int price = slea.readInt();
if(itemtype == 1)
quantity = 1;
MapleInventoryType type = MapleItemInformationProvider.getInstance().getInventoryType(itemid);
IItem i = c.getPlayer().getInventory(type).getItem(slot).copy();
if(i != null && c.getPlayer().getMeso() >= 5000) {
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps;
Calendar calendar = Calendar.getInstance();
int year = 2008; //sad sad date for all of us ;-(
int month = 6; //sad sad date for all of us ;-(
int day = 17; //sad sad date for all of us ;-(
int oldmax = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int oldday = calendar.get(Calendar.DAY_OF_MONTH) + 7;
if(oldmax < oldday)
{
if(calendar.get(Calendar.MONTH) + 2 > 12) {
year = calendar.get(Calendar.YEAR) + 1;
month = 1;
calendar.set(year, month, 1);
day = oldday - oldmax;
} else {
month = calendar.get(Calendar.MONTH) + 2;
year = calendar.get(Calendar.YEAR);
calendar.set(year, month, 1);
day = oldday - oldmax;
}
} else {
day = calendar.get(Calendar.DAY_OF_MONTH) + 7;
month = calendar.get(Calendar.MONTH);
year = calendar.get(Calendar.YEAR);
}
String date = year + "-";
if(month < 10)
date += "0" + month + "-";
else
date += month + "-";
if(day < 10)
date += "0" + day;
else
date += day + "";
if(i.getType() == 2)
{
Item item = (Item)i;
ps = con.prepareStatement("INSERT INTO mts_items (tab, type, itemid, quantity, seller, price, owner, sellername, sell_ends) VALUES " +
"(?, ?, ?, ?, ?, ?, ?, ?, ?)");
ps.setInt(1, 1);
ps.setInt(2, (int)type.getType());
ps.setInt(3, item.getItemId());
ps.setInt(4, quantity);
ps.setInt(5, c.getPlayer().getId());
ps.setInt(6, price);
ps.setString(7, item.getOwner());
ps.setString(8, c.getPlayer().getName());
ps.setString(9, date);
} else {
Equip equip = (Equip)i;
ps = con.prepareStatement("INSERT INTO mts_items (tab, type, itemid, quantity, seller, price, upgradeslots, level, str, dex, `int`, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump, locked, owner, sellername, sell_ends) VALUES " +
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
ps.setInt(1, 1);
ps.setInt(2, (int)type.getType());
ps.setInt(3, equip.getItemId());
ps.setInt(4, quantity);
ps.setInt(5, c.getPlayer().getId());
ps.setInt(6, price);
ps.setInt(7, equip.getUpgradeSlots());
ps.setInt(8, equip.getLevel());
ps.setInt(9, equip.getStr());
ps.setInt(10, equip.getDex());
ps.setInt(11, equip.getInt());
ps.setInt(12, equip.getLuk());
ps.setInt(13, equip.getHp());
ps.setInt(14, equip.getMp());
ps.setInt(15, equip.getWatk());
ps.setInt(16, equip.getMatk());
ps.setInt(17, equip.getWdef());
ps.setInt(18, equip.getMdef());
ps.setInt(19, equip.getAcc());
ps.setInt(20, equip.getAvoid());
ps.setInt(21, equip.getHands());
ps.setInt(22, equip.getSpeed());
ps.setInt(23, equip.getJump());
ps.setInt(24, equip.getLocked());
ps.setString(25, equip.getOwner());
ps.setString(26, c.getPlayer().getName());
ps.setString(27, date);
}
ps.executeUpdate();
ps.close();
MapleInventoryManipulator.removeFromSlot(c, type, slot, quantity, false);
}
catch(SQLException e) {
log.error("SQLErr4: " + e);
}
c.getPlayer().gainMeso(-5000, false);
c.getSession().write(MaplePacketCreator.MTSConfirmSell());
c.getSession().write(getMTS(1, 0, 0));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
}
} else if (op == 3) { //send offer for wanted item
} else if (op == 4) { //list wanted item
int itemid = slea.readInt();
int price = slea.readInt();
int quantity = slea.readInt();
slea.readShort();
String message = slea.readMapleAsciiString();
} else if (op == 5) { //change page/tab
//tabs
//1 = for sale
//2 = wanted
//3 = auction
//4 = my page
//5 = guide
//types (wanted & auction)
//0 = all
//1 = equip
//2 = use
//3 = setup
//4 = etc
//types (my page)
//0 = cart
//1 = offers
//2 = history
//3 = auction
int tab = slea.readInt();
int type = slea.readInt();
int page = slea.readInt();
c.getPlayer().changeTab(tab);
c.getPlayer().changeType(type);
c.getPlayer().changePage(page);
if(tab == 4 && type == 0)
c.getSession().write(getCart(c.getPlayer().getId()));
else
c.getSession().write(getMTS(tab, type, page));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
} else if (op == 6) { //search
//D9 00
//06
//01 00 00 00
//00 00 00 00
//00 00 00 00
//00 00 00 00
//09 00 -search len
//6C 6F 6C 73 65 61 72 63 68 -search
slea.readInt();
slea.readInt();
slea.readInt();
slea.readInt();
String search = slea.readMapleAsciiString();
} else if (op == 7) { //cancel sale
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("UPDATE mts_items SET transfer = 1 WHERE id = ? AND seller = ?");
ps.setInt(1, id);
ps.setInt(2, c.getPlayer().getId());
ps.executeUpdate();
ps.close();
}
catch(SQLException e) {
log.error("SQLErr4: " + e);
}
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(getMTS(c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage()));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
} else if (op == 8) { //transfer item from transfer inv.
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE seller = ? AND transfer = 1 ORDER BY id DESC");
ps.setInt(1, c.getPlayer().getId());
rs = ps.executeQuery();
if (rs.next()) {
IItem i;
if(rs.getInt("type") != 1)
{
Item ii = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
ii.setOwner(rs.getString("owner"));
ii.setPosition(c.getPlayer().getInventory(MapleItemInformationProvider.getInstance().getInventoryType(rs.getInt("itemid"))).getNextFreeSlot());
i = ii.copy();
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
equip.setPosition(c.getPlayer().getInventory(MapleItemInformationProvider.getInstance().getInventoryType(rs.getInt("itemid"))).getNextFreeSlot());
i = equip.copy();
}
PreparedStatement pse = con.prepareStatement("DELETE FROM mts_items WHERE id = ? AND seller = ? AND transfer = 1");
pse.setInt(1, id);
pse.setInt(2, c.getPlayer().getId());
pse.executeUpdate();
pse.close();
MapleInventoryManipulator.addFromDrop(c, i, "MTS transfer", false);
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(getMTS(c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage()));
c.getSession().write(MaplePacketCreator.MTSConfirmTransfer(i.getQuantity(), i.getPosition()));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err8: " + e);
}
} else if (op == 9) { //add to cart
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
try
{
PreparedStatement ps = con.prepareStatement("SELECT id FROM mts_cart WHERE cid = ? AND itemid = ?");
ps.setInt(1, id);
ps.setInt(2, c.getPlayer().getId());
ResultSet rs = ps.executeQuery();
if(!rs.next())
{
PreparedStatement pse = con.prepareStatement("INSERT INTO mts_cart (cid, itemid) VALUES (?, ?)");
pse.setInt(1, c.getPlayer().getId());
pse.setInt(2, id);
pse.executeUpdate();
}
ps.executeUpdate();
} catch(SQLException e) {
log.error("SqlErr12: ", e);
}
c.getSession().write(getMTS(c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage()));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.enableActions());
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
} else if (op == 10) { //delete from cart
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
try
{
PreparedStatement ps = con.prepareStatement("DELETE FROM mts_cart WHERE itemid = ? AND cid = ?");
ps.setInt(1, id);
ps.setInt(2, c.getPlayer().getId());
ps.executeUpdate();
} catch(SQLException e) {
log.error("SqlErr12: ", e);
}
c.getSession().write(getCart(c.getPlayer().getId()));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
} else if (op == 12) { //put item up for auction
int itemid = slea.readInt();
} else if (op == 12) { //cancel wanted cart thing
} else if (op == 14) { //buy auction item now
} else if (op == 16) { //buy
//transaction fees: 100NX + 10% of item price
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE id = ? ORDER BY id DESC");
ps.setInt(1, id);
rs = ps.executeQuery();
if (rs.next()) {
int price = rs.getInt("price") + 100 + (int)(rs.getInt("price") * 0.1); //taxes
if(c.getPlayer().getCSPoints(4) >= price) {
boolean alwaysnull = true;
for(ChannelServer cserv : ChannelServer.getAllInstances()) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterById(rs.getInt("seller"));
if(victim != null) {
victim.modifyCSPoints(4, rs.getInt("price"));
alwaysnull = false;
}
}
if(alwaysnull) {
PreparedStatement pse = con.prepareStatement("SELECT accountid FROM characters WHERE id = ?");
pse.setInt(1, rs.getInt("seller"));
ResultSet rse = pse.executeQuery();
if(rse.next()) {
PreparedStatement psee = con.prepareStatement("UPDATE accounts SET cardNX = cardNX + ? WHERE id = ?");
psee.setInt(1, rs.getInt("price"));
psee.setInt(2, rse.getInt("accountid"));
psee.executeUpdate();
psee.close();
}
pse.close();
rse.close();
}
PreparedStatement pse = con.prepareStatement("UPDATE mts_items SET seller = ?, transfer = 1 WHERE id = ?");
pse.setInt(1, c.getPlayer().getId());
pse.setInt(2, id);
pse.executeUpdate();
pse.close();
c.getPlayer().modifyCSPoints(4, -price);
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(getMTS(c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage()));
c.getSession().write(MaplePacketCreator.MTSConfirmBuy());
c.getSession().write(MaplePacketCreator.showMTSCash(c.getPlayer()));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.enableActions());
} else {
c.getSession().write(MaplePacketCreator.MTSFailBuy());
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
c.getSession().write(MaplePacketCreator.MTSFailBuy());
log.error("Err8: " + e);
}
} else if (op == 17) { //buy from cart
int id = slea.readInt(); //id of the item
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE id = ? ORDER BY id DESC");
ps.setInt(1, id);
rs = ps.executeQuery();
if (rs.next()) {
int price = rs.getInt("price") + 100 + (int)(rs.getInt("price") * 0.1);
if(c.getPlayer().getCSPoints(4) >= price) {
for(ChannelServer cserv : ChannelServer.getAllInstances()) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterById(rs.getInt("seller"));
if(victim != null) {
victim.modifyCSPoints(4, rs.getInt("price"));
} else {
PreparedStatement pse = con.prepareStatement("SELECT accountid FROM characters WHERE id = ?");
pse.setInt(1, rs.getInt("seller"));
ResultSet rse = pse.executeQuery();
if(rse.next()) {
PreparedStatement psee = con.prepareStatement("UPDATE accounts SET cardNX = cardNX + ? WHERE id = ?");
psee.setInt(1, rs.getInt("price"));
psee.setInt(2, rse.getInt("accountid"));
psee.executeUpdate();
psee.close();
}
pse.close();
rse.close();
}
}
PreparedStatement pse = con.prepareStatement("UPDATE mts_items SET seller = ?, transfer = 1 WHERE id = ?");
pse.setInt(1, c.getPlayer().getId());
pse.setInt(2, id);
pse.executeUpdate();
pse.close();
pse = con.prepareStatement("DELETE FROM mts_cart WHERE itemid = ? AND cid = ?");
pse.setInt(1, id);
pse.setInt(2, c.getPlayer().getId());
pse.executeUpdate();
pse.close();
c.getPlayer().modifyCSPoints(4, -price);
c.getSession().write(getCart(c.getPlayer().getId()));
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.MTSConfirmBuy());
c.getSession().write(MaplePacketCreator.showMTSCash(c.getPlayer()));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
} else {
c.getSession().write(MaplePacketCreator.MTSFailBuy());
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
c.getSession().write(MaplePacketCreator.MTSFailBuy());
log.error("Err8: " + e);
}
} else {
log.info("Unhandled OP(MTS): " + op + " Packet: " + slea.toString());
}
} else {
c.getSession().write(MaplePacketCreator.showMTSCash(c.getPlayer()));
}
}
public List<MTSItemInfo> getNotYetSold(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE seller = ? AND transfer = 0 ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err8: " + e);
}
return items;
}
public MaplePacket getCart(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
int pages = 0;
try
{
ps = con.prepareStatement("SELECT * FROM mts_cart WHERE cid = ? ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
PreparedStatement pse = con.prepareStatement("SELECT * FROM mts_items WHERE id = ?");
pse.setInt(1, rs.getInt("itemid"));
ResultSet rse = pse.executeQuery();
if (rse.next()) {
if(rse.getInt("type") != 1)
{
Item i = new Item(rse.getInt("itemid"), (byte)0, (short)rse.getInt("quantity"));
i.setOwner(rse.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rse.getInt("price"), rse.getInt("id"), rse.getInt("seller"), rse.getString("sellername"), rse.getString("sell_ends")));
} else {
Equip equip = new Equip(rse.getInt("itemid"), (byte) rse.getInt("position"), -1);
equip.setOwner(rse.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rse.getInt("acc"));
equip.setAvoid((short) rse.getInt("avoid"));
equip.setDex((short) rse.getInt("dex"));
equip.setHands((short) rse.getInt("hands"));
equip.setHp((short) rse.getInt("hp"));
equip.setInt((short) rse.getInt("int"));
equip.setJump((short) rse.getInt("jump"));
equip.setLuk((short) rse.getInt("luk"));
equip.setMatk((short) rse.getInt("matk"));
equip.setMdef((short) rse.getInt("mdef"));
equip.setMp((short) rse.getInt("mp"));
equip.setSpeed((short) rse.getInt("speed"));
equip.setStr((short) rse.getInt("str"));
equip.setWatk((short) rse.getInt("watk"));
equip.setWdef((short) rse.getInt("wdef"));
equip.setUpgradeSlots((byte) rse.getInt("upgradeslots"));
equip.setLocked((byte) rse.getInt("locked"));
equip.setLevel((byte) rse.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rse.getInt("price"), rse.getInt("id"), rse.getInt("seller"), rse.getString("sellername"), rse.getString("sell_ends")));
}
}
}
rs.close();
ps.close();
ps = con.prepareStatement("SELECT COUNT(*) FROM mts_cart WHERE cid = ?");
ps.setInt(1, cid);
rs = ps.executeQuery();
if (rs.next()) {
pages = (int) Math.ceil(rs.getInt(1) / 16);
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err8: " + e);
}
return MaplePacketCreator.sendMTS(items, 4, 0, 0, pages);
}
public List<MTSItemInfo> getTransfer(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE transfer = 1 AND seller = ? ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err7: " + e);
}
return items;
}
public MaplePacket getMTS(int tab, int type, int page)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
int pages = 0;
try
{
if(type != 0)
ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = ? AND type = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
else
ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
ps.setInt(1, tab);
if(type != 0)
{
ps.setInt(2, type);
ps.setInt(3, page * 16);
} else {
ps.setInt(2, page * 16);
}
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
if(type != 0)
ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items WHERE tab = ? AND type = ? AND transfer = 0");
else
ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items WHERE tab = ? AND transfer = 0");
ps.setInt(1, tab);
if(type != 0)
ps.setInt(2, type);
rs = ps.executeQuery();
if (rs.next()) {
pages = (int) Math.ceil(rs.getInt(1) / 16);
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err6: " + e);
}
return MaplePacketCreator.sendMTS(items, tab, type, page, pages);
}
}
And your MTSItemInfo.java with this:
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.sf.odinms.server;
import net.sf.odinms.client.IItem;
import java.util.*;
/**
*
* @author Traitor
*/
public class MTSItemInfo {
private int price;
private IItem item;
private String seller;
private int id;
private int cid;
private int year, month, day = 1;
public MTSItemInfo(IItem item, int price, int id, int cid, String seller, String date) {
this.item = item;
this.price = price;
this.seller = seller;
this.id = id;
this.cid = cid;
this.year = Integer.parseInt(date.substring(0, 4));
this.month = Integer.parseInt(date.substring(5, 7));
this.day = Integer.parseInt(date.substring(8, 10));
}
public IItem getItem() {
return item;
}
public int getPrice() {
return price;
}
public int getRealPrice() {
return price + getTaxes();
}
public int getTaxes() {
return 100 + (int)(price * 0.1);
}
public int getID() {
return id;
}
public int getCID() {
return cid;
}
public long getEndingDate() {
Calendar now = Calendar.getInstance();
now.set(year, month - 1, day);
return now.getTimeInMillis();
}
public String getSeller() {
return seller;
}
}
And add these in MapleCharacter:
Code:
//mts stuff
private int currentPage, currentType = 0;
private int currentTab = 1;
Same with these:
Code:
public void changePage(int page) {
this.currentPage = page;
}
public void changeTab(int tab) {
this.currentTab = tab;
}
public void changeType(int type) {
this.currentType = type;
}
public int getCurrentPage() {
return currentPage;
}
public int getCurrentTab() {
return currentTab;
}
public int getCurrentType() {
return currentType;
}
And finally, replace your EnterMTSHandler.java with this:
Code:
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.odinms.net.channel.handler;
import java.rmi.RemoteException;
import net.sf.odinms.client.*;
import net.sf.odinms.client.messages.ServernoticeMapleClientMessageCallback;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.net.channel.ChannelServer;
import net.sf.odinms.net.world.remote.WorldChannelInterface;
import net.sf.odinms.server.MTSItemInfo;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
import net.sf.odinms.database.DatabaseConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EnterMTSHandler extends AbstractMaplePacketHandler {
private static Logger log = LoggerFactory.getLogger(DistributeSPHandler.class);
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if (c.getChannelServer().allowMTS()) {
if (c.getPlayer().getNoPets() > 0) {
c.getPlayer().unequipAllPets();
}
try {
WorldChannelInterface wci = ChannelServer.getInstance(c.getChannel()).getWorldInterface();
wci.addBuffsToStorage(c.getPlayer().getId(), c.getPlayer().getAllBuffs());
wci.addCooldownsToStorage(c.getPlayer().getId(), c.getPlayer().getAllCooldowns());
} catch (RemoteException e) {
c.getChannelServer().reconnectWorld();
}
c.getPlayer().getMap().removePlayer(c.getPlayer());
c.getSession().write(MaplePacketCreator.warpMTS(c));
c.getPlayer().setInMTS(true);
c.getSession().write(MaplePacketCreator.enableMTS());
c.getSession().write(MaplePacketCreator.MTSWantedListingOver(0, 0));
c.getSession().write(MaplePacketCreator.showMTSCash(c.getPlayer()));
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
int pages = 0;
try
{
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = 1 AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
ps.setInt(1, 0);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo(i, rs.getInt("price") + 100 + (int)(rs.getInt("price") * 0.1), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price") + 100 + (int)(rs.getInt("price") * 0.1), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items");
rs = ps.executeQuery();
if (rs.next()) {
pages = (int) Math.ceil(rs.getInt(1) / 16);
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err1: " + e);
}
c.getSession().write(MaplePacketCreator.sendMTS(items, 1, 0, 0, pages));
c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
c.getPlayer().saveToDB(true);
} else {
new ServernoticeMapleClientMessageCallback(5, c).dropMessage("The Trade System is unavailable right now");
c.getSession().write(MaplePacketCreator.enableActions());
}
}
public List<MTSItemInfo> getNotYetSold(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE seller = ? AND transfer = 0 ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err8: " + e);
}
return items;
}
public List<MTSItemInfo> getTransfer(int cid)
{
List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
ResultSet rs;
try
{
ps = con.prepareStatement("SELECT * FROM mts_items WHERE transfer = 1 AND seller = ? ORDER BY id DESC");
ps.setInt(1, cid);
rs = ps.executeQuery();
while (rs.next()) {
if(rs.getInt("type") != 1)
{
Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLocked((byte) rs.getInt("locked"));
equip.setLevel((byte) rs.getInt("level"));
items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
rs.close();
ps.close();
}
catch(SQLException e) {
log.error("Err7: " + e);
}
return items;
}
}
Does this fix error 38 and what eles???
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
Quote:
Originally Posted by
fdinufdinu
Does this fix error 38 and what eles???
1. Fixes error 38
2. You can cancel more than one item for sale now
3. Some other things
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
Oh man, can't believe this came out!
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
i know i sound newbie..but wtf is warpCS? -.- modify ur warpCS to look like this...god i cant figure it out...lol =\ can someone tell me where the hell can i find the warpCS thingy?
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
Quote:
Originally Posted by
Darkstorm
i know i sound newbie..but wtf is warpCS? -.- modify ur warpCS to look like this...god i cant figure it out...lol =\ can someone tell me where the hell can i find the warpCS thingy?
MaplePacketCreator.Java
-
Re: Release: MTS by traitor fixed by sadiq and redred from valhalladev
-
Re: [Release]: MTS by traitor fixed by sadiq and redred from valhalladev
People, please stop quoting his post.
-
Re: [Release]: MTS by traitor fixed by sadiq and redred from valhalladev
-
Re: [Release]: MTS by traitor fixed by sadiq and redred from valhalladev
Found an error i added Just someones fixes and now i am getting Main java errors
When i move my Dlist Folders to my Java folders in C:/program files/Java
and when i start the .bats i get Main Jave error
-
Re: [Release]: MTS by traitor fixed by sadiq and redred from valhalladev
now we have a new bug, theres only 1 page. lol.
theres only 1 page of items, it doesnt goto page 2 or anything.
-
Re: [Release]: MTS by traitor fixed by sadiq and redred from valhalladev
my com hangs when i try to visit the first page of this thread...can sum1 copy and paste everything and zip it up? TT
-
Re: [Release]: MTS by traitor fixed by sadiq and redred from valhalladev
Traitor said don't flame, but I say learn to respect others. Traitor had an account here before he released his MTS. If he wanted it here he would post it. Respect.
-
Re: [Release]: MTS by traitor fixed by sadiq and redred from valhalladev
anw....there is still error 38 code..
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
resinate how come u dont get the 38 code error?
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
I'm error in setLocked and getLocked
plz give me a Locked method
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
everytime u press MTS it dc-es u and ends u up in a error 38 reached end of file code. in other words, it doesnt.
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
i know how to get more pages..
hint: when entering mts, there is send a packets with the amount of items
soo, while rs.next... :/
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
well it shows like 2 pages now, but not all the items are listed. so i dunno kippi pm me if u want tho on what it is.
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
it got deleted
and i watch all threads
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
For the new fixes didn't justsomeone fix them all I mean I added his fix now my mts works great
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
actully theres a few bugs left, like u can dupe items, atm i cant force the dupe. it doesnt show half full pages only full pages. u can sell items only for nx. on gms u can sell for both i think
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
nice :):
i hope it works
well, i mean with no errors >o<
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
For the new fixes i dont think it fixes the 2 page thingy right
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
-
Re: [Release]: MTS by traitor fixed by redred from valhalladev
more bugs xD
cancel no delete Carts items
if u have >1 items in transfer it dupes after transfer to inventory (I fix it xD) later post