[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();
}