Jump to content

Recommended Posts

Posted (edited)

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
Posted (edited)

- 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
Posted

- 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.

Posted (edited)

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
Posted

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())
Posted

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.

  • 2 months later...
  • 2 weeks later...
Posted (edited)

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
Posted

Your own auctions are not listed.

 

Ohhh you have right I'm idiot (I'm trying this NPC only with one character there was fault) THX bro :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Provide proofs not providing any kind of proofs i will just issue warnings
    • For the odbc you have to run the Instalador.exe and click crear dsn, but you have to rename them so the lin2clancomm.dsn for example becomes l2c4_lin2clancomm but also check if the file inside has as database value the correct file name, about the client i also wanted a clean client because i had a problem with the monsters because the character didn't have collision with the monsters and he was running through them but i fixed it with files from a normal interlude client, also my client is now c3 😛 i changed the maps, staticmeshes, systextures so now i do not have the fortresses at antharas lair for example but i also have the c3 sounds and login screen. Where is @GX-Ext
    • I really wonder if they launched the server without testing it even once. All players are creating new characters and transferring the level 20 reward to their main ones. It seems banning people is much easier than sending them a direct message in-game. If you can’t do your job properly, get in touch with people who can help you. I made 17 million in 10 minutes on a 1x Adena rate server and got an Icarus weapon. My suggestion to you — as it's written on the character you banned — is to wipe the server and run a proper OBT. Good luck with your time as administrators; although it doesn't look like it will last very long.  
    • all the reports vanished into thin air  
    • 🔥L2 INTERPRIDE - Pride Style  OPENING THIS NOVEMBER! 🔥  ✅ Grand Opening - November 15th! ✅ ❤️ Open Beta - October 08th! ❤️  🩵  The most up-to date client on the market! ▶️  Retail Pride Style Interlude with the new Client! 💡Discord: https://discord.gg/l2interpride 🌍 General Information Client: Interlude Type: Custom PvP Server Rates: High Rates Starting Level: 56 Balanced PvP Environment Unique PvP Enchant System PvP Synergy System: Support Classes earn PvP Score when assisting DDs in kills Toggle Skills → Now Passive Killing Spree: Every 25 kills grants Hero Aura + Hero Skills until death 🐉 Raid Boss System If you are within 1500 radius when a Raid Boss dies, you automatically receive 1 Raid Boss Chest in your inventory! 💫 Join the Battle ⚔️ Experience modern PvP gameplay on a classic Interlude foundation! 🔥 Build your power. Earn glory. Dominate Aden. 🧙 Custom Items Armors: 🛡️ Tier 1: Dread ⚔️ Tier 2: Titanium 👑 Tier 3: Pride Weapons: 🔱 Tier 1: Unique (PvP / PvE) ⚔️ Tier 2: Pride 💀 Tier 3: Abyssal Accessories: Up to 30 custom accessories with unique stats Legendary Dyes: +5 / -2 Belts: Various special stats ⚔️ Custom PvP Skills PvPs Name Color Reward Skill 500 Blue Firework CP Heal +800 1000 Violet Firework Cleanse 1500 Green Blessed Body 2000 Yellow MP Recharge 2500 Light Blue Special Focus 3000 Orange Death Whisper Debuff 3500 Dark Purple Might 4000 Red Empower 4500 Red Increase Weight Debuff 5000 Red Wind Walk 6000 Red Berserker Spirit 7000 Red Recall NPC 🛒 Shops & NPCs Item Store: Up to A/S grade, Potions, Consumables & more Mysterious Merchant: Custom Armors, Weapons, Accessories NPC Buffer: All Buffs + Scheme System Class Master: Free Class Change 🔥 Enchant System Safe Enchant: +7 Max Enchant: +25 Weapon Rate: Custom (higher enchant = lower rate) Armor Rate: Custom (higher enchant = lower rate) Jewel Rate: Custom (higher enchant = lower rate) ⚙️ Rates Experience: x5000 Skill Points: x5000 Drop Rate: x1 Adena: x500 🏆 Events Team vs Team (TvT) Capture the Flag (CTF) Death Match Castle Siege Hunting Grounds URF TvT 💎 Custom Features ALT + Left Click → Remove selected Buff ALT + F → Teleport System Shift + Left Click → View Monster Droplist
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock