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/or y, 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: if x is related accordingly (based on the “sign”) with y 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
!example 5 is bigger than 0 !example No answer because $random[0;10] returned that the number are less than 5

$endif

Ends an if statement.

Syntax

$endif

Example

$nomention
$if[$message==abc]
  Good work!
$endif

With $endif

!example abc Good work!

Without $endif

!example abc $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
!example 5 is bigger than 0 !example 5 is less than 8

$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 $elseifs. 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
!example 5 is less than 6 !example 5 equals 5

$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 return true. Separate conditions using ;. Use Signs.

Example

$nomention
$if[$and[$nickname==MineBartekSA;$message==Update]==true]
  Hi developer
$else
  Hi user
$endif
!example Update Hi user !example Hi user !example Hi user !example Update Hi developer

$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
!example Update Hi !example Bye !example Hi !example Update Hi

Simple Example

  1. Create command with !example trigger.

  2. 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
    
  3. Execute command !example

!example BDFD Hi BDFD User! !example Bartek Are you Bartek? !example Premium Do you want to get premium? !example Hello I can't find this:(