Brand new to mSL and just playing around with trying to make a bot. So I am trying to make something that when a user says a certain word, they get +1 to a count against their name. However they can then not say the word again to further increase their count unlimited times, they must find a new word.
To ensure the words cannot be used multiple times I am writing the words to a file, I then need to load these words and check if its been said already or not against what the user has just said, and act appropriately
on *:TEXT:&:#:{
var %msg
if ($1 == text1) { %msg = msg1 }
elseif ($1 == text2) { %msg = msg2 }
elseif ($1 == text3) { %msg = msg3 }
else { return }
msg # %msg
var %keyword = $readini(keyword.ini,#,$nick)
if (%keyword == $1) {
msg # you already have this keyword! :(
}
else {
var %count = $readini(cookies.ini,#,$nick)
inc %count
writeini cookies.ini # $nick %count
writeini keyword.ini # $nick %keyword $+ , $+ $1
}
}
keyword.ini file looks like:
nickname=text1,text2
is there anyway in mSL that I can grab the list (already done in code above) and then use something similar to .split(,) to divide up the words to run through a for/next?
Thanks in advance
EDIT: I tried out the below and although it did work! I then deleted the file to test it out, and it never remade the file despite the writeini. I even added a writeini keyword.ini at the start of the script to make sure the file is present before any text is written, still didn't make it.
on *:TEXT:&:#:{
var %msg
if ($1 == text1) { %msg = msg1 }
elseif ($1 == text2) { %msg = msg2 }
elseif ($1 == text3) { %msg = msg3 }
else { return }
msg # %msg
var %i = 1, %keyword = $readini(keyword.ini,n,$chan,$nick), %cookie = $readini(cookies.ini,n,#,$nick)
while (%i <= $numtok(%keyword, 44)) {
if ($istok(%keyword, $1, 44)) {
msg # you already have this keyword! :(
}
else {
inc %cookie
writeini cookies.ini $chan $nick %cookie
msg # congrats! you found a keywords
writeini keyword.ini $chan $nick $addtok(%keyword, $1, 44)
}
inc %i
}