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.


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