Jump to content

Interlude Auction Shop


An4rchy

Recommended Posts

Hello.

 

This is an auction shop I made some time ago for aCis.

 

How it works: Players can add items for sale at the auction shop at the price they want. Then, even if they are offline other players can buy the items and they will get the rewards(the price they put). Enchant of items stays, augmented items are not sellable.

There is a searching system(case sensitive) and a paging system.

 

I have NOT tested this code on a live server (only local testing), but I remember adding a shittone of checks to avoid any exploits. I recommend you test it out well before using it.

 

You need to make an npc with id 65529 and type L2AuctionManager.

 

Code: http://pastebin.com/QqY6LGWV

Update - Replace AuctionTable and L2AuctionManagerInstance with these:

AuctionTable (update: the bug mentioned in the replies fixed): http://pastebin.com/vVPhiXKY

L2AuctionManagerInstance: http://pastebin.com/h8LFuesV

 

Some pictures:

 

(Please excuse my html designs..)

 

2ikpbbm.jpgk9c9bk.jpgsdfx4l.jpg2qsb5ab.jpg

 

24n35s2.jpg2cmniwg.jpgrqwuq1.jpg

Edited by An4rchy
  • Upvote 3
Link to comment
Share on other sites

- You will end with instant ConcurrentException on multiplayer scenario. items list should be stored on a concurrenthashmap (avoid copyonwritearraylist, terrible performance).

- string concat in a for loop is the devil (while regular concat is transformed into StringBuilder, in a for loop it doesn't), use StringUtil.append and a StringBuilder.

- all your paging systems can be replaced for existing and cleaner scenarios, such as Bookmark and SchemeBuffer (using MathUtil.countPagesNumber).

- Use try-with-ressources statement (jdk 7) to avoid to bother with ressource close (eliminate an eventual miss and drop the finally block).

- HTM on htm side, to make code more readable/maintainable.

- There could have a bid system, if price is 0 (or you add a checking case).

- Adena should be formatted using StringUtil.formatNumber

- If an item is listed for a very long time, it should be moved back on player inventory (to avoid the list being longer and longer) - One week default.

- server should take a fee, both to set an item (avoid to flood the market with single soulshots) and once the item is sold (to recycle some adena, economy lesson).

- Some items shouldn't be able to be sold, or at least not with low amount (I think about soulshots, arrows) to limit the number of objects (idiots can easily make your server a burden spamming 1 soulshot selling, making the whole system lag if they find a way to automatize it)

- Writting "Cost:" and "Item:" is a waste of space.

Edited by Tryskell
Link to comment
Share on other sites

- You will end with instant ConcurrentException on multiplayer scenario. items list should be stored on a concurrenthashmap (avoid copyonwritearraylist, terrible performance).

- string concat in a for loop is the devil (while regular concat is transformed into StringBuilder, in a for loop it doesn't), use StringUtil.append and a StringBuilder.

- all your paging systems can be replaced for existing and cleaner scenarios, such as Bookmark and SchemeBuffer (using MathUtil.countPagesNumber).

- Use try-with-ressources statement (jdk 7) to avoid to bother with ressource close (eliminate an eventual miss and drop the finally block).

- HTM on htm side, to make code more readable/maintainable.

- There could have a bid system, if price is 0 (or you add a checking case).

- Adena should be formatted using StringUtil.formatNumber

- If an item is listed for a very long time, it should be moved back on player inventory (to avoid the list being longer and longer)

- server should take a fee, both to set an item (avoid to flood the market) and once the item is sold (to recycle some adena, economy lesson)

- I thought about that to be honest when I was uploading this share, but it's been 2+ years since I made it. Gonna update it.

- I don't see what could go wrong with that to be honest..

- The paging system was added after the original npc was created(since I ended with critical errors on many items) so it's really messy and to be honest I can't be bothered to update it.

- I know, idk why I did it that way when I was making it to be honest. Gonna be on next update.

- I always prefer htmls on htm side but in this case most of the htm is generated server-side so it would be pointless having 5 lines of htm code in htm side when the htm is way longer.

- Extra feature, can't be bothered to add it.

- Gonna be on next update, thanks.

- Extra feature, can't be bothered to add it.

- Extra feature, can't be bothered to add it.

 

Thanks for the feedback.

Link to comment
Share on other sites

Just wait the update. To be honest was looking for something like this tho :D
Had an auction system before but no idea where it vanished.

+1 for your recent shares.

Edited by big man bill
Link to comment
Share on other sites

update

  • L2AuctionManagerInstance.java
        ArrayList<ItemInstance> temp = new ArrayList<>();
        for (ItemInstance item : player.getInventory().getItems())
        {
-           if (item.getItemId() != 57 && item.isTradable())
+           if (item.getItemId() != 57 && item.isTradable() && !item.isEquipped())
Link to comment
Share on other sites

Yeah this bug was caused because I changed from a list to a map, I forgot to change items.remove(item); to items.remove(item.getAuctionId()); on removeItem() method.

 

Thanks for the report, fixed and topic updated.

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...

Its interesting because this code works perfectly but when im trying it in game everything working exclude method "showAuction" do not show any items but in block "My Items" or "Add Items" its working normally any suggestion? THX :)

 

// edit

 

I only delete Icons because i dont have table in DB with items icon that cant be a problem I'm sure :)

Edited by TheMark147
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Posts

    • L2 Insignia High Five 20x MID SERVER FOCUSED ON OLYMPIAD | PVP | AUTOFARM       OPEN BETA TEST SERVER 3 MAY 2024   GRAND OPENING 10 MAY 2024    Rates: 📜 XP/SP 20x | Spoil 15x | Drop 10x | Adena 10x 📜     Server Features: 🔥 No Olf-T Shirt, No big over-enchant, No over-power Donate 🔥 🔥 VIP Gold Color Chat, Unique Olympiad Extra Points Engine, GvG Event 🔥 🔥 Auto-Farm, LoA and DV scheduled PvP Zone, Calendar Daily Reward 🔥 🔥 Castle Instance, Solo Instance, PvP Solo Rift, Dress me system, Adena Boxes 🔥        Website: https://www.l2insignia.com  Discord: https://discord.com/invite/yEgsrHn2hQ      
    • I am selling the essence project which includes versions 388 and 439 that have been running for over 2 years or (447 as custom PVP like Pride). I have a test server for you to test them out. If you are really interested in it then contact my seller at discord: kiwi7106. Price: 4000 Euro P/s: This is a project that I have spent a lot of money and time developing, so if you are not interested in it, please get out of this topic, thank you. P/s 2: If you find the price too expensive, it's best to skip this article and find another project and don't comment negatively on my topic, thank you.
    • Someone ask me for this, it should work on any client that has Kamael race, preview:     Installation - there are two ways to install depending on how you want to use it:   Method 1: If you want to completely replace the original, do:   Copy all lines from your armorgrp to Notepad++, press Ctrl+H, check the "match whole word" option and replace:   kamael.Mkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_MKamael_m001_w_ad00   Then replace:   MKamael.Mkamael_m000_t00_w   by:   AvengersKamaelWings.MKamael_m001_t00_w   Now repeat the same process with the female, replace:   kamael.Fkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_FKamael_m001_w_ad00   Then replace:   FKamael.Fkamael_m000_t00_w   by:   AvengersKamaelWings.FKamael_m001_t00_w   You're done, paste everything back into File Edit and save!   Method 2: If you only want to replace in specific sets, execute the above process only on the armorgrp of those sets.   Repack by: AvengersTeamBr Password: LadrãoDeFrango      
  • Topics

×
×
  • Create New...