If Statements
In this section, you’ll learn how to use the if statement.
Content
Functions Used > Signs > $if[] > $endif[] > $else > $elseif[] > $and[] > $or[] > Simple Example
Functions Used
Support Functions Used
Signs
==
- Equal
!=
- Not equal
<
- Less than
>
- Greater than
>=
- Greater than or equal to
<=
- Less than or equal to
- These signs could vary in meaning based on the order or intent of the if statement.
- If you are using text as your
x
and/ory
, you can not use any other signs besides==
and!=
. However for numbers, you can use any sign shown in the above list.
$if
Executes the following block of code if the provided condition is true
.
Syntax
$if[Condition]
$if[]
uses the format of: ifx
is related accordingly (based on the “sign”) withy
then the code below runs.
Parameters
Condition
(Type: String || Flag: Required)
: Check that will be carried out. Use Signs.
Example
$nomention
$if[5>$random[0;10]]
5 is bigger than $random[0;10]
$endif
$endif
Ends an if statement.
Syntax
$endif
Example
$nomention
$if[$message==abc]
Good work!
$endif
With $endif
Without $endif
$if
not closed with $endif
$else
A block of code to be executed, if the $if[]
condition is false
.
Syntax
$else
Example
$if[5>$random[0;10]]
5 is bigger than $random[0;10]
$else
5 is less than $random[0;10]
$endif
$elseif
Checks provided condition only if previous $if[]
or $elseif[]
conditions returned false
. If the provided condition is true
, the following block of code will be executed.
You can use multiple
$elseif
s. Only for BDScript 2!
Syntax
$elseif[Condition]
Parameters
Condition
(Type: String || Flag: Required)
: Check that will be carried out. Use Signs.
Example
BDScript 2:
$nomention
$if[5<$random[0;10]]
5 is less than $random[0;10]
$elseif[5==$random[0;10]]
5 equals $random[0;10]
$endif
BDScrpt and BDScript Unstable:
$nomention
$if[5<$random[0;10]]
5 is less than $random[0;10]
$else
$if[5==$random[0;10]]
5 equals $random[0;10]
$endif
$endif
$and
Returns true
if every provided condition is true
, otherwise false
is returned.
Syntax
$and[Conditions;...]
Parameters
Conditions
(Type: String || Flag: Required)
: Checks that will be carried out. All conditions must be true for this function to returntrue
. Separate conditions using;
. Use Signs.
Example
$nomention
$if[$and[$nickname==MineBartekSA;$message==Update]==true]
Hi developer
$else
Hi user
$endif
$or
Returns true
if at least one of the provided conditions is true
, otherwise false
is returned.
Syntax
$or[Conditions;...]
Parameters
Conditions
(Type: String || Flag: Required)
: The condition to check. Separate conditions using;
. Use Signs.
Example
$nomention
$if[$or[$nickname==MineBartekSA;$message==Update]==true]
Hi
$else
Bye
$endif
Simple Example
-
Create command with
!example
trigger. -
Paste the following code:
$nomention $if[$message==BDFD] Hi BDFD User! $elseif[$message==Bartek] Are you Bartek? $elseif[$message==Premium] Do you want to get premium? $else I can't find this:( $endif
-
Execute command
!example