The code can be shortened using $iif().
$iif() is same as if {..} | else {..}.
//echo $iif(%a,yes,no) is same as //if %a { echo yes } | else { echo no }
If %a has value it will echoes yes, otherwise no.
So, we simply put $iif() into the message.
msg # /me gives $nick a cup of $iif($2,$2-,$null) coffee in his favorite cup.
If $2 has value, $2- will be added to msg, otherwise nothing will be added.
on *:text:!coffee*:#:{
; Store your vip user into %vip.user variable
var %vip.user username username2 username3 etc
; Make sure that the user is a VIP
if $istok(%vip.user,$nick,32) {
; Random between 1 and 3.
var %r $rand(1,3)
if (%r == 1) { msg # /me gives $nick a cup of $iif($2,$2-,$null) coffee in his favorite cup. | return }
if (%r == 2) { msg # bleh $2- | return }
if (%r == 3) { msg # bluh $2- | return }
}
; If user isn't a VIP
else {
; Random between 1 and 2.
var %r $rand(1,2)
if (%r == 1) { msg # /me throws a cup of $iif($2,$2-,$null) coffee to $nick $+ . | return }
if (%r == 2) { msg # heh | return }
}
}