Shoutbox

problem with invalid command - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: problem with invalid command (/showthread.php?tid=83570)

problem with invalid command by Zeelia on 05-06-2008 at 11:08 PM

<For moderators: please move this thread to the appropriate forum if it is not on the appropriate forum>

Hi!
I have made an command and an action for the command but when i try the command in an chat window the action works and all, i get an Messenger Plus toast but i also get the invalid command prompt which tells me something about "invalid command... if you weren't intending on writing an command start with double-slash '//"
so i need help to get rid of that invalid command prompt, here is my code:

code:
//vars
var appenable = "no";

function OnEvent_ChatWndSendMessage(ChatWnd, sMessage)
{
    if(sMessage=="/shortopener enable") {
        appenable = "yes";
        return(MsgPlus.DisplayToast("Shortopener :: Enable", "Shortopener enabled!"));
    }
}

function OnGetScriptCommands()
{
    var Commands = "<ScriptCommands>";
    Commands += "<Command>";
    Commands += "<Name>shortopener enable</Name>";
            Commands += "<Description>Shortopener \n Enables the shortopener, must be written before starting to use Shortopener</Description>";
    Commands += "</Command>";
    Commands += "</ScriptCommands>";
    return Commands;
}


its not a really big thing but its really irritating when you want to type in the command and get the unnecessary prompt when the command does its work so please help me
RE: problem with invalid command by roflmao456 on 05-06-2008 at 11:46 PM

code:
var appenable = false;

function OnEvent_ChatWndSendMessage(ChatWnd, sMessage){
if(sMessage.substr(0,12)=="/shortopener") {
switch(sMessage.substr(13)){
case "enable":
appenable = true;
break;
case "disable":
appenable = false;
break;
default:
appenable = !appenable;
}
MsgPlus.DisplayToast("appenable: " + appenable, "shortopener");
return "";
}
}

function OnGetScriptCommands(){
var Commands = "<ScriptCommands>";
Commands += "<Command>";
Commands += "<Name>shortopener</Name>";
Commands += "<Description>Shortopener \n Enables the shortopener, must be written before starting to use Shortopener</Description>";
Commands += "<Parameters>&lt;enable or disable&gt;</Parameters>";
Commands += "</Command>";
Commands += "</ScriptCommands>";
return Commands;
}


i would use booleans ;)
and you have to return nothing otherwise it will show that error
RE: problem with invalid command by CookieRevised on 05-07-2008 at 01:04 AM

For more details and a working example of how the return value works and what effects it will give, see:
CookieRevised's reply to Gettin data from "/" commands

Which also includes a far better method of handling parameters, using regular expressions


RE: problem with invalid command by Zeelia on 05-07-2008 at 05:13 AM

Ok, thanks to both of you, you fixed my problem but did also give me ideas on how to improve my code, thanks!
//Zeelia