You guys are still using the bugged version of ReadLineFromFile(). On the last line, "FileContents" is misspelled, which I already mentioned in my previous post.
Another possible issue could be that the file you're trying to read is saved as Unicode. By default, OpenTextFile reads the file as ASCII so you need to pass in an extra parameter to override this behavior. Therefore, I added an extra parameter to the function which takes care of this. You could try to detect whether a file is saved as ASCII or Unicode, but that requires some Win32 trickery.
js code:
function ReadLineFromFile(sFile, nLine, bUnicode) {
var f = new ActiveXObject("Scripting.FileSystemObject").OpenTextFile(sFile, 1 /* ForReading */, false, (bUnicode ? -1 : 0));
var s = f.ReadAll();
f.Close();
var FileContents = s.split(/\r?\n/);
if(nLine > FileContents.length) return false; // implement some error handling here?
return FileContents[nLine-1];
}
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
var m;
if (m = /^\/([^ \n\r\v\xA0\/][^ \n\r\v\xA0]*)[\s\xA0]?([\s\S]*)/.exec(sMessage)) {
var command = m[1].toLowerCase();
var parameter = m[2];
if (command == 'acserv') {
var line = ReadLineFromFile("C:\\Program Files\\AssaultCube_v1.1.0.3\\config\\saved.cfg", 255, false); // change false to true if Unicode
// line now contains the 255th line from saved.cfg
line = line.replace('alias "serverinfo [', '');
line = line.replace(']', '');
return line;
}
}
return sMessage;
}