What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Making a /command

Making a /command
Author: Message:
Suma
New Member
*


Posts: 7
33 / Male / –
Joined: Aug 2006
O.P. Making a /command
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
08-10-2006 01:11 PM
Profile E-Mail PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
RE: Making a /command
Have a look at the PlusScriptWiki for information about adding commands.
[Image: markee.png]
08-10-2006 01:14 PM
Profile PM Find Quote Report
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
36 / Male / –
Joined: May 2004
Status: Away
RE: Making a /command
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 '';
  }
}

08-10-2006 01:19 PM
Profile E-Mail PM Find Quote Report
Suma
New Member
*


Posts: 7
33 / Male / –
Joined: Aug 2006
O.P. RE: RE: Making a /command
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?
08-10-2006 01:24 PM
Profile E-Mail PM Web Find Quote Report
Veggie
Full Member
***

Avatar

Posts: 415
Reputation: 21
37 / Male / Flag
Joined: Sep 2004
RE: Making a /command
http://mpscripts.net/docs.php?p=ref-plusevents-ongetscriptcommands.htm
08-10-2006 01:28 PM
Profile E-Mail PM Web Find Quote Report
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
36 / Male / –
Joined: May 2004
Status: Away
RE: Making a /command
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
08-10-2006 01:28 PM
Profile E-Mail PM Find Quote Report
Suma
New Member
*


Posts: 7
33 / Male / –
Joined: Aug 2006
O.P. RE: RE: Making a /command
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;
}

08-10-2006 01:33 PM
Profile E-Mail PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: Making a /command
You can also add it to the ScriptInfo.xml;)
08-10-2006 01:39 PM
Profile E-Mail PM Find Quote Report
Suma
New Member
*


Posts: 7
33 / Male / –
Joined: Aug 2006
O.P. RE: RE: Making a /command
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
08-10-2006 01:43 PM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Making a /command
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 ;)

This post was edited on 08-10-2006 at 03:34 PM by RaceProUK.
[Image: spartaafk.png]
08-10-2006 03:32 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On