Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Add-on] NPC that delete your items.

Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
2nd Release o.o Oh well ;)

Add these in NPCConversationManager.java
Code:
public String EquipList(MapleClient c) {
        StringBuilder str = new StringBuilder();
           MapleInventory equip = c.getPlayer().getInventory(MapleInventoryType.EQUIP);
                List<String> stra = new LinkedList<String>();
                    for (IItem item : equip.list()) {
                        stra.add("#L"+item.getPosition()+"##v"+item.getItemId()+"##l");
                        }
                    for (String strb : stra) {
                str.append(strb);
            }
        return str.toString();
    }
    
public String CashList(MapleClient c) {
        StringBuilder str = new StringBuilder();
           MapleInventory cash = c.getPlayer().getInventory(MapleInventoryType.CASH);
                List<String> stra = new LinkedList<String>();
                    for (IItem item : cash.list()) {
                        stra.add("#L"+item.getPosition()+"##v"+item.getItemId()+"##l");
                        }
                    for (String strb : stra) {
                str.append(strb);
            }
        return str.toString();
    }

NPC script :
Code:
/*
Scripted by Yz, AAFS's DEVTeam. 2010-2011. All right reserved.
--------------------------------------------------------------
Feel free to re-distribute my work, but remember to give the proper credits. 

Credit to Shawn in Rz
*/

importPackage(Packages.client);

var status = 0;
var chosenItem;
var selected = 1;
var selectedType = -1;
var selectedItem = -1;
var choice;
status = -1;

function start() {
    cm.sendSimple("Hey #b#h ##k. I'm #rInventory Cleaner#k. Well, do you think you need some #bcleaning#k? If yes, I will give u a small #rwarning#k. Once click, your item will be deleted. We won't #rrefund#k your item! So, choose wisely! \r\n#L0#Equip Cleaner#l \r\n#L1#Cash Cleaner#l");
}
function action(mode, type, selection){
    if (mode != 1) {
        cm.dispose();
        return;
    }else{
        status++;
    }
    if (status == 0){
        choice = selection;
        if (choice == 0){
            cm.sendSimple("Well, choose wisely! We won't refund your #rEquip#k if you selected wrong! \r\n\r\n"+cm.EquipList(cm.getClient()));
        }else if (choice == 1){
            cm.sendSimple("PWell, choose wisely! We won't refund your #rCash#k if you selected wrong!  \r\n\r\n"+cm.CashList(cm.getClient()));
        }
    }else if (status == 1){
        /*     not fully sure, but this should work for both since 
            selection will start at 0 regardless of which you chose */
      	selectedType = selection;
		var type = [MapleInventoryType.EQUIP,MapleInventoryType.CASH];
            chosenItem = cm.getPlayer().getInventory(type[choice]).getItem(selection).getItemId();
            cm.gainItem(chosenItem, -1);
            cm.sendOk("Thank you for your garbage!");
            cm.dispose();
    }
}

Should work probably.. ^_^"
Release for those need it. If you dislike then excuse me please <3

Credit : AAFSv2, Shawn, SuperLol, maxcloud on NPC idea, the one who release the MSI NPC :eek:tt:
 
Joined
Nov 27, 2009
Messages
442
Reaction score
230
Re: NPC that delete your items.

I don't get it, your Dev team claims it's scripted by them yet you give credits to Shawn? Also I find Moogra's version alot better.
 
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: NPC that delete your items.

@Expedia : Shawn one don't work for some reason o.o But he did help me a lots with the script, so credit Shawn ;) And Moongra's one I can't make it work o.o Idk why. the ArrayList function undefined @_@
 
Joined
Jun 5, 2010
Messages
567
Reaction score
598
Re: NPC that delete your items.

@Expedia : Shawn one don't work for some reason o.o But he did help me a lots with the script, so credit Shawn ;) And Moongra's one I can't make it work o.o Idk why. the ArrayList function undefined @_@

You didn't add the method to MapleInventory.java. You just need to make it return a new ArrayList with the items in the inventory. It's a lame way of preventing concurrentmod, but since it's only GMs using it, it doesn't matter. Also that's for the full wipe, which barely any of the GMs use. For the single item removal, you can delete that part and only use the first selection which doesn't require that method.
 
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: NPC that delete your items.

@SuperLol : o.o Sorry I din't know it go into MapleInventory.java >< Well because I just want to delete only the selected item, and my NPC release for all players, so I use this instead of yours ;)

But I believe yours is always better ^_^"
 
Joined
Jun 5, 2010
Messages
567
Reaction score
598
Re: NPC that delete your items.

I wasn't comparing yours to mine. I was just saying that mine wasn't broken lol. Oh there's a complication with all of the ones here too, and mine. The real way would be removeFromSlot, not gainItem(id, -1). You might end up deleting the wrong item but the same item id. I think I found a way to fix that a while ago but I never implemented it
 
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: NPC that delete your items.

Sorry I don't understand o.o
How will gainItem(id, -1) end up deleting the wrong item? o.o I thought it should always delete the right item we choose? @_@

//Edit : And I thought that every item should have an unique ID eh? o.o
 
Last edited:
bleh....
Loyal Member
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,129
Re: NPC that delete your items.

Ok... normally I'm not one to witch about people claiming credits for the scripts I hand them when they ask for help... but really?

Look at my post:
o_0

PHP:
function start() {
    cm.sendSimple("Pick an Item:\r\n\r\n"+cm.EquipAndCashList(cm.getC()));
}
function action(mode, type, selection) {
    cm.dispose();
    if (mode > 0) {
        cm.gainItem(selection, -1);
    }
}

Use the method Snipe posted. Or... if you want to make it a bit longer, use these methods.

NPCConversationManager.java
PHP:
public String EquipList(MapleClient c) {
        StringBuilder str = new StringBuilder();
           MapleInventory equip = c.getPlayer().getInventory(MapleInventoryType.EQUIP);
                List<String> stra = new LinkedList<String>();
                    for (IItem item : equip.list()) {
                        stra.add("#L"+item.getPosition()+"##v"+item.getItemId()+"##l");
                        }
                    for (String strb : stra) {
                str.append(strb);
            }
        return str.toString();
    }
	
public String CashList(MapleClient c) {
        StringBuilder str = new StringBuilder();
           MapleInventory cash = c.getPlayer().getInventory(MapleInventoryType.CASH);
                List<String> stra = new LinkedList<String>();
                    for (IItem item : cash.list()) {
                        stra.add("#L"+item.getPosition()+"##v"+item.getItemId()+"##l");
                        }
                    for (String strb : stra) {
                str.append(strb);
            }
        return str.toString();
    }

NPC
PHP:
var choice;
var chosenItem;
var type = [MapleInventoryType.EQUIP,MapleInventoryType.CASH];
status = -1;
function start() {
	cm.sendSimple("Which would you like to remove? \r\n #L0#Equip Item#l \r\n #L1#Cash Item#l");
}
function action(mode, type, selection){
    if (mode != 1) {
		cm.dispose();
		return;
	}else{
		status++;
	}
	if (status == 0){
		choice = selection;
		if (choice == 0){
			cm.sendSimple("Pick an Item:\r\n\r\n"+cm.EquipList(cm.getC()));
		}else if (choice == 1){
			cm.sendSimple("Pick an Item:\r\n\r\n"+cm.CashList(cm.getC()));
		}
	}else if (status == 1){
		/* 	not fully sure, but this should work for both since 
			selection will start at 0 regardless of which you chose */
		chosenItem = cm.getPlayer().getInventory(type[choice]).getItem(selection).getItemId(); // might be wrong due to type array
        cm.gainItem(chosenItem, -1);
		cm.dispose();
    }
}

Make sure you compile the methods properly, then @dispose yourself before testing. Also, read the comments I put. They may help you fix any errors that might occur.

Now look at the NPC script and the methods you posted and are claiming credit for.

The only thing added to your "released" script is what I've added in the comments of your script here..

PHP:
/*
Scripted by Yz, AAFS's DEVTeam. 2010-2011. All right reserved.
--------------------------------------------------------------
Feel free to re-distribute my work, but remember to give the proper credits. 

Credit to Shawn in Rz
*/

importPackage(Packages.client);

var status = 0;
var chosenItem;
var selected = 1; // added
var selectedType = -1; // added
var selectedItem = -1; // added
var choice;
status = -1; // repeat status variable? lol?

function start() {
    cm.sendSimple("Hey #b#h ##k. I'm #rInventory Cleaner#k. Well, do you think you need some #bcleaning#k? If yes, I will give u a small #rwarning#k. Once click, your item will be deleted. We won't #rrefund#k your item! So, choose wisely! \r\n#L0#Equip Cleaner#l \r\n#L1#Cash Cleaner#l");
}
function action(mode, type, selection){
    if (mode != 1) {
        cm.dispose();
        return;
    }else{
        status++;
    }
    if (status == 0){
        choice = selection;
        if (choice == 0){
            cm.sendSimple("Well, choose wisely! We won't refund your #rEquip#k if you selected wrong! \r\n\r\n"+cm.EquipList(cm.getClient()));
        }else if (choice == 1){
            cm.sendSimple("PWell, choose wisely! We won't refund your #rCash#k if you selected wrong!  \r\n\r\n"+cm.CashList(cm.getClient()));
        }
    }else if (status == 1){
        /*     not fully sure, but this should work for both since 
            selection will start at 0 regardless of which you chose */
      	selectedType = selection; // literally has no use at all in the script. Where do you have selectedType being used?
		var type = [MapleInventoryType.EQUIP,MapleInventoryType.CASH]; // moved this down to localized
            chosenItem = cm.getPlayer().getInventory(type[choice]).getItem(selection).getItemId();
            cm.gainItem(chosenItem, -1);
            cm.sendOk("Thank you for your garbage!");
            cm.dispose();
    }
}

The things you added do not affect anything at all with the script, because they play no factor at all. The only thing you've done that might have made a difference is moved the type array to a localized variable, instead of global. Other than that, selectedType, selectedItem and selected don't do anything because they aren't used anywhere in the script except being defined... So... how does mine not work?
 
Smoke & Fly
Loyal Member
Joined
Apr 21, 2008
Messages
1,190
Reaction score
76
Re: NPC that delete your items.

I'm sorry for the people who got credited on this.
 
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: NPC that delete your items.

@Shawn : Ahh sorry o.o Maybe I did forget about the import eh? @_@"

@Kars : Lol ><" Sorry if this troublesome those person o.o

//Edit : Close this topic if needed :) I din't expect much thanks, but finally I know at least 2 or 3 people took this away and use them o.o Ah well, mission done ^_^"
 
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
Re: NPC that delete your items.

I guess you can improve it by enabling the user to type in the item id and the npc will just search for it in your inventory and remove it.
 
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: NPC that delete your items.

@yenpooh o.o I don't think this is a good idea, because the NPC were for player, so they don't have those item id @_@"
 
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
Re: NPC that delete your items.

You can give them gm handbook or put @search command for them <3 this will be an easier method as you do not need to click one by one to delete them. Lols
 
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: NPC that delete your items.

o.o But they will need to type 1 by 1 to delete them now lol..
 
Custom Title Activated
Loyal Member
Joined
Aug 21, 2009
Messages
1,149
Reaction score
598
Re: NPC that delete your items.

Yeah, yenpooh idea is terrible.

Also, what SuperLol said doesn't apply in here at all. He is right, you must remove from slot, not by ID. But this only matters for merchants that sells in bundles, that doesn't apply in here at all, because you will ends up removing exactly the same item you wanted to. Well, the only way this could apply, is if the user have some cash items with the same ID, but he only wants to remove the one with the most quantity and left the one with the least (But really, barely going to happen).
 
Joined
Jun 5, 2010
Messages
567
Reaction score
598
Re: NPC that delete your items.

Yeah, yenpooh idea is terrible.

Also, what SuperLol said doesn't apply in here at all. He is right, you must remove from slot, not by ID. But this only matters for merchants that sells in bundles, that doesn't apply in here at all, because you will ends up removing exactly the same item you wanted to. Well, the only way this could apply, is if the user have some cash items with the same ID, but he only wants to remove the one with the most quantity and left the one with the least (But really, barely going to happen).

It also matters for equips.
Say you have a 10000 attack sword and a 15 attack sword and a 25000 attack sword. You want to remove the 15 attack sword, but the code currently deletes the first one in the inventory list (not slot btw) so it may remove the wrong one.
 
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: NPC that delete your items.

@XxOsirisxX : Thanks! I understand now ^_^" Increase my knowledge much <3 Thanks again ~ ;)

---------- Post added at 11:40 AM ---------- Previous post was at 11:39 AM ----------

It also matters for equips.
Say you have a 10000 attack sword and a 15 attack sword and a 25000 attack sword. You want to remove the 15 attack sword, but the code currently deletes the first one in the inventory list (not slot btw) so it may remove the wrong one.

But we can't make it show the stats in the NPC right? o.o
 
Custom Title Activated
Loyal Member
Joined
Aug 21, 2009
Messages
1,149
Reaction score
598
Re: NPC that delete your items.

@XxOsirisxX : Thanks! I understand now ^_^" Increase my knowledge much <3 Thanks again ~ ;)

---------- Post added at 11:40 AM ---------- Previous post was at 11:39 AM ----------



But we can't make it show the stats in the NPC right? o.o

Yeah, SuperLol is right lol, I never thought about that one. :p
 
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: NPC that delete your items.

Yeah, SuperLol is right lol, I never thought about that one. :p

But there is a way to prevent this case?
Its possible to show the item stats in NPC? o.o
Like every time we move our mouse to an Equip and it appear those details? :mellow:
 
Custom Title Activated
Loyal Member
Joined
Aug 21, 2009
Messages
1,149
Reaction score
598
Re: NPC that delete your items.

But there is a way to prevent this case?
Its possible to show the item stats in NPC? o.o
Like every time we move our mouse to an Equip and it appear those details? :mellow:

What can I say...

When you do that over a NPC it's always using "#i" <ItemId> "#", so the client reads from WZ and retrieve the item image, for equips case, it also retrieve the default stats. I don't thinks you can do this using the client features... I thinks you must have to do this manually :/.
 
Back
Top