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();
}
/*
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();
}
}
@Expedia : Shawn one don't work for some reason o.o But he did help me a lots with the script, so credit ShawnAnd Moongra's one I can't make it work o.o Idk why. the ArrayList function undefined @_@
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.
/*
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();
}
}
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.
@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.
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: