• 0

# About Maximum Level Difference For Pvp Count

## Question

Hello there, i am a newbie to java... so if you could help me, i would appreciate it.

i have a code for Maximum level difference for the PvP count, for example look below:

```                if((PLAYER1.getLevel() - PLAYER2.getLevel()) >= 20 || (PLAYER2.getLevel() - PLAYER1.getLevel()) >= 20)
{
PLAYER2.setPvpKills(PLAYER2.getPvpKills() + 1);
}```
the PLAYER2 is the winner of the PvP and he will get the +1 pvp count.
the code above... works as the player2 must be 20 level higher than player1 to get the +1 pvp count, but i want the opposite.

i want the PLAYER2 must have 20 maximum level more than the player1 to get the +1 pvp count, not more than 20.
I tried to change it from >=20 to <= 20 but it didn't work :/

## Recommended Posts

• 0

Make it like that

```if((PLAYER1.getLevel() - PLAYER2.getLevel()) >= 20 || (PLAYER2.getLevel() - PLAYER1.getLevel()) <= 20)
```

But, I believe you don't need 2 cases, just one is enough. You couldn't manage it on your own cuz of the 2 cases, so I suggest to use just one :P

##### Share on other sites

• 0

If the Player2 who wins the +1 pvp has the lower level, it does not work.

Example1: Player2(64level), Player1(85level) - Player2 wins the PvP but the code is not working, he gets +1 pvp while he has 20+ level difference than Player1.

Example2: Player2(85level), Player1(64level) - Player2 wins the PvP and the code is working, he does NOT get the +1 pvp.

Edit:

I tried to do it with 1 case like as:

`if((PLAYER1.getLevel() - PLAYER2.getLevel()) <= 20)`

It had the same result of the above Example1,2 but with opposite levels at Player2,Player1.

Edit2:

`if((PLAYER1.getLevel() - PLAYER2.getLevel()) >= 20)`

Has the same result of the above Example1,2, same levels.

Edited by LarysL2
##### Share on other sites

• 0

This is supposed to work just fine..

```if((PLAYER1.getLevel() - PLAYER2.getLevel()) >= 20)
```

Well, maybe show me the whole method, maybe the problem is somewhere else.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×
×
• Create New...