What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Whats wrong with this?

Pages: (3): « First [ 1 ] 2 3 » Last »
Whats wrong with this?
Author: Message:
Hengy
Junior Member
**


Posts: 16
Joined: Jul 2006
O.P. Whats wrong with this?
I am a beginning scripter... I have had limited experience in BASIC, VB, C#. I am just trying to learn the jscript language...

Does anyone know whats wrong with this script?

code:
function OnEvent_ChatWndSendMessage(Wnd,Msg) {
    if(Msg == "!picknum") {
return "Pick a number between 1 and 100";
var rndnumber = Math.random() * 100;
}

function OnEvent_ChatWndReceiveMessage(Wnd,Msg,1) {
if(Msg == rndnumber) {
return rndnumber + "was the correct number."
}

Thanks
07-22-2006 08:00 PM
Profile PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: Whats wrong with this?
Your OnEvent_ChatWndReceiveMessage has incorrect parameters.

The first parameter is Chat window, yes, but the second is the name of the users sending the message, while the third one being the message itself. Finally, MessageKind is a variable and you can't not set 1 for that :)

So your codes should look like:
code:
function OnEvent_ChatWndReceiveMessage(Wnd,Sender,Msg,MsgKind){
    if(Msg == rndnumber) {
    return rndnumber + "was the correct number."
}


This post was edited on 07-22-2006 at 08:10 PM by Mnjul.
07-22-2006 08:07 PM
Profile PM Web Find Quote Report
Weyzza
Veteran Member
*****

Avatar
SoCal sunset > *

Posts: 1170
Reputation: 29
– / Male / –
Joined: May 2003
RE: Whats wrong with this?
quote:
Originally posted by Hengy
if(Msg == "!picknum") {
return "Pick a number between 1 and 100";
var rndnumber = Math.random() * 100;
}
You should not use return there.

Keyword "return" exits from the current function and returns a value from that function (form here)

And you have extra curly brackets, too :tongue:

This post was edited on 07-22-2006 at 08:13 PM by Weyzza.
Registered 7853 days, 3 hours, 13 minutes, 46 seconds ago.
Happy Birthday, WDZ

07-22-2006 08:07 PM
Profile PM Find Quote Report
Hengy
Junior Member
**


Posts: 16
Joined: Jul 2006
O.P. Huh?  RE: Whats wrong with this?
so i've got this now, but it still doen't work...
(please be patient with me...:$)

code:
function OnEvent_ChatWndSendMessage(Wnd,Msg) {
    if(Msg == "!picknum") {
    return Begin();
}

function Begin() {
    var rndnumber = Math.random() * 100;
    return "Pick a number between 1 and 100.";
}

function OnEvent_ChatWndReceiveMessage(Wnd,Sender,Msg,MsgKind){
if(Msg == rndnumber) {
    return rndnumber + "was the correct number.";
}


I am afriad I don't see the extra brackets... :huh:
07-22-2006 08:24 PM
Profile PM Find Quote Report
Weyzza
Veteran Member
*****

Avatar
SoCal sunset > *

Posts: 1170
Reputation: 29
– / Male / –
Joined: May 2003
RE: Whats wrong with this?
quote:
Originally posted by Hengy
I am afriad I don't see the extra brackets...
What about the ones after each if statement?

Edit: I'm sorry if I sound harsh, but that's truly not my intention :p

This post was edited on 07-22-2006 at 08:34 PM by Weyzza.
Registered 7853 days, 3 hours, 13 minutes, 46 seconds ago.
Happy Birthday, WDZ

07-22-2006 08:27 PM
Profile PM Find Quote Report
Hengy
Junior Member
**


Posts: 16
Joined: Jul 2006
O.P. RE: Whats wrong with this?
Go easy! Im a beginner...
and it still doesn't work...:$
07-22-2006 08:33 PM
Profile PM Find Quote Report
Aeryn
Full Member
***

Avatar

Posts: 230
Reputation: 28
– / Female / –
Joined: Jun 2005
Status: Away
RE: Whats wrong with this?
It's easier to see bracket mismatches if you put each bracket on a line by itself and indent your code.


code:
function OnEvent_ChatWndReceiveMessage(Wnd,Sender,Msg,MsgKind)
{
  if(Msg == rndnumber)
  {
    return rndnumber + "was the correct number.";
  }


as you can see there's a missing bracket for the function header.

so it should be like this:

code:
function OnEvent_ChatWndReceiveMessage(Wnd,Sender,Msg,MsgKind)
{
  if(Msg == rndnumber)
  {
    return rndnumber + "was the correct number.";
  }
}


Edit: actually it's the exact same thing with the first section of your code too:

code:
function OnEvent_ChatWndSendMessage(Wnd,Msg) {
if(Msg == "!picknum") {
return Begin();
}

there should be one more bracket in the end again.

This post was edited on 07-22-2006 at 08:52 PM by Aeryn.
07-22-2006 08:40 PM
Profile PM Find Quote Report
Hengy
Junior Member
**


Posts: 16
Joined: Jul 2006
O.P. RE: Whats wrong with this?
Thanks! It works!
07-22-2006 08:53 PM
Profile PM Find Quote Report
Aeryn
Full Member
***

Avatar

Posts: 230
Reputation: 28
– / Female / –
Joined: Jun 2005
Status: Away
RE: Whats wrong with this?
No problem, glad it works now. :)
07-22-2006 09:00 PM
Profile PM Find Quote Report
Hengy
Junior Member
**


Posts: 16
Joined: Jul 2006
O.P. RE: Whats wrong with this?
Sorry to bother u all again... but in this thing of code, when I say "!an", it come back "undefined"...

code:
function OnEvent_ChatWndSendMessage(Wnd,Msg)
{
if(Msg == "!pick")
    {
    var rndnumber = Math.floor(Math.random()*5);
    return "Pick a number between 0 and 4";
    }
if(Msg == "!an")
    {
    return rndnumber + "was the correct number.";
    }
}


Thanks
07-22-2006 10:33 PM
Profile PM Find Quote Report
Pages: (3): « First [ 1 ] 2 3 » Last »
« 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