Shoutbox

Making a /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: Making a /command (/showthread.php?tid=64740)

Making a /command by Suma on 08-10-2006 at 01:11 PM

I want to make a /command, /uit. but is't not working...
this is what I use now:

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{

  if(Message == "/uit")
  {
  toast("blaat","ghehe uit");
  }
}

can somebody help me to make the /uit command?

Thanks:D
RE: Making a /command by markee on 08-10-2006 at 01:14 PM

Have a look at the PlusScriptWiki for information about adding commands.


RE: Making a /command by alexp2_ad on 08-10-2006 at 01:19 PM

quote:
Originally posted by Suma
I want to make a /command, /uit. but is't not working...
this is what I use now:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{

  if(Message == "/uit")
  {
  toast("blaat","ghehe uit");
  }
}

can somebody help me to make the /uit command?

Thanks:D

That is sort of correct, but since you don't return anything and the function is invalid, it won't work, you want:

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{

  if(Message == "/uit")
  {
  MsgPlus.DisplayToast("blaat","ghehe uit");
  return '';
  }
}


RE: RE: Making a /command by Suma on 08-10-2006 at 01:24 PM

quote:
Originally posted by alexp2_ad
quote:
Originally posted by Suma
I want to make a /command, /uit. but is't not working...
this is what I use now:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{

  if(Message == "/uit")
  {
  toast("blaat","ghehe uit");
  }
}

can somebody help me to make the /uit command?

Thanks:D

That is sort of correct, but since you don't return anything and the function is invalid, it won't work, you want:

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{

  if(Message == "/uit")
  {
  MsgPlus.DisplayToast("blaat","ghehe uit");
  return '';
  }
}


but why doesn't it appear in the /list?
RE: Making a /command by Veggie on 08-10-2006 at 01:28 PM

http://mpscripts.net/docs.php?p=ref-plusevents-ongetscriptcommands.htm


RE: Making a /command by alexp2_ad on 08-10-2006 at 01:28 PM

You have to add it to the list by putting something like this in your code:

code:
function OnGetScriptCommands(){
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>pause</Name>';
            commands+='<Description>'+langstrings[94]+'</Description>';
            commands+='<Parameters/>';
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;
}


For more on commands:
http://mpwiki.net/Script_Commands
RE: RE: Making a /command by Suma on 08-10-2006 at 01:33 PM

quote:
Originally posted by alexp2_ad
You have to add it to the list by putting something like this in your code:

code:
function OnGetScriptCommands(){
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>pause</Name>';
            commands+='<Description>'+langstrings[94]+'</Description>';
            commands+='<Parameters/>';
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;
}


For more on commands:
http://mpwiki.net/Script_Commands

I don't get it :S because the code in this code:
code:
function OnEvent_Initialize( Messenger )
{

  if(!LoadInstall())
  {
 
    LoadInstall();
 
  }
 
}

function OnEvent_Signin(Email)
{

  if(ReadReg("todaysDate") != datum())
  {

    WriteReg("todaysDate", datum());
    WriteReg("today", 0);

  }
 
  WriteReg("today", parseInt(ReadReg("today"))+1);
  WriteReg("total", parseInt(ReadReg("total"))+1);

  if(LoadInstall())
  {

    tostie("Overzicht - Totaal", data("totaal"));
    tostie("Overzicht - Vandaag", data("vandaag"));

  }
  else
  {

    tostie("Hersteld", "Het script heeft zich hersteld van een fout!");

  }

}

function datum()
{

  var datum = new Date();
  var month = datum.getMonth()+1;

  if(month < 9)
  {

    month = "0" + month;

  }

  var vandaag = datum.getDate() + "/" + month + "/" + datum.getYear(); 
  return vandaag;

}

function WriteReg(titel, value)
{

  var Shell = new ActiveXObject("WScript.Shell");
  var ValRegPath = MsgPlus.ScriptRegPath + Messenger.MyUserId + "\\" + titel;
  Shell.RegWrite(ValRegPath, value);

}

function ReadReg(titel)
{

  var Shell = new ActiveXObject("WScript.Shell");
  var ValRegPath = MsgPlus.ScriptRegPath + Messenger.MyUserId + "\\" + titel;
 
  try
  {

    BackDo = Shell.RegRead( ValRegPath );
                 
    if ( BackDo != '' )
    {
                 
      return Shell.RegRead(ValRegPath);
                         
    }
    else
    {
                 
      return false;
                         
    }
                 
  }
  catch( exception )
  {

    return false;
                 
   }

}

function LoadInstall()
{

  var i = 0;

  if(!ReadReg("todaysDate"))
  {

    WriteReg("todaysDate", datum());
    i++;

  }

  if(!ReadReg("total"))
  {

    WriteReg("total", 1);
    i++;

  }

  if(!ReadReg("today"))
  {

    WriteReg("today", 1);
    i++;

  }

  if(i == 0) {

    return true;

  }
  else
  {

    return false;

  }

}

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{

  if(Message == "/singelogd")
  {

    if(LoadInstall()){

      if(ReadReg("todaysDate") != datum())
      {

        WriteReg("todaysDate", datum());
        WriteReg("today", 0);

      }

      tostie("Overzicht - Totaal", data("totaal"));
      tostie("Overzicht - Vandaag", data("vandaag"));

    }
    else
    {

      tostie("Hersteld", "Het script heeft zich hersteld van een fout!");

    }

    return "";
   
  }

}

function tostie(titel, msg)
{

  MsgPlus.DisplayToast(titel, msg);

}

function data(type)
{

  if(type == "vandaag")
  {

    return "Je bent vandaag al " + ReadReg("today") + " keer ingelogd.";

  }
  else if(type == "totaal")
  {

    return "In het totaal ben je al " + ReadReg("total") + " keer ingelogd.";

  }

}

does appeard in the /list without :
code:
function OnGetScriptCommands(){
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>pause</Name>';
            commands+='<Description>'+langstrings[94]+'</Description>';
            commands+='<Parameters/>';
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;
}


RE: Making a /command by J-Thread on 08-10-2006 at 01:39 PM

You can also add it to the ScriptInfo.xml;)


RE: RE: Making a /command by Suma on 08-10-2006 at 01:43 PM

quote:
Originally posted by J-Thread
You can also add it to the ScriptInfo.xml;)

ooo, tnx:D
now am I using:
code:
function OnGetScriptCommands()
{
    var ScriptCommands = "<ScriptCommands>";
    ScriptCommands    +=     "<Command>";
    ScriptCommands    +=         "<Name>beep</Name>";
    ScriptCommands    +=         "<Description>Play a beep sound</Description>";
    ScriptCommands    +=     "</Command>";
    ScriptCommands    +=     "<Command>";
    ScriptCommands    +=         "<Name>flash</Name>";
    ScriptCommands    +=         "<Description>Flashes the window</Description>";
    ScriptCommands    +=         "<Parameters>&lt;flash count&gt;</Parameters>";
    ScriptCommands    +=     "</Command>";
    ScriptCommands    += "</ScriptCommands>";

    return ScriptCommands;
}

and it works:D tnx:D
RE: Making a /command by RaceProUK on 08-10-2006 at 03:32 PM

quote:
Originally posted by Suma
Message == "/uit"
A more reliable way would be to use Message.match("^/uit"). Then it doesn't matter if you type anything after the command.

^/uit is a regular expression. This one is very simple: '^' means start of line, and '/uit' means literally '/uit'.

A more complex regex is ^.*\A0{(.*)}$. It's very useful: see if you can guess what it matches ;)