[Release]Block CS Items From Being Bought (FIXED)

Status
Not open for further replies.
Newbie Spellweaver
Joined
Jun 24, 2007
Messages
25
Reaction score
0
Omg, I'm so excited about this. This is the FIRST thing I've contributed to the community. Lol I have 11 posts. :D
For those who DIDN'T find a way for blocking CS items from being bought, since iGoofy's method blocks ALL items on accident. This method, MY method, is basically iGoofy's method just with a couple of edits to make it work. It's just a bit ugly. It's not my fault I don't know any java. I just moved my original post from iGoofy's thread because I wanted people to benefit from this and I just realized how to add more item IDs without adding the WHOLE script over again. Not many people read old posts that apparently died because the owner didn't GIVE a fix for it. I'm pretty sure iGoofy did this already....As did other people who are experienced with java. I've tested this and it works 100%!!
ALL CREDITS GO TO iGoofy. Without further ado. The fix! You do not need to apply iGoofy's block CS items method. I've included parts of his method in here because this IS entirely based off it. This shouldn't even be considered mine. Here it is:


In BuyCSItemhandler.java:
Under
Code:
private final static Logger log = LoggerFactory.getLogger(MapleServerHandler.class);
Place
Code:
private final static int[] blockedItems = {1};
Under
Code:
CashItemInfo item = CashItemFactory.getItem(snCS);
Place
PHP:
                if (item.getId() >= 5211000 && item.getId() <= 5211048 || item.getId() == Enter_Item_Id_Here) {
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(1, "You may not purchase this item."));
                    c.getSession().write(MaplePacketCreator.showNXMapleTokens(c.getPlayer()));
                    c.getSession().write(MaplePacketCreator.enableCSUse0());
                    c.getSession().write(MaplePacketCreator.enableCSUse1());
                    c.getSession().write(MaplePacketCreator.enableCSUse2());
                    c.getSession().write(MaplePacketCreator.enableCSUse3());
                    return;
                }
This ALREADY blocks out the EXP cards from being bought. You need to edit it to block more items in the Cash Shop. (Duh?) To block more item id's, just Add:
PHP:
 || item.getId() == ENTER_ITEM_ID_HERE
After:
PHP:
|| item.getId() == Enter_Item_Id_Here
And Repeat to block more items

To block a range of items, just Add:
PHP:
|| item.getId() >= Item_ID_Here && item.getId() <= Item_ID_Here
After:
PHP:
|| item.getId() == Enter_Item_Id_Here
And Repeat to block more items



Hope I helped someone. :D
Note: I doubt you would need
PHP:
private final static int[] blockedItems = {1};
but I included it, just incase iGoofy comes back with a BETTER fix for his original script.

Some people still use this thread. (I think...) So... THIS WAS FOR V.55. IT MAY NOT WORK WITH ANY OTHER VERSIONS. USE AT YOUR OWN RISK! <:= WARNING!
 
Last edited:
can't u just edit the client and remove the cs?
What I'm doing is blocking you from buying individual items. And what you said is remove the whole Cash Shop. I/people still want Cash Shop to function, but want to restrict certain items as they could glitch your character. Like Magic Scales item. And I think if you edit the client to remove individual items from the cash shop, you'd have to unpack the wz files then repack them. Which I or most people don't know how to do. Then people would have to download your WHOLE MAPLESTORY FOLDER to play and people without your folder would be running around with the items they bought from the Cash Shop that you tried to block.

Someone correct me if I'm wrong. :)
 
What I'm doing is blocking you from buying individual items. And what you said is remove the whole Cash Shop. I/people still want Cash Shop to function, but want to restrict certain items as they could glitch your character. Like Magic Scales item. And I think if you edit the client to remove individual items from the cash shop, you'd have to unpack the wz files then repack them. Which I or most people don't know how to do. Then people would have to download your WHOLE MAPLESTORY FOLDER to play and people without your folder would be running around with the items they bought from the Cash Shop that you tried to block.

Someone correct me if I'm wrong. :)
your not wrong lol..
some people donate money and get stuff and then get like massive amounts of nx then just sell it...
 
your not wrong lol..
some people donate money and get stuff and then get like massive amounts of nx then just sell it...

Sweet.:flag_schw Aw man, so less replies, I hope people are benefiting from this. :( I didn't post this just for it to be ignored.

Thanks iMurad \/. Didn't want to waste another post on another Thanks. :D

Did you use it iMurad?
 
Last edited:
where u say to add code..
underneath stands:

Code:
if (item.getId() >= 5000000 && item.getId() <= 5000045) {
			try {
				Connection con = DatabaseConnection.getConnection();
				PreparedStatement ps = con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness) VALUES (?, ?, ?, ?)");
				ps.setString(1, ii.getName(item.getId()));
				ps.setInt(2, 1);
				ps.setInt(3, 0);
				ps.setInt(4, 100);
				ps.executeUpdate();
				ResultSet rs = ps.getGeneratedKeys();
				rs.next();
				//c.getPlayer().equipChanged();
				MapleInventoryManipulator.addById(c, item.getId(), (short) item.getCount(), "Cash Item was purchased.", null, rs.getInt(1));
				rs.close();
				ps.close();
			} catch (SQLException ex) {
				java.util.logging.Logger.getLogger(BuyCSItemHandler.class.getName()).log(Level.SEVERE, null, ex);
			}
		}

do i need to change if to else if ??
 
If you don't want people spaming the all channel when they try to buy a blocked item, change the:
Code:
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(1, "You may not purchase this item."));
To:
Code:
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(6, "You may not purchase this item."));
 
where u say to add code..
underneath stands:

Code:
if (item.getId() >= 5000000 && item.getId() <= 5000045) {
            try {
                Connection con = DatabaseConnection.getConnection();
                PreparedStatement ps = con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness) VALUES (?, ?, ?, ?)");
                ps.setString(1, ii.getName(item.getId()));
                ps.setInt(2, 1);
                ps.setInt(3, 0);
                ps.setInt(4, 100);
                ps.executeUpdate();
                ResultSet rs = ps.getGeneratedKeys();
                rs.next();
                //c.getPlayer().equipChanged();
                MapleInventoryManipulator.addById(c, item.getId(), (short) item.getCount(), "Cash Item was purchased.", null, rs.getInt(1));
                rs.close();
                ps.close();
            } catch (SQLException ex) {
                java.util.logging.Logger.getLogger(BuyCSItemHandler.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
do i need to change if to else if ??

You add it before that and no you don't need to change "if" to "else if".

If you don't want people spaming the all channel when they try to buy a blocked item, change the:
Code:
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(1, "You may not purchase this item."));
To:
Code:
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(6, "You may not purchase this item."));

What do you mean? Once someone buys a blocked item, it doesn't show the message to everyone in the channel. It did before, when iGoofy didn't update his script. I tested it now and it doesn't show to everyone, but thanks anyways. I might be wrong...~
 
This is useful because nobody can't even find a full Cash Shop Patch lolz.
Lol, omg... HAHAHAHAHAHAHAHA. Nice.
Just because the Cash Shop isn't FULLY working, doesn't mean it's not working at all. I mean, you can still use the Cash Shop and buy items from there. (Just not the female items... Or maybe it's just me.) If the Cash Shop works, even if it's not fully working, people will still want to block items, for whatever reason. For instance, the magic scales item glitches you, and I'm pretty sure that people who play on your server won't know that unless you tell them, but there are always people who won't know and would buy it. Then later they will come complaining, saying, "Omg omg my account iz glitch0rzed fix it pl0x i wan to plae s0 badlay." (Sorry my impression of a noob is off, I should just be myself if I wanted to show a noob.) So you could use this to block off items that glitch just like Magic Scales. Or you could block off other items and make them like "Event Only" items so they will be rare. An incentive for people to stay. So they won't get everything so easily.
 
I get this
Code:
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Owner\Desktop\CrisisMS\OdinMS\build\classes
C:\Documents and Settings\Owner\Desktop\CrisisMS\src\net\sf\odinms\net\channel\handler\BuyCSItemHandler.java:59: illegal start of expression
                if (item.getId() >= 5211000 && item.getId() <= 5211048 || item.getId() == 1812006) || item.getId() >= 1112001 && item.getId() <= 1112006;   {
                                                                                                   ^
C:\Documents and Settings\Owner\Desktop\CrisisMS\src\net\sf\odinms\net\channel\handler\BuyCSItemHandler.java:59: not a statement
                if (item.getId() >= 5211000 && item.getId() <= 5211048 || item.getId() == 1812006) || item.getId() >= 1112001 && item.getId() <= 1112006;   {
                                                                                                                                              ^
Help?
 
I get this
Code:
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Owner\Desktop\CrisisMS\OdinMS\build\classes
C:\Documents and Settings\Owner\Desktop\CrisisMS\src\net\sf\odinms\net\channel\handler\BuyCSItemHandler.java:59: illegal start of expression
                if (item.getId() >= 5211000 && item.getId() <= 5211048 || item.getId() == 1812006) || item.getId() >= 1112001 && item.getId() <= 1112006;   {
                                                                                                   ^
C:\Documents and Settings\Owner\Desktop\CrisisMS\src\net\sf\odinms\net\channel\handler\BuyCSItemHandler.java:59: not a statement
                if (item.getId() >= 5211000 && item.getId() <= 5211048 || item.getId() == 1812006) || item.getId() >= 1112001 && item.getId() <= 1112006;   {
                                                                                                                                              ^
Help?
Sorry for taking so long to reply, I thought this would die down. Any who... I need to see your WHOLE BuyCSItemHandler.java file, but I'm pretty sure you're missing a "{" somewhere before that "if" statement because it works fine for me.
 
Can we see your whole BUYCSItem Handler to block all 2x exp cards because its not working for me

Sure, here you go. Sorry I took so long, I'm not that active on RageZone anymore.

PHP:
/*
    This file is part of the OdinMS Maple Story Server
    Copyright (C) 2008 Patrick Huy <[email protected]> 
                       Matthias Butz <[email protected]>
                       Jan Christian Meyer <[email protected]>

    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.util.logging.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import net.sf.odinms.client.MapleClient;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.database.DatabaseConnection;
import net.sf.odinms.net.MapleServerHandler;
import net.sf.odinms.server.AutobanManager;
import net.sf.odinms.server.MapleInventoryManipulator;
import net.sf.odinms.server.MapleItemInformationProvider;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
import net.sf.odinms.server.CashItemFactory;
import net.sf.odinms.server.CashItemInfo;

/**
*
* @author Penguins (Acrylic)
*/
public class BuyCSItemHandler extends AbstractMaplePacketHandler {
    private final static Logger log = LoggerFactory.getLogger(MapleServerHandler.class);
    private final static int[] blockedItems = {1072153, 5040000, 5041000, 5060000, 1702151, 1102039, 1112002, 1112003, 1112801, 1112800, 1112802, 1112006, 1112005, 1112001, 2030007, 5075001, 5075002, 5075003, 5075004, 5075005, 5021021, 5021020, 5021016, 5021015, 5021014, 5021013, 5021012, 5021010, 5021009, 5021008, 5021007, 5021006, 5021005, 5021004, 5021003, 5021002, 5021001, 5021000, 5021011, 1702147, 1702146, 1702099, 1702180, 1702185, 1702145, 1002186, 1032024, 1032051, 1032053, 1032052, 10822273, 5000000, 5000001, 5000002, 5000003, 5000004, 5000005, 5000006, 5000007, 5000008, 5000009, 5000010, 5000011, 5000012, 5000013, 5000014, 5000015, 5000017, 5000018, 5000020, 5000021, 5000022, 5000023, 5000024, 5000025, 5000028, 5000030, 5000031, 5000032, 5000033, 5000034, 5000036, 5000037, 5000039, 5000041};

    @Override
    public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
        if(c.getPlayer().inCS())
        {
                log.info(slea.toString());
                int mode = slea.readByte();
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        slea.skip(1);
        int snCS = slea.readInt();
        CashItemInfo item = CashItemFactory.getItem(snCS);
                if (item.getId() >= 5211000 && item.getId() <= 5211048) {
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(1, "You may not purchase this item."));
                    c.getSession().write(MaplePacketCreator.showNXMapleTokens(c.getPlayer()));
                    c.getSession().write(MaplePacketCreator.enableCSUse0());
                    c.getSession().write(MaplePacketCreator.enableCSUse1());
                    c.getSession().write(MaplePacketCreator.enableCSUse2());
                    c.getSession().write(MaplePacketCreator.enableCSUse3());
                    return;
                } 
                if (item.getId() >= 5000000 && item.getId() <= 5000045) {
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(1, "You may not purchase this item."));
                    c.getSession().write(MaplePacketCreator.showNXMapleTokens(c.getPlayer()));
                    c.getSession().write(MaplePacketCreator.enableCSUse0());
                    c.getSession().write(MaplePacketCreator.enableCSUse1());
                    c.getSession().write(MaplePacketCreator.enableCSUse2());
                    c.getSession().write(MaplePacketCreator.enableCSUse3());
                    return;
                }
                if (item.getId() == 1072153 || item.getId() == 1812005 || item.getId() == 5040000 || item.getId() == 5060000 || item.getId() == 1702151 || item.getId() == 1102039 || item.getId() == 1112002 || item.getId() == 1112003 || item.getId() == 1112801 || item.getId() == 1112800 || item.getId() == 1112802 || item.getId() == 1112006 || item.getId() == 1112005 || item.getId() == 1112001 || item.getId() == 2030007 || item.getId() == 5075001 || item.getId() == 5075002 || item.getId() == 5075003 || item.getId() == 5075004 || item.getId() == 5075005 || item.getId() == 5021021 || item.getId() == 5021020 || item.getId() == 5021016 || item.getId() == 5021015 || item.getId() == 5021014 || item.getId() == 5021013 || item.getId() == 5021012 || item.getId() == 5021010 || item.getId() == 5021009 || item.getId() == 5021008 || item.getId() == 5021007 || item.getId() == 5021006 || item.getId() == 5021005 || item.getId() == 5021004 || item.getId() == 5021003 || item.getId() == 5021002 || item.getId() == 5021001 || item.getId() == 5021000 || item.getId() == 5021011 || item.getId() == 1702147 || item.getId() == 1702146 || item.getId() == 1702099 || item.getId() == 1702180 || item.getId() == 1702185 || item.getId() == 1702145 || item.getId() == 1002186 || item.getId() == 1032024 || item.getId() == 1032051 || item.getId() == 1032053 || item.getId() == 10822273 || item.getId() == 1812006) {
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(1, "You may not purchase this item."));
                    c.getSession().write(MaplePacketCreator.showNXMapleTokens(c.getPlayer()));
                    c.getSession().write(MaplePacketCreator.enableCSUse0());
                    c.getSession().write(MaplePacketCreator.enableCSUse1());
                    c.getSession().write(MaplePacketCreator.enableCSUse2());
                    c.getSession().write(MaplePacketCreator.enableCSUse3());
                    return;
                }

        if (item.getId() >= 5000000 && item.getId() <= 5000045) {
            try {
                Connection con = DatabaseConnection.getConnection();
                PreparedStatement ps = con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness) VALUES (?, ?, ?, ?)");
                ps.setString(1, ii.getName(item.getId()));
                ps.setInt(2, 1);
                ps.setInt(3, 0);
                ps.setInt(4, 100);
                ps.executeUpdate();
                ResultSet rs = ps.getGeneratedKeys();
                rs.next();
                //c.getPlayer().equipChanged();
                MapleInventoryManipulator.addById(c, item.getId(), (short) item.getCount(), "Cash Item was purchased.", null, rs.getInt(1));
                rs.close();
                ps.close();
            } catch (SQLException ex) {
                java.util.logging.Logger.getLogger(BuyCSItemHandler.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
        if(c.getPlayer().getNX() >= item.getPrice())
                if (item.getId() >= 5211000 && item.getId() <= 5211048) {
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(1, "You may not purchase this item."));
                    c.getSession().write(MaplePacketCreator.showNXMapleTokens(c.getPlayer()));
                    c.getSession().write(MaplePacketCreator.enableCSUse0());
                    c.getSession().write(MaplePacketCreator.enableCSUse1());
                    c.getSession().write(MaplePacketCreator.enableCSUse2());
                    c.getSession().write(MaplePacketCreator.enableCSUse3());
                    return;
                }
                if (item.getId() >= 5000000 && item.getId() <= 5000045) {
                    c.getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(1, "You may not purchase this item."));
                    c.getSession().write(MaplePacketCreator.showNXMapleTokens(c.getPlayer()));
                    c.getSession().write(MaplePacketCreator.enableCSUse0());
                    c.getSession().write(MaplePacketCreator.enableCSUse1());
                    c.getSession().write(MaplePacketCreator.enableCSUse2());
                    c.getSession().write(MaplePacketCreator.enableCSUse3());
                    return;
                }
        MapleInventoryManipulator.addById(c, item.getId(), (short) item.getCount(), "Cash Item was purchased.");
        }
        c.getSession().write(MaplePacketCreator.showBoughtCSItem(item.getId()));
        c.getPlayer().modifyCSPoints(0, -item.getPrice());
        c.getSession().write(MaplePacketCreator.showNXMapleTokens(c.getPlayer()));
        c.getSession().write(MaplePacketCreator.enableCSUse0());
        c.getSession().write(MaplePacketCreator.enableCSUse1());
        c.getSession().write(MaplePacketCreator.enableCSUse2());
        c.getSession().write(MaplePacketCreator.enableCSUse3());

    if (c.getPlayer().getNX() < 0) {
    AutobanManager.getInstance().addPoints(c, 1000, 0, "NX Hacking");
    }
            }
        }
}

PS: It's a bit sloppy because I got too lazy to clean it up. Doesn't really matter anyways. It's still a small file. Enjoy. :)
 
Status
Not open for further replies.
Back