Jump to content
  • 0

Maximum 2 healers allowed in party


Question

Posted (edited)

Hello i try to make maximum 2 healers allowed in 1 party but im getting some problems maybe can someone help me ?

 

i added this lines to requestjoinparty but is not working properly

 

            if (target.getClassId().getId() == 97 && (party.getMembersCount() >= 2) ) 
                {
                    requestor.sendMessage("Maximum 2 healers are allowed in party !");
                    return;
                }

 

 

Edited by arm4729

5 answers to this question

Recommended Posts

  • 0
Posted (edited)

Your "party.getMembersCount() >= 2" condition is for the party overall.
You need to store the healers at-invite and remove them at-leave, so you know they are actually in the party.

 

filter(player -> player.getClassId() == 97).size()

 

or

 

Fast and ugly for the sake of L2J:

 

private static final List<Player> HEALER_LIST = new ArrayList<>();

 

If player.getClassId == 97:

HEALES_LIST.add(player);

HEALER_LIST.remove(player);

 

You can use the condition If HEALER_LIST.size() >= 2 to forbid an amount and you don't need to check getClassId, because you already checked that at add/remove.

 

You also got this: for (Player healer : HEALER_LIST)

So you can do stuff with the healer while being in the party.

 

Make the player to leave party while changing subclasses.

Edited by Trance
  • 0
Posted
37 minutes ago, Trance said:

Your "party.getMembersCount() >= 2" condition is for the party overall.
You need to store the healers at-invite and remove them at-leave, so you know they are actually in the party.

 

private static final List<Player> HEALER_LIST = new ArrayList<>();

 

If player.getClassId == 97:

HEALES_LIST.add(player);

HEALER_LIST.remove(player);

 

You can use the condition If HEALER_LIST.size() >= 2 to forbid an amount and you don't need to check getClassId, because you already checked that at add/remove.

 

You also got this: for (Player healer : HEALER_LIST)

So you can do stuff with the healer while being in the party.

 

Make the player to leave party while changing subclasses.

Your code is unnecessary.

 

@arm4729

 

if (party.getMembers().stream().filter(k -> k.getClassId() == ClassId.bishop).count() > 2)
{
	// Failed to add		
}

 

  • 0
Posted (edited)
17 minutes ago, EdithFinch said:

Your code is unnecessary.

 

@arm4729

 


if (party.getMembers().stream().filter(k -> k.getClassId() == ClassId.bishop).count() > 2)
{
	// Failed to add		
}

 

 

I included that as well, edited before your reply, I had a feeling someone would take it more seriously.

Edited by Trance
  • 0
Posted (edited)

very thank you guys !!

 

i only tried this 

 

            if (party.getMembers().stream().filter(k -> k.getClassId() == (ClassId.CARDINAL)).count() >= 2)

 

is working fine thx

Edited by arm4729
Guest
This topic is now closed to further replies.


  • Posts

    • L2 PEARL — OPEN BETA REWARDS   Join the L2 Pearl Open Beta and receive exclusive rewards for your participation. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OPEN BETA REWARDS   Players who participate in the Open Beta will receive: • One exclusive Open Beta Hat • 3 days of Premium Account ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ REWARD LIMIT   Rewards are limited to one reward per HWID. Each eligible hardware ID can receive the Open Beta reward only once. Multiple accounts connected to the same HWID will not receive additional rewards. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ The Open Beta begins on 2 October 2026.   Take part in the testing phase, help us improve the server and get ready for the official launch of the first season. Please note that all Open Beta progress will be wiped before the Grand Opening. The exclusive hat and the 3 days of Premium Account will be granted according to the Open Beta reward conditions. Grand Opening 9 October 2026   Join the Open Beta and secure your exclusive rewards. https://www.l2pearl.com https://discord.com/invite/l2pearl
    • 🛡️ Sguard — A New Version Is Coming in 2026 Hello everyone — clients, server owners, and fellow developers! We have been working on a new version of Sguard, with release planned for the end of 2026. AI-assisted development has helped us work faster, reduce repetitive tasks, and spend more time on implementation and testing. Our team remains responsible for the engineering and the results. The goal is straightforward: better quality, dependable operation, and more affordable pricing. We believe the L2 protection market needs renewed attention — ongoing development, responsive support, and closer cooperation with server administrators. That is the direction we are taking with Sguard. Early Testing Applications Are Open We are looking for server administrators willing to test the new version, report issues, and share practical feedback. 🎁 The first testers will receive free licenses. If you would like to participate, contact us with: Your server’s chronicles and protocol. A brief description of your setup. Whether you can provide a test environment. This is a preliminary announcement. We will share specific features, compatibility details, and testing dates as they are ready. Thank you for your continued support. We look forward to building the next version of Sguard with your feedback. ✉️ APPLY FOR TESTING — @L2scripts Send us a message with “Sguard Test” and tell us about your server.
    • 🚀 End-of-month restock! Upgrade your personal Gmail to 5TB + Gemini Pro instantly with 100% private automated delivery! 🎃 Fresh October Batch Active! Upgrade your personal Gmail to 5TB + Gemini Pro Advanced (12-18M) instantly. 100% private, automated delivery 24/7!
  • 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..