mIRC Home    About    Download    Register    News    Help

Print Thread
#259144 08/10/16 08:28 PM
Joined: Mar 2016
Posts: 21
P
pykolas Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2016
Posts: 21
Quote:

on *:text:!pykolas:#:{
if ((%floodEVERYONE) || ($($+(%,floodEVERYONE.,$nick),2))) { return }
set -u2 %floodEVERYONE On
set -u3 %floodEVERYONE. $+ $nick On
if $nick = pykolas {
msg $chan /me Something something
}
if $nick = pyko_bot {
msg $chan /me I am robot smile /
}
if $nick = pykolas2 {
msg $chan /me Hello random person smile /
}
}

Can someone teach me how to use else statement? laugh

pykolas #259145 08/10/16 08:33 PM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Code:
if (condition) {
  ;; if the above condition is true
  ;; this block of code will execute
}
elseif (condition2) {
  ;; If previous any previous if->elseif statements
  ;; DID NOT execute, and condition2 is true
  ;; this block of code will execute
}
else {
  ;; if non of the previous if->elseif statements
  ;; executed, then this block of code will execute
}



You can also string together multiple elseif statements:
Code:
if (condition1) {
  ;; if condition1 is true this block of code will execute
}
elseif (condition2) {
  ;; if condition1 is not true and condition2 is true
  ;; this block of code will execute
}
elseif (condition3) {
  ;; if condition1 and condition2 were not true
  ;; and condition3 is true
  ;; this block of code will execute
}
elseif (condition4) {
  ;; if condition1, condition2, and condition3 were not true
  ;; and condition4 is true
  ;; this block of code will execute
}

;; and so on for as many elseif clauses as you need

else {
  ;; if none of the conditions are true
  ;; this block of code will execute
}



Think of if-then-else similar to English speech:
Code:
if Jimmy has 3 balls he'll juggle them.
Otherwise if Jimmy has 2 balls he'll dribble them.
Otherwise Jimmy will just hold onto to any balls he has


Can be represented similar to:
Code:
if (jimmy has 3 balls) {
  he'll juggle them
}
elseif (Jimmy has 2 balls) {
  he'll dribble them
}
else {
  he'll hold onto any balls he has
}


Last edited by FroggieDaFrog; 08/10/16 08:43 PM.

I am SReject
My Stuff
FroggieDaFrog #259164 11/10/16 04:30 AM
Joined: Mar 2016
Posts: 21
P
pykolas Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2016
Posts: 21
Thank you. In the future this will be handy smile


Link Copied to Clipboard