Jump to content
  • 0

[Help]A Bit.


sakisd

Question

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);
                        }
                     }

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

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

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

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

 

Your code is wrong and not optimized. I lock.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • 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