Making a /command |
Author: |
Message: |
Suma
New Member
Posts: 7
33 / / –
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
|
|
08-10-2006 01:11 PM |
|
|
markee
Veteran Member
Posts: 1622 Reputation: 50
36 / /
Joined: Jan 2006
|
RE: Making a /command
Have a look at the PlusScriptWiki for information about adding commands.
|
|
08-10-2006 01:14 PM |
|
|
alexp2_ad
Scripting Contest Winner
Who love the chocolate?
Posts: 691 Reputation: 26
37 / / –
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
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 |
|
|
Suma
New Member
Posts: 7
33 / / –
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
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 |
|
|
Veggie
Full Member
Posts: 415 Reputation: 21
37 / /
Joined: Sep 2004
|
|
08-10-2006 01:28 PM |
|
|
alexp2_ad
Scripting Contest Winner
Who love the chocolate?
Posts: 691 Reputation: 26
37 / / –
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 |
|
|
Suma
New Member
Posts: 7
33 / / –
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 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 |
|
|
J-Thread
Full Member
Posts: 467 Reputation: 8
– / / –
Joined: Jul 2004
|
RE: Making a /command
You can also add it to the ScriptInfo.xml
|
|
08-10-2006 01:39 PM |
|
|
Suma
New Member
Posts: 7
33 / / –
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
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><flash count></Parameters>";
ScriptCommands += "</Command>";
ScriptCommands += "</ScriptCommands>";
return ScriptCommands;
}
and it works tnx
|
|
08-10-2006 01:43 PM |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
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.
|
|
08-10-2006 03:32 PM |
|
|
|