mIRC Home    About    Download    Register    News    Help

Print Thread
#196357 15/03/08 03:55 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
Can I add on/off and also make a dialog so that I can add and remove swear words for this code?

Code:

alias swear {
  return sale rent phone fone sun friendster cam webcam cam. cam?
}

On @*:Text:*:#: {
  if (!$hget(swear)) hmake swear 10
  var %i = 1
  while ($gettok($swear,%i,32)) {
    if ($istok($1-,$v1,32)) { 
      if ($nick !isop $chan) {
        hinc swear $nick
        if ($hget(swear,$nick) == 1) /say $nick (Warning) Don't spam or advertise
        if ($hget(swear,$nick) == 2) { ban -k $chan $nick 2 Don't spam or advertise | hdel swear $nick }
      }
    }
    inc %i
  }
}


bcancer #196382 15/03/08 11:14 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
First of all, I'd remove the alias. It's not needed. Just hsave the hash table after making changes and then hload it when starting mIRC (on START) and/or when !$hget(swear). It is faster that way.

As far as on/off, you could just use groups... /help groups

Just put the on TEXT inside a group and use an alias for enabling/disabling the group.

And for adding new words, just make a dialog with a listbox (to show the words), an editbox (to add the words), and a button (that will add the word that you put in the editbox). When a word is added, /hadd it to the hash table and then /hsave the table. You'll probably want to refresh the listbox with the words in the hash table. To remove, just have a remove button that will /hdel the word from the hash table.

Remember to put the words as their own item names rather than having them all in one line like you have in your alias so that you don't run out of space if you add a lot of words.


Invision Support
#Invision on irc.irchighway.net
Riamus2 #196409 16/03/08 10:18 AM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
Why this not working ?

Code:

On me:*:Disconnect: swear save
On *:Exit: swear save
on *:start:{
  if (!$isdir($mircdirsys)) mkdir $qt($mircdirsys)
  if !$hget(swear)  { .hmake swear 10 }
  if $exists($mircdirsys\swear.op) { .hload -i swear $mircdirsys\swear.op }
}

dialog swear {
  title "Bad swear Protection"
  size -1 -1 148 167
  option dbu
  combo 1, 9 15 125 125, sort, size, vsbar
  button "Add", 2, 5 150 25 11, flat
  button "Delete", 3, 33 150 25 11, flat
  box "Enter Bad swear Words.", 5, 5 5 135 140
  button "Ok", 7, 117 150 25 11, flat ok
  button "ON", 333, 89 150 25 11, flat
  button "OFF", 334, 61 150 25 11, flat
}

on *:dialog:swear:sclick:*: {
  if ($did == 333) { .enable #swear ON | echo -a $asctime([HH:nn]) * 10swear Ban Protection Is Now 15«4Enable15» }   
  if ($did == 334) { .disable #swear Off | echo -a $asctime([HH:nn]) * 10swear Ban Protection Is Now 15«4Disable15» }
} 

on *:dialog:swear:*:*: {
  if ($devent == init) {
    did -b $dname 3
    var %x = 1
    while (%x <= $lines(sys/swear.op)) {
      did -a $dname 1 $read(sys/swear.op,%x)
      inc %x
    }
  }
  if ($devent == sclick) {
    if ($did == 1) {
      did -e $dname 3
    }
    if ($did == 2) {
      if ($did($dname,1)) {
        if (!$didwm(swear,1,$did($dname,1),0)) {
          write sys/swear.op $did($dname,1) 
          did -a $dname 1 $did($dname,1)
        }
      }
    }
    if ($did == 3) { 
      write -dw $did($dname,1).seltext sys/swear.op
      did -d $dname 1 $did($dname,1).sel
      did -b $dname 3
    }
  } 
}

On @*:Text:*:#dns: { 
  if (!$hget(swear)) hmake swear 10
  var %i = 1
  while ($gettok($swear,%i,32)) {
    if ($istok($1-,$v1,32)) { 
      if ($nick !isop $chan) {
        hinc swear $nick
        if ($hget(swear,$nick) == 1) /say $nick (Warning) Don't spam or advertise 
        if ($hget(swear,$nick) == 2) { ban -k $chan $nick 2 Don't spam or advertise | hdel swear $nick }
      }
    }
    inc %i
  }
}

 

bcancer #196413 16/03/08 12:05 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I don't have time now to go through it all as I'm about to leave for work, but you should not be using /write at all. Add or remove the items directly from the hash table (/hadd, /hdel) and then save the hash table (/hsave). Otherwise your changed words will not be loaded into the hash table until you restart and won't be used in the script until then.

You also removed the swear alias, but you didn't change your on TEXT event to use the hash table. It's still trying to use the alias.


Invision Support
#Invision on irc.irchighway.net
Riamus2 #196416 16/03/08 12:08 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
ok thx ill start over smile


Link Copied to Clipboard