mIRC Homepage
Posted By: OmegaZeron Making a command list - 23/08/15 07:22 PM
I'm having some trouble making a command that shows other created commands in a channel. Here's what I have so far
Code:
on *:TEXT:!cmd*:#: {
  if ($nick isop #) {
    if ($2 == add) {
      write -c txt\ $+ $+(#,.,$3,.txt) $$4-
      write txt\ $+ $+(#,.,commandlist.txt) $3
      msg $chan Command added.
    }
    if ($2 == remove) {
      remove txt\ $+ $+(#,.,$3,.txt)
      msg $chan Command removed
    }
  }
}
on *:TEXT:!*:#: {
  msg $chan $read(txt\ $+ $+(#,.,$1,.txt))
}


With this I can add and remove commands, and write the command names into a txt file for use for the command list. Problem is I can't figure out how to actually get the list to work. I need all the commands to show in one message, and the ability to delete commands in the list. I've tried putting all commands in the list on different lines which makes it easy to delete them, but then I don't know how to make it so all of them are displayed in one message, and I've tried appending commands to the first line, but then I can't delete them when they're removed naturally. Would anyone be able to help?
Posted By: REDxPHOEN Re: Making a command list - 08/09/15 09:45 PM
You are better off just doing a simple command and then adding the commands in the script itself. For example if you had this
Code:
 
on *:TEXT:!cmd:#: {
msg $chan YOUR COMMANDS HERE
}

That way all you have to do is go into the script and type the command. It will save a lot of time smile
Posted By: Nillen Re: Making a command list - 09/09/15 02:06 AM
You can use a while loop to loop through the text file. When looping through the text file you can add the content to a dynamic variable using $addtok. Then paste the variable when you're done looping to the channel.

/help while loops
Example:
Code:
var %textfile PathToFile.txt
var %i 1
var %lines $lines(%textfile)
while (%i <= %lines) { 
var %line $read(%file,%i)
set %variable $addtok(%variable,%line,32) 
inc %i
}
msg # %variable
Posted By: OmegaZeron Re: Making a command list - 14/09/15 09:11 PM
Ahh, thank you so much. I couldn't quite figure out how to get everything in one message, but $addtok worked perfectly.
© mIRC Discussion Forums