Problem with my script. |
Author: |
Message: |
vikke
Senior Member
Posts: 900 Reputation: 28
31 / /
Joined: May 2006
|
RE: Problem with my script.
But there's one syntax error, if you look,
code: return ";
should be code: return "";
|
|
08-12-2006 08:38 AM |
|
|
TheTomb
New Member
Posts: 6
Joined: Aug 2006
|
O.P. RE: Problem with my script.
code: function OnEvent_Initialize(MessengerStart)
{
}
function OnEvent_Uninitialize(MessengerExit)
{
}
function OnGetScriptCommands(){
var commands = '<ScriptCommands>';
commands+='<Command>';
commands+='<Name>interpretate</Name>';
commands+='<Description>Interpretate your contact by stealing their name!</Description>';
commands+='<Parameters/>';
commands+='</Command>';
commands+='</ScriptCommands>';
return commands;
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if(Message.substr(0,13) == "/interpretate")
{
var Contacts = ChatWnd.Contacts;
var e = new Enumerator(Contacts); for(; !e.atEnd(); e.moveNext())
var Blah = e.item()
Messenger.MyName = Blah.Name;
MsgPlus.DisplayToast("Success!", "You have the same name as your contact!");
return '';
}
}
That is my Interpreter.js
code: <?xml version="1.0" encoding="UTF-16"?>
<ScriptInfo xmlns="urn:msgpluscripts" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Information>
<Name>Interpreter</Name>
<Description>Steal the name of your contact!</Description>
<AboutUrl>http://thetomb.co.uk</AboutUrl>
</Information>
</ScriptInfo>
Thats my ScriptInfo.xml
EDIT: Fixed, the Script wasnt activated Sorry for wasting your time.
Felu that works fine
This post was edited on 08-12-2006 at 08:42 AM by TheTomb.
|
|
08-12-2006 08:39 AM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: Problem with my script.
TheTomb that Interpreter.js works perfectly fine . Dont know why is it that you cant use that code?
|
|
08-12-2006 08:42 AM |
|
|
Eljay
Elite Member
:O
Posts: 2949 Reputation: 77
– / / –
Joined: May 2004
|
RE: Problem with my script.
quote: Originally posted by -!Felu!-
Whats the difference Eljay? Just Blah is Contact
When using for() without opening and closing braces, only the first statement is executed (in this case, "var Blah = e.item()"). for multiple statements in a statement/loop you need to enclose the code in {} for it to be executed (otherwise where would the script know when to stop?)
or maybe thats just javascript not jscript, but i doubt it. its neater anyway
|
|
08-12-2006 08:50 AM |
|
|
TheTomb
New Member
Posts: 6
Joined: Aug 2006
|
O.P. RE: Problem with my script.
OK that problem is fixed but i've tried to add another command which changed your name back, heres my code.
code: var OldName = "";
function OnEvent_Initialize(MessengerStart)
{
}
function OnEvent_Uninitialize(MessengerExit)
{
}
function OnGetScriptCommands(){
var commands = '<ScriptCommands>';
commands+='<Command>';
commands+='<Name>intstealname</Name>';
commands+='<Description>Steal your contacts name!</Description>';
commands+='<Parameters/>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>intoldname</Name>';
commands+='<Description>Change your name back to the previous name!</Description>';
commands+='<Parameters/>';
commands+='</Command>';
commands+='</ScriptCommands>';
return commands;
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if(Message.substr(0,13) == "/intstealname")
{
OldName = Messenger.MyName;
var Contacts = ChatWnd.Contacts;
var e = new Enumerator(Contacts); for(; !e.atEnd(); e.moveNext())
var Blah = e.item()
Messenger.MyName = Blah.Name;
MsgPlus.DisplayToast("Interpreter 1.0", "You are now interpretating your contact!");
return '';
}
if(Message.substr(0,9) == "/intoldname")
{
if(OldName = ""){
MsgPlus.DisplayToast("Interpreter 1.0", "You dont have an old name!");
}else{
Messenger.MyName = OldName;
MsgPlus.DisplayToast("Interpreter 1.0", "Your name is back to normal!");
return '';
}
}
}
It comes up with the same error and the script is enabled.
This post was edited on 08-12-2006 at 09:05 AM by TheTomb.
|
|
08-12-2006 09:05 AM |
|
|
Shondoit
Full Member
Hmm, Just Me...
Posts: 227 Reputation: 15
36 / /
Joined: Jul 2006
|
RE: Problem with my script.
The last 'return "" ' should be outside the brackets, so it works for both when OldName has, and hasn't got a value
You forgot the brackets { } again, this should work:
code: var OldName = "";
function OnGetScriptCommands(){
var commands = '<ScriptCommands>';
commands+='<Command>';
commands+='<Name>intstealname</Name>';
commands+='<Description>Steal your contacts name!</Description>';
commands+='<Parameters/>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>intoldname</Name>';
commands+='<Description>Change your name back to the previous name!</Description>';
commands+='<Parameters/>';
commands+='</Command>';
commands+='</ScriptCommands>';
return commands;
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
if(Message.substr(0,13) == "/intstealname"){
OldName = Messenger.MyName;
var Contacts = ChatWnd.Contacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext()){
var Contact = e.item()
Messenger.MyName = Contact.Name;
MsgPlus.DisplayToast("Interpreter 1.0", "You are now interpretating your contact!");
return '';
}
}else if(Message.substr(0,9) == "/intoldname"){
if(OldName = ""){
MsgPlus.DisplayToast("Interpreter 1.0", "You dont have an old name!");
}else{
Messenger.MyName = OldName;
MsgPlus.DisplayToast("Interpreter 1.0", "Your name is back to normal!");
}
return '';
}
}
This post was edited on 08-12-2006 at 01:47 PM by Shondoit.
|
|
08-12-2006 01:44 PM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: Problem with my script.
Here's the fixed code. See BOLD letters for the change made.
code: var OldName;
function OnGetScriptCommands(){
var commands = '<ScriptCommands>';
commands+='<Command>';
commands+='<Name>intstealname</Name>';
commands+='<Description>Steal your contacts name!</Description>';
commands+='<Parameters/>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>intoldname</Name>';
commands+='<Description>Change your name back to the previous name!</Description>';
commands+='<Parameters/>';
commands+='</Command>';
commands+='</ScriptCommands>';
return commands;
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if(Message.substr(0,13) == "/intstealname")
{
OldName = Messenger.MyName;
var Contacts = ChatWnd.Contacts;
var e = new Enumerator(Contacts); for(; !e.atEnd(); e.moveNext())
var Blah = e.item()
Messenger.MyName = Blah.Name;
MsgPlus.DisplayToast("Interpreter 1.0", "You are now interpretating your contact!");
return '';
}
if(Message.substr(0,11) == "/intoldname")
{
if(OldName == null){
MsgPlus.DisplayToast("Interpreter 1.0", "You dont have an old name!");
}else{
Messenger.MyName = OldName;
MsgPlus.DisplayToast("Interpreter 1.0", "Your name is back to normal!");
}
return '';
}
}
This post was edited on 08-12-2006 at 02:19 PM by Felu.
|
|
08-12-2006 02:16 PM |
|
|
Pages: (2):
« First
«
1
[ 2 ]
Last »
|
|