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

  • 0
Posted

L2ItemInstance coinItem = player.getInventory().getItemByItemId(3481);
if (coinItem == null || coinItem.getCount() < 200)

 

Your code is wrong and not optimized. I lock.

Guest
This topic is now closed to further replies.


  • Posts

    • ➡ Discount for your purchase: APRIL (10% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
    • ➡ Discount for your purchase: APRIL (10% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
    • Hi people, someone has to sharing a client for Lineage 2 Shinemaker?. I found a few but are not working very well. Thanks
    • Grab a proper launcher for Your server - update files whenever You need
    • Dear players, 19.04 at 06:00 server time, the Airin server will be updated to Chronicle 2. - The x2 updater will be disabled on April 18, 2025, at 23:59 and will become available again during the update. - Server rates will be increased to x2.25; - The siege of Innadril will take place on April 27 at 16:00 server time; - Bonus Start will begin after the restart! Characters created after April 16, 00:00 will receive rewards.   You can download the full client for Airin C2 from the following link.  Do not run the updater until tomorrow's update. 
  • Topics

×
×
  • Create New...