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

    • QR code recognition has been added when logging into Google services that include this request. Instructions have been added to product descriptions; this only works for items that include this information.
    • Server owners, Top.MaxCheaters.com is now live and accepting Lineage 2 server listings. There is no voting, no rankings manipulation, and no paid advantages. Visibility is clean and equal, and early listings naturally appear at the top while the platform grows. If your server is active, it should already be listed. Submit here  https://Top.MaxCheaters.com This platform is part of the MaxCheaters.com network and is being built as a long-term reference point for the Lineage 2 community. — MaxCheaters.com Team
    • Server owners, Top.MaxCheaters.com is now live and accepting Lineage 2 server listings. There is no voting, no rankings manipulation, and no paid advantages. Visibility is clean and equal, and early listings naturally appear at the top while the platform grows. If your server is active, it should already be listed. Submit here  https://Top.MaxCheaters.com This platform is part of the MaxCheaters.com network and is being built as a long-term reference point for the Lineage 2 community. — MaxCheaters.com Team
    • Server owners, Top.MaxCheaters.com is now live and accepting Lineage 2 server listings. There is no voting, no rankings manipulation, and no paid advantages. Visibility is clean and equal, and early listings naturally appear at the top while the platform grows. If your server is active, it should already be listed. Submit here  https://Top.MaxCheaters.com This platform is part of the MaxCheaters.com network and is being built as a long-term reference point for the Lineage 2 community. — MaxCheaters.com Team
    • Server owners, Top.MaxCheaters.com is now live and accepting Lineage 2 server listings. There is no voting, no rankings manipulation, and no paid advantages. Visibility is clean and equal, and early listings naturally appear at the top while the platform grows. If your server is active, it should already be listed. Submit here  https://Top.MaxCheaters.com This platform is part of the MaxCheaters.com network and is being built as a long-term reference point for the Lineage 2 community. — MaxCheaters.com Team
  • 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..