LarysL2 Posted March 9, 2014 Share Posted March 9, 2014 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 :/ Quote Link to comment Share on other sites More sharing options...
0 SweeTs Posted March 9, 2014 Share Posted March 9, 2014 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 Quote Link to comment Share on other sites More sharing options...
0 LarysL2 Posted March 9, 2014 Author Share Posted March 9, 2014 (edited) Thank you SweeTs for your fast reply, about your solution, it worked but somehow still there is a problem. 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 March 9, 2014 by LarysL2 Quote Link to comment Share on other sites More sharing options...
0 SweeTs Posted March 10, 2014 Share Posted March 10, 2014 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. Quote Link to comment Share on other sites More sharing options...
Question
LarysL2
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:
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.