Im working on a code that has an array of phrases and wen someone types the activation command (apply) its supposed to choose a phrase at random from "sArray" and post it into the chat window, but instead it posts
and nothing else, why does it do this?, please help me Thank you in advance. the code is: code:
function OnEvent_Initialize(MessengerStart)
{
}
var sArray = new Array();
sArray[0] = "*";
sArray[1] = "**";
var dArray = new Array();
dArray[0] = "***";
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message.substr(0,8).toLowerCase()=="apply"){
var i = Math.floor((Math.random()*(sArray.length-1)));
return "[b][c=red]"+sArray[i]+"[/c]
";
}
if(Message.substr(0,7).toLowerCase()=="applyver"){
var h = Math.floor((Math.random()*(dArray.length-1)));
return "
[c=blue]"+dArray[h]+"[/c]";
}
}
function OnGetScriptCommands(){
var commands = '<ScriptCommands>';
commands+='<Command>';
commands+='<Name>apply</Name>';
commands+='<Description>Sends a "apply" sentence</Description>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>applyver</Name>';
commands+='<Description>Sends Script Version Information</Description>';
commands+='</Command>';
commands+='</ScriptCommands>';
return commands;
}
function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
if(MenuItemId=="ym"){
OriginWnd.SendMessage(OnEvent_ChatWndSendMessage("", "apply"));
}
if(MenuItemId=="i"){
OriginWnd.SendMessage(OnEvent_ChatWndSendMessage("", "applyver"));
}
}
function OnGetScriptMenu(nLocation){
var ScriptMenu = "<ScriptMenu>\n";
if(nLocation===2){
ScriptMenu += "<MenuEntry Id=\"ym\">apply</MenuEntry>";
ScriptMenu += "<MenuEntry Id=\"i\">Version Information</MenuEntry>";
}
ScriptMenu += "</ScriptMenu>";
return ScriptMenu;
}
function OnEvent_Uninitialize(MessengerExit)
{
}
I was using * for examples in the code so it was shorter