Remove custom NPC script: Donation Box bulk selling
This commit is contained in:
@@ -19,54 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
/* NPC: Donation Box (9000041)
|
/* NPC: Donation Box (9000041)
|
||||||
Victoria Road : Henesys
|
Victoria Road : Henesys
|
||||||
|
|
||||||
NPC Bazaar:
|
|
||||||
* @author Ronan Lana
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var options = ["EQUIP", "USE", "SET-UP", "ETC"];
|
|
||||||
var name;
|
|
||||||
var status;
|
|
||||||
var selectedType = 0;
|
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
status = -1;
|
|
||||||
action(1, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function action(mode, type, selection) {
|
|
||||||
status++;
|
|
||||||
if (mode != 1) {
|
|
||||||
cm.dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == 0) {
|
|
||||||
const YamlConfig = Java.type('config.YamlConfig');
|
|
||||||
if (!YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) {
|
|
||||||
cm.sendOk("The medal ranking system is currently unavailable...");
|
cm.sendOk("The medal ranking system is currently unavailable...");
|
||||||
cm.dispose();
|
cm.dispose();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var selStr = "Hello, I am the #bBazaar NPC#k! Sell to me any item on your inventory you don't need. #rWARNING#b: Make sure you have your items ready to sell at the slots #rAFTER#b the item you have selected to sell.#k Any items #bunder#k the item selected will be sold thoroughly.";
|
|
||||||
for (var i = 0; i < options.length; i++) {
|
|
||||||
selStr += "\r\n#L" + i + "# " + options[i] + "#l";
|
|
||||||
}
|
|
||||||
cm.sendSimple(selStr);
|
|
||||||
} else if (status == 1) {
|
|
||||||
selectedType = selection;
|
|
||||||
cm.sendGetText("From what item on your #r" + options[selectedType] + "#k inventory do you want to start the transaction?");
|
|
||||||
} else if (status == 2) {
|
|
||||||
name = cm.getText();
|
|
||||||
var res = cm.getPlayer().sellAllItemsFromName(selectedType + 1, name);
|
|
||||||
|
|
||||||
if (res > -1) {
|
|
||||||
cm.sendOk("Transaction complete! You received #r" + cm.numberWithCommas(res) + " mesos#k from this action.");
|
|
||||||
} else {
|
|
||||||
cm.sendOk("There is no #b'" + name + "'#k in your #b" + options[selectedType] + "#k inventory!");
|
|
||||||
}
|
|
||||||
|
|
||||||
cm.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -9192,87 +9192,6 @@ public class Character extends AbstractCharacterObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int sellAllItemsFromName(byte invTypeId, String name) {
|
|
||||||
//player decides from which inventory items should be sold.
|
|
||||||
InventoryType type = InventoryType.getByType(invTypeId);
|
|
||||||
|
|
||||||
Inventory inv = getInventory(type);
|
|
||||||
inv.lockInventory();
|
|
||||||
try {
|
|
||||||
Item it = inv.findByName(name);
|
|
||||||
if (it == null) {
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
|
||||||
return (sellAllItemsFromPosition(ii, type, it.getPosition()));
|
|
||||||
} finally {
|
|
||||||
inv.unlockInventory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int sellAllItemsFromPosition(ItemInformationProvider ii, InventoryType type, short pos) {
|
|
||||||
int mesoGain = 0;
|
|
||||||
|
|
||||||
Inventory inv = getInventory(type);
|
|
||||||
inv.lockInventory();
|
|
||||||
try {
|
|
||||||
for (short i = pos; i <= inv.getSlotLimit(); i++) {
|
|
||||||
if (inv.getItem(i) == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
mesoGain += standaloneSell(getClient(), ii, type, i, inv.getItem(i).getQuantity());
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
inv.unlockInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (mesoGain);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int standaloneSell(Client c, ItemInformationProvider ii, InventoryType type, short slot, short quantity) {
|
|
||||||
if (quantity == 0xFFFF || quantity == 0) {
|
|
||||||
quantity = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Inventory inv = getInventory(type);
|
|
||||||
inv.lockInventory();
|
|
||||||
try {
|
|
||||||
Item item = inv.getItem(slot);
|
|
||||||
if (item == null) { //Basic check
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int itemid = item.getItemId();
|
|
||||||
if (ItemConstants.isRechargeable(itemid)) {
|
|
||||||
quantity = item.getQuantity();
|
|
||||||
} else if (ItemId.isWeddingToken(itemid) || ItemId.isWeddingRing(itemid)) {
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (quantity < 0) {
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
short iQuant = item.getQuantity();
|
|
||||||
if (iQuant == 0xFFFF) {
|
|
||||||
iQuant = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (quantity <= iQuant && iQuant > 0) {
|
|
||||||
InventoryManipulator.removeFromSlot(c, type, (byte) slot, quantity, false);
|
|
||||||
int recvMesos = ii.getPrice(itemid, quantity);
|
|
||||||
if (recvMesos > 0) {
|
|
||||||
gainMeso(recvMesos, false);
|
|
||||||
return (recvMesos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
} finally {
|
|
||||||
inv.unlockInventory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasMergeFlag(Item item) {
|
private static boolean hasMergeFlag(Item item) {
|
||||||
return (item.getFlag() & ItemConstants.MERGE_UNTRADEABLE) == ItemConstants.MERGE_UNTRADEABLE;
|
return (item.getFlag() & ItemConstants.MERGE_UNTRADEABLE) == ItemConstants.MERGE_UNTRADEABLE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user