HARDECORE Posted November 19, 2019 Posted November 19, 2019 how do i get a player to sell anything in npc for 1 adena? Note: There is the option to go item by item and set the price to 1. but that would bring me a lot of work, in the code there is an easier way? long totalPrice = 0; // Proceed the sell for (UniqueItemHolder i : _items) { L2ItemInstance item = player.checkItemManipulation(i.getObjectId(), i.getCount(), "sell"); if ((item == null) || (!item.isSellable())) { continue; } long price = item.getReferencePrice() / 100; totalPrice += price * i.getCount(); if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA)) { Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + MAX_ADENA + " adena worth of goods.", Config.DEFAULT_PUNISH); return; } if (Config.ALLOW_REFUND) { item = player.getInventory().transferItem("Sell", i.getObjectId(), i.getCount(), player.getRefund(), player, merchant); } else { item = player.getInventory().destroyItem("Sell", i.getObjectId(), i.getCount(), player, merchant); } } player.addAdena("Sell", totalPrice, merchant, false); // Update current load as well StatusUpdate su = player.makeStatusUpdate(StatusUpdate.CUR_LOAD); player.sendPacket(su); player.sendPacket(new ExBuySellList(player, taxRate, true)); } Quote
0 cyta5 Posted November 20, 2019 Posted November 20, 2019 i think you can change it from database... Quote
0 Nightw0lf Posted November 20, 2019 Posted November 20, 2019 (edited) change this player.addAdena("Sell", totalPrice, merchant, false); to player.addAdena("Sell", 1, merchant, false); the best solution is to write for all items sold that cost is 1 adena in the window so you wont confuze players Edited November 20, 2019 by Nightw0lf Quote
0 HARDECORE Posted November 20, 2019 Author Posted November 20, 2019 On 11/20/2019 at 6:46 AM, Nightw0lf said: change this player.addAdena("Sell", totalPrice, merchant, false); to player.addAdena("Sell", 1, merchant, false); the best solution is to write for all items sold that cost is 1 adena in the window so you wont confuze players Expand did not work :( Quote
0 HARDECORE Posted November 20, 2019 Author Posted November 20, 2019 On 11/20/2019 at 5:35 AM, cyta5 said: i think you can change it from database... Expand All my items are in XML. Quote
0 L2 TokTil Posted November 20, 2019 Posted November 20, 2019 On 11/19/2019 at 10:59 PM, HARDECORE said: long price = item.getReferencePrice() / 100; Expand change that to long price = 1; Quote
0 Nightw0lf Posted November 20, 2019 Posted November 20, 2019 On 11/20/2019 at 12:46 PM, L2 TokTil said: change that to long price = 1; Expand Quote
0 melron Posted November 20, 2019 Posted November 20, 2019 Nightw0lf's answer is the correct one. You just need to edit the visual sell price too in order to work perfect. SellList.java - writeD(item.getItem().getReferencePrice() / 2); + writeD(1); RequestSellItem.java - player.addAdena("Sell", totalPrice, merchant, false); + player.addAdena("Sell", 1, merchant, false); Quote
0 L2 TokTil Posted November 20, 2019 Posted November 20, 2019 On 11/20/2019 at 1:15 PM, Nightw0lf said: Expand when you change total price to 1, it worse because all item stackable example (11 piece item) is still 1 adena in total, if we want to antisipation adena population we can change price per item to this totalPrice = SafeMath.addAndCheck(totalPrice, SafeMath.mulAndCheck((item.getReferencePrice() / "your rate setting"), count) / 2); <= this code from my pack so maybe diff from another pack or item.getReferencePrice(), count)/ "your rate setting" *"your rate setting" = like item drop rate so all item still have uniqe price not 1 adena, to antisipation player to make trash in every town floor <= still can be anticipation to make all item drop by player destroy by xx sec like drop by monster #Still newbee, correct me if im wrong Quote
0 Nightw0lf Posted November 21, 2019 Posted November 21, 2019 On 11/20/2019 at 10:19 PM, L2 TokTil said: when you change total price to 1, it worse because all item stackable example (11 piece item) is still 1 adena in total, if we want to antisipation adena population we can change price per item to this totalPrice = SafeMath.addAndCheck(totalPrice, SafeMath.mulAndCheck((item.getReferencePrice() / "your rate setting"), count) / 2); <= this code from my pack so maybe diff from another pack or item.getReferencePrice(), count)/ "your rate setting" *"your rate setting" = like item drop rate so all item still have uniqe price not 1 adena, to antisipation player to make trash in every town floor <= still can be anticipation to make all item drop by player destroy by xx sec like drop by monster #Still newbee, correct me if im wrong Expand On 11/20/2019 at 6:46 AM, Nightw0lf said: change this player.addAdena("Sell", totalPrice, merchant, false); to player.addAdena("Sell", 1, merchant, false); the best solution is to write for all items sold that cost is 1 adena in the window so you wont confuze players Expand Quote
0 HARDECORE Posted November 21, 2019 Author Posted November 21, 2019 On 11/20/2019 at 4:29 PM, melron said: Nightw0lf's answer is the correct one. You just need to edit the visual sell price too in order to work perfect. SellList.java - writeD(item.getItem().getReferencePrice() / 2); + writeD(1); RequestSellItem.java - player.addAdena("Sell", totalPrice, merchant, false); + player.addAdena("Sell", 1, merchant, false); Expand Hello. first of all thank you so much for helping me. In my SellList.java there is no such line that you have replaced. take a look look at the print. Quote
0 tazerman2 Posted November 22, 2019 Posted November 22, 2019 (edited) have this in SellList.java writeQ(item.getItem().getReferencePrice() / 2); change it writeQ(1); Edited November 22, 2019 by tazerman2 Quote
0 HARDECORE Posted November 22, 2019 Author Posted November 22, 2019 all right. but can you show for the player that will be sold for 1 adena? why the modification works. but "player" will think it will sell for the price that is shown and is not. see the video: https://www.youtube.com/watch?v=kqQXrmU82ao Quote
0 tazerman2 Posted November 22, 2019 Posted November 22, 2019 make post in pastebin selllist.java and requestsellitem.java for fix that you need Quote
0 HARDECORE Posted November 22, 2019 Author Posted November 22, 2019 On 11/22/2019 at 7:12 PM, tazerman2 said: make post in pastebin selllist.java and requestsellitem.java for fix that you need Expand ok Here it is: https://pastebin.com/3RKSvWca Quote
0 filimon Posted November 22, 2019 Posted November 22, 2019 long price = item.getReferencePrice() / 1; Quote
Question
HARDECORE
how do i get a player to sell anything in npc for 1 adena?
Note: There is the option to go item by item and set the price to 1. but that would bring me a lot of work, in the code there is an easier way?
long totalPrice = 0; // Proceed the sell for (UniqueItemHolder i : _items) { L2ItemInstance item = player.checkItemManipulation(i.getObjectId(), i.getCount(), "sell"); if ((item == null) || (!item.isSellable())) { continue; } long price = item.getReferencePrice() / 100; totalPrice += price * i.getCount(); if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA)) { Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + MAX_ADENA + " adena worth of goods.", Config.DEFAULT_PUNISH); return; } if (Config.ALLOW_REFUND) { item = player.getInventory().transferItem("Sell", i.getObjectId(), i.getCount(), player.getRefund(), player, merchant); } else { item = player.getInventory().destroyItem("Sell", i.getObjectId(), i.getCount(), player, merchant); } } player.addAdena("Sell", totalPrice, merchant, false); // Update current load as well StatusUpdate su = player.makeStatusUpdate(StatusUpdate.CUR_LOAD); player.sendPacket(su); player.sendPacket(new ExBuySellList(player, taxRate, true)); }
20 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.