mIRC Homepage
Posted By: GamingTom $readini - 03/07/13 03:41 PM
I'm having a bit of trouble with reading from an ini file with an 'on text' script. I have this in the Aliases section and works when i type '/commandtest 1' into the mIRC chat:

Code:
/commandtest { msg $chan $readini(file.ini,items,$1) }


The problem is when I try using an 'on text' script to call the command it doesn't seem to work, nothing comes up:

Code:
on *:text:!commandtest *:#:{
  commandtest $2- { msg $chan $readini(file.ini,items,$1) }
}


I also tried reading from the ini without using an alias but that didn't work either, I tried:

Code:
on *:text:!commandtest *:#:{
  msg $chan $readini(file.ini,items,$2-)
}


If anyone could help me I would really appreciate it, I'm probably doing something really stupid but I can't get it to work.
Many thanks, Tom.
Posted By: 5618 Re: $readini - 03/07/13 06:37 PM
The correct format would be:
Code:
on *:TEXT:!commandtest *:#:{
  commandtest $2-
}

And $2 should be used instead of $2-... not? I don't think spaces are allowed in .ini items.

Remote scripts can also only be triggered by other users, in case you didn't know.
Posted By: Loki12583 Re: $readini - 03/07/13 06:45 PM
You should be using the n switch with $readini to prevent evaluation of the value $readini(file.ini,n,items,$1)
Posted By: GamingTom Re: $readini - 03/07/13 06:57 PM
I have changed the script to what '5168' suggested but still doesn't work. My .ini file is set out like this:
Code:
[items]
1=This is an item.

but when I type in '!commandtest 1' the bot doesn't reply with 'This is an item'. I am using an external Twitch chat client to perform the command and I also put in the n switch suggested by Loki12583. I don't understand what I'm doing wrong...

Posted By: 5618 Re: $readini - 03/07/13 07:33 PM
Whoops, you need to pass the channel to your alias as well.
Code:
/commandtest { msg $2 $readini(file.ini,items,$1) }

on *:TEXT:!commandtest *:#: commandtest $2 $chan

Posted By: GamingTom Re: $readini - 03/07/13 07:42 PM
I'm suspecting that you wrote the alias wrong because that would be sending a message to the channel '$2' which in this case is 'This'. But I changed the remote on text script but still nothing happens. If you have any other ideas I would greatly appreciate them.

-- Edit --
Never mind, I got it working in the end, I moved it to a separate script file and it seems to be working, many thanks for your help!
© mIRC Discussion Forums