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.


  • Posts

    • Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11 Telegram : https://t.me/ultrastore1 Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11
    • L2 ArenaWar: Low Rate PvP Server with Free Buffs & Autofarm [PVP]⚔️ [Free]🆓 Classic Interlude with  3x XP rates! Free starter pack(no grade) to kickstart your adventure! Autofarm for convenient grinding! Free buffs to keep you fighting fit! (2 job buffs) No experience loss on death! (Except with Karma) Clear Karma system to keep things fair! ⚖️ Active community of 800-1k players! Join our Discord to learn more! >> Discord <<     Server website: https://l2arenawar.com/en/    
    • This is dedication! 2 years working on a problem. Congratulations!
    • You indeed have to save player position over Enterworld to properly clean it up later (if you don't, even trying to delete packet content would eventually keep it up), that's what we do with debug packet (which is a reusable Map of ExServerPrimitive packets) on aCis.   It doesn't solve the FPS stuttering - more you draw/delete lines, more your client becomes laggy. It's like if client wasn't deleting drawn points/lines properly, but instead simply hide them and redrawn content above.   If you got a solution, I would happy to integrate it.   You should check aCis#Player _debug packet integration, it allows very big amount of lines/points to be drawn, it is also reusable.   https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java?ref_type=heads https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java?ref_type=heads  
    • we sell website templates, make websites to order. Great selection at very good prices. My contacts discord : advert1231 telegram : https://t.me/ggwpins  
  • Topics

×
×
  • Create New...