Lucyfero commented on a Page, Need help with a Define and Explain script  -  May 05, 2015

Hi, just 2 issues:
first use alias so that you can check the script; second you should consider an anti-flood mechanism otherwise you will get kicked.
This code works: (to check it use: !define love nature's way of tricking people into reproducing. )

on *:INPUT:#: {
if ($1 == !define) { define $me $2- | haltdef }
elseif ($1 == !explain) { explain $2 | haltdef }
}

on 1:TEXT:!define :#: define $nick $2-
on 1:TEXT:!explain
:#: explain $2

alias -l define {
if (%noflood) { halt }
; Silently exits
set -u10 %noflood $true
.writeini Worddata.ini Define-Explain $2- ::: Last Modified by $1 @ $date - $time
msg $chan The Definition Of ( $2 ) Has Been Set by $1 $+ .
}

alias -l explain {
if (%noflood) { halt }
; Silently exits
set -u10 %noflood $true
if ($readini(Worddata.ini,Define-Explain,$1) == $null) {
msg $chan $1 --->> Undefined.
}
else {
msg $chan $1 --->> $readini(Worddata.ini,Define-Explain,$1)
}
}

ovelayer  -  May 05, 2015

instead of using $date and $time you could allways use $ctime and $duration

BitHelper  -  May 05, 2015

Well I tried this script and it won't work.

BitHelper  -  May 05, 2015

I also forgot to add that i want people to add there own define and that OP's can only remove the define or re-define it.

ovelayer  -  May 05, 2015

here ya go

on *:TEXT:*:#coders: {
  if ($1 == !define) {
    if ($2 == add) {
      if (!$3) || (!$4) { msg $chan $+(4,ERROR,15,!) | halt }
      elseif ($read(Worddata.txt,s,$3)) { msg $chan $+(7,$3) 15is allready in my database | halt }
      write $+(Worddata.txt) $3 $ctime $nick $4-
      msg $chan $+(13,Added,15,:) $+(7,$3) 14(13Definition15:7 $4-14) 15to Worddata.txt
    }
    elseif ($2 == del) {
      if (!$3) { msg $chan $+(4,ERROR,15,!) | halt }
      elseif (!$read(Worddata.txt,s,$3)) { msg $chan $+(4,ERROR,15,!) $+(7,$3) 15is not in worddata.txt| halt }
      elseif ($nick !isop $chan) { msg $chan $+(4,ERROR,15,!) You must be a channel operator to use this command! | halt }
      write -ds $3 worddata.txt
      msg $chan $+(7,$3) 15has been deleted form worddata.txt.
    }
    elseif ($2 == lines) {
      msg $chan 15There are7 $lines(worddata.txt) 15words in my database.
    }
    elseif ($2 == help) {
      msg $chan useage:
      msg $chan 15!define 13add8 <word> 14(15Adds a word and definition 14ex15: !define 13add 7test 15this is a test.14)
      msg $chan 15!define 13del8 <word> 14(15Deletes a definition 14ex15: !define 13del7 test14)
      msg $chan 15!define 13lines 14(15Shows how many words have been added to worddata.txt14)
      msg $chan 15!explain8 <word> 14(15Gives the explination of a word. 14ex15: !explain7 test14)
    }
    else {
      msg $chan $+(4,ERROR,15,!)
    }
  }
  elseif ($1 == !explain) {
    if ($lines(worddata) == $null) || (!$exists(worddata.txt)) { msg $chan 15No data has been entered. | halt }
    elseif (!$read(Worddata.txt,s,$2)) { msg $chan $+(7,$2) 15is Not in my database | halt }
    var %temp = $read(Worddata.txt,s,$2)
    msg $chan $+(13,Word,15,-,,>,) $+(7,$2)    $+(13,Definition,15,-,,>,) $+(7,$gettok(%temp,3-,32))    $+(13,Last Edited,15,-,,>,) $+(15,$replace($duration($calc($ctime - $gettok(%temp,1,32))),w,44w,d,14d,h,14h,m,14m,se,14se,$chr(32),$+($chr(32),15)) ) $+(15,ago.)    $+(13,By,15,-,,>,) $+(7,$gettok(%temp,2,32))
  }
}

the code wrapped on hawkee seems to have erase the char needed for the colors
i added a pastebin here: http://pastebin.com/U3JJhV8c

BitHelper  -  May 05, 2015

Thank You ovelayer! The script works awesome!

ovelayer  -  May 05, 2015

your welcome =)

Sign in to comment

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.