Coke script

By jackster35-1 on Sep 09, 2011

This is a little script I made within 2 days. It's very simple, I've also tryed to make it flexible as well so it's easy for new coders to add on to it.

I'll be adding on to it in the future and updating the script.

Commands:

!register - Registers your account, (You'll have to go through a verification stage in order to complete the registration)
!stats (nick) - Get's the statics of the nick you wish. If you leave the nick bit empty, it'll show you the stats of your self.
!cdrink - Get a glass of coke from the bot. (One person to be served at a time ;) )

Enjoy, please feel free to comment on suggestions and other things you feel necessary

on *:TEXT:!register*:#:{
  if (!$2) {
    if (%coke. [ $+ [ $nick ] ] == 1) {
      echo ( $+ $time $+ -+- $+ $date $+ ) [4ERR] $nick tryed to register when they already had an account!
      privmsg $chan $nick $+ , you already have an account.
    }
    else {
      privmsg $chan $nick $+ , you will be noticed a code within 10 seconds to prove that you're a human.
      set %reg. [ $+ [ $nick ] ] $rand(999999,999999999)
      timer 1 10 /notice $nick Your code is  $+ %reg. [ $+ [ $nick ] ] $+ 
      timer 1 10 /notice $nick Inorder to complete your registration, type the following:
      timer 1 10 /notice $nick !register %reg. [ $+ [ $nick ] ] 
      timer 1 10 /notice $nick If you do not do that command within 1 minute, the request will not longer be valid. :(
      timer 1 70 /unset %reg. [ $+ [ $nick ] ]
    }
  }
  else {
    if ($2 == %reg. [ $+ [ $nick ] ]) {
      privmsg $chan Thank you for registering $+($nick,.)
      privmsg $chan I will now add you to my database...
      set %coke. [ $+ [ $nick ] ] 1
      set %coke. [ $+ [ $nick ] $+ ] . [ $+ [ time ] ] $ctime
      set %coke. [ $+ [ $nick ] $+ ] . [ $+ [ network ] ] $network
      set %coke. [ $+ [ $nick ] $+ ] . [ $+ [ cokes ] ] 0
      $tip(Coke, Coke Registration!,$nick has successfully registered on my Coke system!,10)
      unset %reg. [ $+ [ $nick ] ]
      timer 1 5 privmsg $chan Done, you may now use the coke system :)
      timer 1 5 privmsg $chan Enjoy! =D
    }
  }
}

on *:TEXT:!stats*:#:{
  if ($2) {
    if (%coke. [ $+ [ $2 ] ] == 1) {
      privmsg $chan $2 registered $duration($calc($ctime - %coke. [ $+ [ $2 ] $+ ] . [ $+ [ time ] ] )) ago!
      privmsg $chan They've drank %coke. [ $+ [ $2 ] $+ ] . [ $+ [ cokes ] ] cokes since they registered.
    }
    else {
      privmsg $chan $2 isn't registered!
    }
  }
  if ($2 == $null) {
    if (%coke. [ $+ [ $nick ] ] == 1) {
      privmsg $chan You registed $duration($calc($ctime - %coke. [ $+ [ $nick ] $+ ] . [ $+ [ time ] ] )) ago!
      privmsg $chan You've drank %coke. [ $+ [ $nick ] $+ ] . [ $+ [ cokes ] ] cokes since you registered.
    }
    else {
      privmsg $chan You ain't registered, try registering with !register
    }
  }
}

on *:TEXT:!cdrink:#:{
  if (%coke. [ $+ [ $nick ] ] == 1) {
    if (%cokes1 == 1) { privmsg $chan Please wait, $+($nick,!) I'm already serving somebody, I've only got 1 pair of hands! }
    else {
      set %cokes1 1
      set %coke. [ $+ [ $nick ] $+ ] . [ $+ [ cokes ] ] $calc(%coke. [ $+ [ $nick ] $+ ] . [ $+ [ cokes ] ] + 1)
      describe $chan grabs a glass and slowly puts coke in to the glass...
      timer 1 5 msg $chan Ok... Almost done! Gives a few secs, just spilt it all over the counter :(
      timer 1 10 msg $chan Done!
      timer 1 12 describe $chan hands $nick a glass of coke
      timer 1 15 msg $chan Adding it to your tab now. :)
      timer 1 16 msg $chan Done!
      timer 1 16 unset %cokes1
    }
  }
  else {
    privmsg $chan Please register by using !register
  }
}

Comments

Sign in to comment.
dma   -  Oct 30, 2015

works fine in 2015

 Respond  
Jethro   -  Sep 11, 2011

I've been told by jaytea recently that using one text event per operation is efficient than having them under one with a bunch of if or elseif statements.

 Respond  
jackster35-1   -  Sep 10, 2011

=D I've also been given some help from GrimReaper on how I'd have it all in 1 :TEXT: :) I'll be using that in the new update as well.

Thank you so much for your help, Jethro. :)

 Respond  
Jethro   -  Sep 10, 2011

Yes, jackster35. That was what I tried to get it across.

 Respond  
jackster35-1   -  Sep 10, 2011

Oooooooooooooooooooooooooh, I see.

So for example, the user would do "!stats Jack1" and the bot would check if $address(Jack1,2) matched !@jacks.vhost and then reply the statics if all is well.

^ Is that what you mean?

 Respond  
Jethro   -  Sep 10, 2011

To make it clear for you to see, here is another example:

on *:TEXT:!register:#:{
  if (!%coke. [ $+ [ $nick ] ]) {
    set %coke. $+ $nick 1
  }
  else {
    msg $chan $nick you already have an account!
  }
}

The $2 is not necessary. Simply use the !register command. When you set a dynamic variable, you don't need to include the [ ] evaluation bracket.

 Respond  
Jethro   -  Sep 10, 2011

Also, I realize this part doesn't quite make sense:> on :TEXT:!register:#:{
if (!$2) {
if (%coke. [ $+ [ $nick ] ] == 1) {
The $2 has nothing to do with the dynamic variable here. It should have been:

on *:TEXT:!register*:#:{
  if (!%coke. [ $+ [ $nick ] ]) {
    if (%coke. [ $+ [ $nick ] ] == 1) {

You're to check for the value, not compare them with $2 and the variable.

 Respond  
Jethro   -  Sep 10, 2011

For example,

alias gethost {
 if ($me ison #) && ($1 ison #) {
  echo -a $1's host is: $address($1,2)
 }
}

Command: /gethost Nick

will return his or her nickname and host. I hope you get the idea. For the text event with a trigger, the $1 becomes $2.

 Respond  
jackster35-1   -  Sep 10, 2011

I kinda get it, but I'm still very confused how you'd actually get it to work with saying !stats nick

 Respond  
Jethro   -  Sep 10, 2011

You'd have to do !stats !@host.here for it to work.Use:

$address($2,2)

For $nick inside the [ ] brackets, you use $wildsite ; for $2 inside the [ ], you use $address($2,2)

Like this:> if ($address($2,2)) {
if (%coke. [ $+ [ $address($2,2) ] ] == 1) {and you can still use $2 and $address($2,2) side by side to refer to his or her nickname and host.

 Respond  
jackster35-1   -  Sep 10, 2011

Jethro, I understand what you're on about and as I was updating a few things I realised that if I use $wildsite, the !stats command would be annoying. You'd have to do !stats !@host.here for it to work. Any idea how I could use $wildsite and have the !stats command work with nicks still?

Thanks in advanced.

 Respond  
Jethro   -  Sep 10, 2011

What have you updated? You still haven't updated the $nick matter I mentioned.
That aside, this is your own script after all. I can't tell you what to do but advise only.

 Respond  
jackster35-1   -  Sep 10, 2011

Updated...

 Respond  
jackster35-1   -  Sep 10, 2011

Jethro, ever since I've been coding Python IRC bots I've used "PRIVMSG" as it's a raw command. So I've been using it in mIRC lately due to my Python habits. Sorry :(

 Respond  
Jethro   -  Sep 09, 2011

Well yes, rather than having 10-second notices per interval, you can make them as one notice display. It's more straightforward and less annoying this way. Lastly, I'm not certain why you'd use "privmsg" over msg. According to irc protocol: > PRIVMSG is used to send private messages between users.
is the nickname of the receiver of the message. can also
be a list of names or channels separated with commas.

 Respond  
Dani_l11   -  Sep 09, 2011
    else {
      privmsg $chan $nick $+ , you will be noticed a code within 10 seconds to prove that you're a human.
      set %reg. [ $+ [ $nick ] ] $rand(999999,999999999)
      timer 1 10 /notice $nick Your code is  $+ %reg. [ $+ [ $nick ] ] $+ 
      timer 1 10 /notice $nick Inorder to complete your registration, type the following:
      timer 1 10 /notice $nick !register %reg. [ $+ [ $nick ] ] 
      timer 1 10 /notice $nick If you do not do that command within 1 minute, the request will not longer be valid. :(
      timer 1 70 /unset %reg. [ $+ [ $nick ] ]
    }

You know that does nothing but annoy people right? If people wanna bot this game, it's not gonna stop them...

 Respond  
Jethro   -  Sep 09, 2011

A friendly suggestion: change all the $nick to $wildsite in the evaluation brackets. People tend to change their nicknames every now and then, and if they do, mIRC won't be able to keep an accurate count or info. Another way is to make a nick event to detect nickname change and have the variable reflect it in real time, but that's a tad tedious.

 Respond  
jackster35-1   -  Sep 09, 2011

Guys, the "%coke. [ $+ [ $nick ] $+ ] . [ $+ [ network ] ]" isn't needed at the moment. It's there just to remind me of something I'll be using it for in the future. :P

 Respond  
jackster35-1   -  Sep 09, 2011

Aha2Y, I've been working on it for the paste 2 days and finished it like 5 minutes ago. :P I'll be updating it in the future. :)

 Respond  
jackster35-1   -  Sep 09, 2011

LoL, the credit thing in the script screwed over. My bad :P

 Respond  
Jordyk19   -  Sep 09, 2011

That was a fast reaction on my comment at your other script.
Great script. 9/10 from me. and a like.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.