So I made a death command. Here is the code: Code (text): if (command == "d") { if (SESSION.channels(channel).dieoff === true) { normalbot.sendMessage(src, "/d was turned off.", channel); return; } var death = new Array(sys.getFileContent(Config.dataDir + "death.txt")); var y = Math.floor(death.length * Math.random()); sys.sendHtmlAll(death[y], channel); sys.kick(src); return; } I didn't want to add 170 different deaths into the script, thats why I tried making an array in a text file. but instead of sending one of the death links. It sends all of them. From that I can see that this: Code (text): var death = new Array(sys.getFileContent(Config.dataDir + "death.txt")); is worng.
Make sure each item in the text file is separated by a new line. So This is line 1 This is line 2 This is line 3 etc Then just do sys.getFileContent(Config.dataDir + "death.txt").split("\n") or .split("\r\n") depending on your OS and what text editor you use. (Windows is \r\n, unless you use notepad++ then it's \n). That'll return an array with each item been a separate line.
Code (javascript): String.prototype.splitLines = function() { return this.replace(/\r/g, "").split("\n"); }; i makey this for my client scripts you can just put this at the very top of the file and do like Code (javascript): var death = sys.getFileContent(Config.dataDir + "death.txt").splitLines();
You'd have to extend the String prototype to do .splitLines() like that (and then the function would be wrong). I'm assuming you mean this.splitLines(stuff) or splitLines(stuff)