Well, I used the return statement there so that when the user types /Crypto, it will not send the message itself but just enable the encryption thing. Well it seems that the return outString; is what I needed, even though it doesn't work yet but that is because I probably made a mistake in the algorithm which I am about to correct right now. Thanks for the help
Edit: So guys, yes it works
the code here for anyone who is interested
code:
var flag = new Boolean();
var CryptoTable = [], i = 8;
function OnEvent_Initialize(MessengerStart)
{
Debug.trace("Crypto Script v0.1 started.");
parseIntoTable();
flag = false;
}
function OnEvent_Uninitialize(MessengerExit)
{
Debug.trace("Crypto Script v0.1 terminated.");
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if(Message == "/Crypto") {
flag = true;
return "";
}
if(Message == "/ExitCrypto") {
flag = false;
return "";
}
if(flag) {
var i = 0;
var mesg = Message;
var outString = "";
while(i < Message.length) {
if(mesg.charAt( i ) == " ") {
outString = outString + "#";
i++;
continue;
}
for(var x = 0; x < 8; x++) {
for(var y = 0; y < 4; y++) {
if(CryptoTable[x][y] == mesg.charAt( i )) {
for(var z = 0; z < y + 1; z++) {
var send = (x + 2);
outString = outString + send;
}
}
}
}
if( ((i+1) != Message.length) && (mesg.charAt(i+1) != ' ') ) {
outString = outString + "*";
}
i++;
}
return outString;
}
return Message;
}
function parseIntoTable() {
Debug.trace("parseIntoTable() called");
do
CryptoTable.push([]);
while(0 < --i);
CryptoTable[0] = ['A', 'B', 'C', -1 ];
CryptoTable[1] = ['D', 'E', 'F', -1 ];
CryptoTable[2] = ['G', 'H', 'I', -1 ];
CryptoTable[3] = ['J', 'K', 'L', -1 ];
CryptoTable[4] = ['M', 'N', 'O', -1 ];
CryptoTable[5] = ['P', 'Q', 'R', 'S'];
CryptoTable[6] = ['T', 'U', 'V', -1 ];
CryptoTable[7] = ['W', 'X', 'Y', 'Z'];
}