; -------------------------------------------------------------------------------------------------
; moomootree
; https://forums.mirc.com/showflat.php?Cat=0&Number=162717&an=0&page=0&gonew=1#UNREAD
;
; AIDS spell cast. Requires use of $decode (Options dalog, Expand 'Lock', click sub-category
; 'options', and uncheck 'Decode' from the list box half-way down on the right.
; -------------------------------------------------------------------------------------------------
;
; HASH TABLE
; Row: Username
;
; AIDS: column: format:
; - Registered 1 0,1
; - Logged 2 0,1
; - Password 3 $encode(...)
; - Money 4 0-9
; - Aids 5 0,1
;
; v1.1
; - Fixed the hash table not saving--Was error in the /hsave on exit.
; - Added 'global' variables to easily change the hash table name and file.
; - Changed how bot retrieves passwords that aren't set yet.
; - Added query window concealment
; - Added inc and dec properties to $aids alias
; - Added !register <password> (via PM)
; - Added !login <password> (via PM)
; - Added !give <name> <credits> to give another user money (works only for ops)
; 'Global' Variables.
; Change htese if you'd like.
alias -l aids.table { return AIDS }
alias -l aids.hash { return aids.hsh }
; Startup
; Create hash file containing AIDS info
on *:START: {
/hmake $aids.table 10
if ($isfile($aids.hash)) /hload -b $aids.table $aids.hash
}
; Exit
; Store AIDS information
on *:EXIT: {
if ($hget($aids.table) && $hget($aids.table,0).item) {
/hsave -bo $aids.table $aids.file
/hfree $aids.table
}
}
; !cast aids <name>
; Cast AIDS on to <name>
on *:TEXT:!cast aids &:#: {
var %victim = $3, %cost = 1000, %time = 300
if (!$aids($nick,Registered)) .notice $nick Please register! (!register)
else if (!$aids($nick,Logged)) .notice $nick Please login by PMing $me with !login PassYouMade
else if ($aids($nick,Money) < %cost) .notice $nick You do not have enough credits to cast AIDS!
else if ($aids(%victim,Aids)) .notice $nick $nick already has AIDS!
else if (%victim !ison $chan) .notice $nick %victim was not found on $chan
else {
if (!$aids(%victim,Money,%cost).dec) /msg $chan Could not decrease $nick $+ 's account balance.
else {
/describe $chan begins to cast AIDS.
/msg $chan $nick has spent %cost credits to cast AIDS!
; more accurate rand
var %rand = $calc($rand(1,999) % 4)
if (%rand == 0) /msg $chan AIDS failed to cast!
else if (!$aids(%victim,Aids,1).set) .msg $chan Could not assign AIDS to %victim $+ .
else {
; Did this until I noticed you changed the messages ;p
;var %t = 0
;while (%t <= %time) {
; .timer [ $+ [ $+(aids,%victim,$calc(%t / 60)) ] ] 1 $calc(%t + 10) /msg $chan %victim has $duration($calc(%time - %t)) until AIDS will take affect.
; /inc %t 60
;}
.timer [ $+ [ $+(aids,%victim,1) ] ] 1 10 /msg $chan %victim has 5 minutes 'til AIDS will take affect.
.timer [ $+ [ $+(aids,%victim,2) ] ] 1 70 /msg $chan %victim has 4 minutes remaining 'til consumed by the AIDS affect.
.timer [ $+ [ $+(aids,%victim,3) ] ] 1 130 /msg $chan %victim has only 3 minutes remaining.
.timer [ $+ [ $+(aids,%victim,4) ] ] 1 190 /msg $chan %victim has only 2 minutes left! GASP!
.timer [ $+ [ $+(aids,%victim,5) ] ] 1 250 /msg $chan %victim has only 1 minute left! Please apply the !cure soon.
.timer [ $+ [ $+(aids,%victim,6) ] ] 1 310 /kick $chan %victim You just died of AIDS! $+(|) /msg $chan %victim has DIES OF AIDS! $+(|) .echo -q $!aids(%victim,Aids,0).set
}
}
}
}
; !cure <name>
; Cures AIDS for <name>
on *:TEXT:!cure &:#: {
var %victim = $2, %cost = 1000
if (!$aids($nick,Registered)) .notice $nick Please register! (!register <password>)
else if (!$aids($nick,Logged)) .notice $nick Please login by PMing $me with !login <password>
else if ($aids($nick,Money) < %cost) .notice $nick You do not have enough credits to cure AIDS!
else if (%victim !ison $chan) .notice $nick %victim was not found on $chan
else if (!$aids(%victim,Aids)) .msg $chan $nick just wasted %cost credits to cure someone who doesn't have AIDS!
else {
if (!$aids(%victim,Money,%cost).dec) /msg $chan Could not decrease $nick $+ 's account balance.
else if (!$aids(%victim,Aids,0).set) /msg $chan Could not unset AIDS value.
else {
/msg $chan $nick has spent %cost credits to cure %victim of AIDS!
.timer [ $+ [ $+(aids,%victim,?) ] ] off
}
}
}
; !give <name> <credits>
; Gives another user credits (works for operators only)
on *:TEXT:!give & &:#: {
var %victim = $2, %credits = $3
if (!$aids($nick,Registered)) .notice $nick Please register! (!register <password>)
else if ($aids($nick,Logged)) .notice $nick Please login by PMing $me with !login <password>
else if ($aids(%victim,Registered)) .notice %victim is not registered.
else if (!$isnumeric(%credits) && %credits > 0) .notice $nick %credits is not a value credit.
else if ($nick == %victim) .notice $nick You may not give yourself %credits credits.
else if ($nick !isop $chan) .notice $nick You must be an operator to give credits
else if (!$aids(%victim,Money,%credits).inc) .notice $nick Could not increase credits; database error
else {
.notice $nick You have given %credits credits to %victim $+ .
if (%victim ison $chan) .notice %victim $nick has just given you %credits credits.
}
}
; open query window
; Keeps the windows containing bot commands closed. No need to the bot's status bar
; to fill up with windows full of 1 or 2 commands.
on *:OPEN:?:*: {
var %reg = /^!(register|login|logout)/i
if ($regex(pm,$1-,%reg)) /window -c $nick
}
; !register <password>
; Registrs your account with the bot's database (via PM)
on *:TEXT:!register &:?: {
var %password = $2-
if ($aids($nick,Registered)) {
if ($aids($nick,Password) && !$aids($nick,Logged)) {
.msg $nick You already have an account, but are not logged in. To login, PM $me with !login PassYouMade
}
else if (!$aids($nick,Password)) {
if ($aids($nick,Password,%password).set) .msg $nick Your account password has been set.
else .msg $nick Sorry, but your account has no password, and could not be updated.
}
else .msg $nick You already have an account setup.
}
else if ($aids($nick).reg) .msg $chan Your account has been setup with the password $+(,%password,.)
else .msg $nick Could not setup your account; database error.
}
; !login <password>
; Logs you in the bot
on *:TEXT:!login &:?: {
var %password = $2-
if (!$aids($nick,Registered)) .msg $nick Please register! (!register <password>)
else if (!$aids($nick,Password)) .msg $nick You do not have a password setup. Please use !register <password>
else if ($aids($nick,Logged)) .msg $nick You are already logged in.
else if ($aids($nick,Password) == %password) {
if (!$aids($nick,Logged,1).set) .msg $nick Could not log in; database error
else {
[color:blue];
; Login Stuffs
;[/color]
.msg $nick You are now logged in.
}
}
else .msg $nick Could not log you in: bad password
}
; !logout
; Logs you out of the bot
on *:TEXT:!logout:?: {
if (!$aids($nick,Registered)) .msg $nick Please register! (!register <password>)
else if (!$aids($nick,Logged)) .msg $nick You are not logged in.
else if (!$aids($nick,Logged,0).set) .msg $nick Could not log out; database error
else {
[color:blue];
; Logout Stuffs
;[/color]
.msg $nick You are now logged out.
}
}
; $aids(<name>,<item>,[value]).[set|register|inc|dec]
; Retrieves/assigns information on the specified user profile.
;
; Properties:
; - set
; Assigns [value] to the specified <item> in the table. If the value
; is numeric, you may also use the inc and dec property to increase and
; decrease their values respectivly.
; - inc
; Increase a numeric value in the <item> field
; - dec
; Decrease a numeric field in the <item> field
; - reg/register
; Registers a new user. This will create the default values necessary for
; operation.
;
; Item listing:
; - Registered
; - Logged
; - Password
; - Money
; - Aids
alias aids {
var %tbl = $aids.table, %hash = $aids.hash, %nick = $1, %item = $2
var %item_list = Registered Logged Password Money Aids, %tok = $findtok(%item_list,$2,1,32)
if ($isid && (%tok || reg* iswm $prop)) {
if ($prop == set) {
var %value = $3
if (%item == Password) %value = $encode(%value,m)
/hadd -m %tbl %nick $puttok($hget(%tbl,%nick),%value,%tok,32)
if ($gettok($hget(%tbl,%nick),%tok,32) == %value) {
/hsave -bo %tbl %hash
return $true
}
}
else if ($istok(inc dec,$prop,32) && $isnumeric($3)) {
var %value = $3, %mult = 1
if ($prop == dec) var %mult = -1
%value = %value * %mult
if ($isnumeric($gettok($hget(%tbl,%nick),%tok,32))) {
%value = $gettok($hget(%tbl,%nick),%tok,32) + %value
/hadd -m %tbl %nick $puttok($hget(%tbl,%nick),%value,%tok,32)
if ($gettok($hget(%tbl,%nick),%tok,32) == %value) {
/hsave -bo %tbl %hash
return $true
}
}
}
else if (reg* iswm $prop) {
/hadd -m %tbl %nick 1 0 - 0 0
if ($hget(%tbl,%nick)) {
/hsave -bo %tbl %hash
return $true
}
}
else {
var %value = $gettok($hget(%tbl,%nick),%tok,32)
if (%item == Password) {
; no password
if (%value == -) return $null
%value = $decode(%value,m)
}
return %value
}
return $false
}
}
; $isNumeric(<value>)
; Returns true or false if value is a number
alias -l isnumeric { return $regex($1,/^(\-*[0-9]+)$/) }