> - Greater than
>= - Greater or equal to
< - Less than
<= - Less or equal to
Example:
Code:void function() { int rights = 2; if(somePlayer.returnRights() >= 2) { //Would allow any player with the rights greater or equal to two }
|
Can someone explain a <= statement thing too me? Like what it does. Like the difference between < and = and <=?
For example, what does this mean:Code:if(playerRights >= 2)
> - Greater than
>= - Greater or equal to
< - Less than
<= - Less or equal to
Example:
Code:void function() { int rights = 2; if(somePlayer.returnRights() >= 2) { //Would allow any player with the rights greater or equal to two }
Thanks aton
Wait could anything just be equal too? So people above and people below couldnt use?
For example if it was playerRights = 3
Could only the person with player rights 3 use it?
In if statements you must use 2 == signs but if your changing the value of the integer then you only use one like thisCode:if(playerRights == 3) { //do this }
Code:playerRights = 3;
thanks
If you want a String to be equal you must use the method aStringAtribute.equals("SomeThing"), which returns if the aStringAtribute is equals to "SomeThing".
Or use aStringAtribute.equalsIgnoreCase("something") to check if it's the same (except for any capital letters).
Here's an example code:
It's saying that if your rights are greater or equal to 2 then send the message:Code:if(playerRights >= 2) { sendMessage("I'm an Admin!"); } else if(playerRights == 1) { sendMessage("I'm a Moderator!"); }
else if your player rights equal to 1 send the message:Code:sendMessage("I'm an Admin!");
>= Greater than or Equal toCode:sendMessage("I'm a Moderator!");
<= Less than or equal to
> Greater than
< Less than
= Equals
+ Addition
- Subtraction
<> Greater or Less than
! = untrue
In a code if you wanted to add points for how many times you were killed, you would do this:
Declare this:
This is putting the int killed so we can call it.Code:public int killed = 0;
Then under your dieing method you would add this:
It doesn't mean HIGHER or EQUAL It's just saying add 1 int to the already equaled 0 int.Code:killed += 1;
Here's another code that you might want to know about:
This:Code:if(playerRights != 2) { sendMessage("I'm neither moderator nor admin); } else if(playerRights != 1) { sendMessage("I'm neither moderator nor admin); }
Means if your player rights are not 2 send the message:Code:!=
Hope I helpedCode:sendMessage("I'm neither moderator nor admin);
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |