mIRC Home    About    Download    Register    News    Help

Print Thread
#249374 26/11/14 06:35 PM
Joined: Nov 2014
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Nov 2014
Posts: 8
So i have this !addcom type of thing, Which lets you add commands only for the channel its in.
Code:
on *:text:!cadd *:#: {
  if ($nick isop #) {
    var %r = $read(# $+ commands.txt,ns,$2)
    if (%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) is already exist into the database! | return }
    write # $+ commands.txt $2-
    msg $chan /me + Command $2 has been added to the database!
  }
}
on *:text:!cdel *:#: {
  if ($nick isop #) {
    var %r = $read(# $+ commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -dl $+ $readn # $+ commands.txt
    msg $chan /me - Command $2- has been deleted from the database!
  }
}
on *:text:!cedit & *:#: {
  if ($nick isop #) {
    var %r = $read(# $+ commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -l $+ $readn # $+ commands.txt $2-
    msg $chan /me -> Command $2 has been updated!
  }
}
ON *:TEXT:*:#: {
  tokenize 32 $strip($1-,burci)
  if ($read(# $+ commands.txt, nts, $1)) {
    var %com = $v1
    var %com = $replace(%com,@user@,$iif($2,$2,?),@nick@,$nick,@target@,$target)
    if (-ul=mod == $gettok(%com,1,32)) && ($nick !isop $chan) { msg $chan  | return }
    msg $chan $iif(-ul=mod == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
  }
}


But the !commands dosent know how to read that..
Code:
ON !*:TEXT:!cmd:#: {
  var %f = commands.txt
  if (!$isfile(%f)) { msg $chan [ $+ $nick $+ ]: Service Error no command file found | return }
  if (!$lines(%f)) { msg $chan [ $+ $nick $+ ]: There is currently no commands for this channel. | return }

  var %t = $lines(%f)
  var %i = 1
  while (%i <= %t) {
    var %r = $read(%f,nt,%i)
    var %g = $gettok(%r,1,32)
    var %com = $addtok(%com,%g,32)
    inc %i
  }


Could anyone help with this?

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
If you look at the first code, what's the file name?
If you look at the second code, what's the file name?

Contemplate over this and you should be able to fix it yourself.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Nov 2014
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Nov 2014
Posts: 8
Originally Posted By: Nillen
If you look at the first code, what's the file name?
If you look at the second code, what's the file name?

Contemplate over this and you should be able to fix it yourself.

Well the command files start with #usernamecommands
So its not just one command file.

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Look at the code, not in the mircdir.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Nov 2014
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Nov 2014
Posts: 8
Originally Posted By: Nillen
Look at the code, not in the mircdir.

I have tried to change it around and stuff to get the username of the channel then the commands part but just isnt working


Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
What I was trying to get at is in your first code, you're writing and checking everything with
Code:
    var %r = $read(# $+ commands.txt,ns,$2)
which indicates that the file is called #channelnamecommands.txt
In the second code you're using
Code:
  var %f = commands.txt
which doesn't match the first code.

FIX
replace
Code:
  var %f = commands.txt
with
Code:
  var %f = # $+ commands.txt


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Nov 2014
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Nov 2014
Posts: 8
Originally Posted By: Nillen
What I was trying to get at is in your first code, you're writing and checking everything with
Code:
    var %r = $read(# $+ commands.txt,ns,$2)
which indicates that the file is called #channelnamecommands.txt
In the second code you're using
Code:
  var %f = commands.txt
which doesn't match the first code.

FIX
replace
Code:
  var %f = commands.txt
with
Code:
  var %f = # $+ commands.txt

Thank you <3


Link Copied to Clipboard