You need to include the parameters (ChatWnd and Message) for
OnEvent_ChatWndReceiveMessage().
jscript code:
function ReadLineFromFile(sFile, nLine)
{
var f = new ActiveXObject("Scripting.FileSystemObject").OpenTextFile(sFile, 1 /* ForReading */);
var s = f.ReadAll();
f.Close()
var FileContents = s.split('\r\n');
return FileConents[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);
// line now contains the 255th line from saved.cfg
line = line.replace('alias "serverinfo [', '');
line = line.replace(']', '');
}
}
return sMessage;
}
If you're not sure how to put together and compile the script, have a look at the attachment.