Jump to content
  • 0

[Help]A Bit.


Question

Posted

Hi mates I need some help

I try my players when add a new sub village master take from them 200 coin's...i manage to do that: when a player have 0 coins the master work just i want but when player have at least 1 coin village master print "message incorrect item count" and he add the sub class here is the code any help will be appreciate..

 

               if (Config.SUBCLASS_WITH_ITEM_AND_NO_QUEST)
                     {
                        L2ItemInstance coinItem = player.getInventory().getItemByItemId(3481);
                        if (coinItem == null)
                        {
                           player.sendMessage("Sorry you must give me \"200 Coin's\" for each subclass and you dont have.");
                           player.setLocked(false);
                      return;
                        }                     
                        if (allowAddition)
                        {
                           player.destroyItemByItemId("Quest", 3481, 200, this, true);
                        }
                     }

5 answers to this question

Recommended Posts

  • 0
Posted

When you delete an object it is supposed to return something. Use that returned value wisely and you won't have problem.

 

destroyItem() != null means the operation was successful, otherwise it means it couldn't be made (no items or incorrect items).

 

Which means from all your checks, you simply need to destroy the item, if it returns something it was ok, else you can send message. The good stuff is you can make the operation and the check in same time.

 

// Destroy item
if (player.destroyItem(param, param param, ...) == null)
{
      player.sendMessage("blabla or send a sysstring it's better");
      return;
}

// Regular code if object has been destroyed goes here.

 

If Frozen hasn't such method, or method returns nothing, then I'm sorry for you and you have to use coinItem.getCount() for the number check then destroy the item from the method Frozen makes to destroy items (which I got no clue).

  • 0
Posted

When you delete an object it is supposed to return something. Use that returned value wisely and you won't have problem.

 

destroyItem() != null means the operation was successful, otherwise it means it couldn't be made (no items or incorrect items).

 

Which means from all your checks, you simply need to destroy the item, if it returns something it was ok, else you can send message. The good stuff is you can make the operation and the check in same time.

 

// Destroy item
if (player.destroyItem(param, param param, ...) == null)
{
      player.sendMessage("blabla or send a sysstring it's better");
      return;
}

// Regular code if object has been destroyed goes here.

 

If Frozen hasn't such method, or method returns nothing, then I'm sorry for you and you have to use coinItem.getCount() for the number check then destroy the item from the method Frozen makes to destroy items (which I got no clue).

 

Thanks!! for your help i fix it like this

 

  if (coinItem == null && player.getInventory().getItemByItemId(3481).getCount() <= 199)

 

Problem solved someone lock it

Guest
This topic is now closed to further replies.


  • Posts

    • Legends never truly die. They just wait for the right time to return. For over a decade, Vindication (aka Noobwars) held the crown as the longest-running and most legendary Greek private server. We built a home, created unbreakable bonds, and lived through thousands of hours of epic PvP, endless castle sieges, and unforgettable memories. Lately, others have tried to use our name to mimic what we built. But you can't copy soul, and you can't fake history. As the original Administrator, I am proud to tell you that the waiting is finally over. The true architect is back to bring you the ultimate Interlude experience. We are returning to revive that pure, old-school Lineage 2 nostalgia—the way it was always meant to be played. Just the authentic Vindication vibe we all fell in love with. Gather your old comrades, prepare your clans, and get ready to step back into the world of Interlude where it all started.   The original era begins again. Welcome home. GM*absolut*   Server Rates VINDICATION CLASSIC INTERLUDE x4  EXP/SP: x4  Adena: x2  Drop: x3  Spoil: x3  Seal Stones: x2  Raid Boss EXP/SP: x2  Raid Boss Drop: x1  Epic Boss Drop: x1  Manor: x1  Safe Enchant: +3  Max Enchant: +20  Normal Scroll Chance: Retail  Blessed Scroll Chance: Retail   🚀 Nostalgia Meets Next-Gen Technology We are not just bringing back the server you loved; we are upgrading it for the modern era. For the first time ever, we have integrated DLSS 5 into our Interlude client. Experience the classic gameplay you miss with ground-breaking performance     More info @ sites   Website:    http://www.vindication.gr Discord:       https://discord.gg/BVtgYvjyk6 Facebook:  https://www.facebook.com/groups/lineage2gr
    • maybe you can try L2jBayev Chronicle 4 project.
    • I think that bastard has been doing this for a long time, taking advantage of his reputation. 
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..