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

Pages: (2): « First [ 1 ] 2 » Last »
is there somthing wrong with this script..?
Author: Message:
joosh00
New Member
*

Avatar

Posts: 12
30 / Male / Flag
Joined: Mar 2008
O.P. Huh?  is there somthing wrong with this script..?
Well ive started to creat this script, it sends random jokes when you tell it too. it all works fine exept for 1 bit, that bit is when you open a conversation and you click the script button its there but when i try and click on it it doesnt work, but it works if you type in the command. anyway please help...

Here is the script...

code:
//This script is created by Josh Brand
//Version - 1.0
//Released
//Last Updated
//Created for the Messenger Plus!

/*Changelog
0.1 - Script Created
0.2 - Made it functional
0.3 - Fixed most spelling/grammar mistakes
0.4 - Fixed bugs and some more grammar mistakes
0.5 - Fixed "unidentified" error =D (first real bug solved!)
0.6 - Added other insults!
0.7 - Added about window! =D
1.0 - Final Version! Finally!
*/

var sArray = new Array();
sArray[0] = "How did the blonde try to kill the bird? She threw it off a cliff.";
sArray[1] = "Did you hear about the blonde secretary who cut her fingers off so that she could write short hand?";
sArray[2] = "Your mom's so fat that Nasa octually orbits her.";
sArray[3] = "I'm not a steady drinker - my hand shakes too much.'";
sArray[4] = "Yo momma so ugly, she make blind muthafuckas cry.";
sArray[5] = "1 Tequila, 2 Tequila, 3 Tequila, Floor.";
sArray[6] = "How do you start an onion race?   Onion marks! Get set! Go!";
sArray[7] = "Your mom.";
sArray[8] = "Your mom owes me money, you douche!";
sArray[9] = "Just cause you went to prom with Merv the Perv.";
sArray[10] = "Your mom is like a brick, flat on both sides and gets laid by Mexicans.";
sArray[11] = "Your Mom has a really nice hat...";
sArray[12] = "Don't worry, Your Mom is still a virgin. You were a backdoor baby.";
sArray[13] = "Your mom is poop.";


function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    if(Message.substr(0,8).toLowerCase()=="/jokes"){
        var i = Math.floor((Math.random()*(sArray.length-1)));
        return "[c=blue]"+sArray[i]+"[/c]";
    }

}

function OnGetScriptCommands(){
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>Jokes</Name>';
            commands+='<Description>Sends a joke</Description>';
        commands+='</Command>';
        commands+='</ScriptCommands>';
    return commands;
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
    if(MenuItemId=="jk"){
        OriginWnd.SendMessage(OnEvent_ChatWndSendMessage("", "/jokes"));
    }
    if(MenuItemId=="about"){
        WndAbout = MsgPlus.CreateWnd("WndAbout.xml", "WndAbout");
    }
}

function OnGetScriptMenu(nLocation){
    var ScriptMenu = "<ScriptMenu>\n";
    if(nLocation===2){
        ScriptMenu    +=    "<MenuEntry Id=\"JK\">Jokes</MenuEntry>";
        ScriptMenu    +=    "<Separator/>";
    }
    ScriptMenu    +=    "<MenuEntry Id=\"about\">About</MenuEntry>";
    ScriptMenu    += "</ScriptMenu>";
    return ScriptMenu;
}


oh and 1 more thing... the about box works fine.

Thanks ~joosh00~
03-26-2008 04:34 PM
Profile E-Mail PM Find Quote Report
pollolibredegrasa
Full Member
***

Avatar
formerly fatfreechicken

Posts: 483
Reputation: 34
35 / Male / Flag
Joined: May 2005
RE: is there somthing wrong with this script..?
quote:
Originally posted by joosh00
code:
function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
    if(MenuItemId=="jk"){

       
code:
ScriptMenu    +=    "<MenuEntry Id=\"JK\">Jokes</MenuEntry>";


Scripting is case sensitive, so make these the same case and it should work fine :)

Hope this helps
;p

[Image: chickennana.gif] Vaccy is my thin twin! [Image: chickennana.gif]
03-26-2008 04:45 PM
Profile PM Find Quote Report
joosh00
New Member
*

Avatar

Posts: 12
30 / Male / Flag
Joined: Mar 2008
O.P. RE: is there somthing wrong with this script..?
OMG im such an idiot xD thanks it works now.. lol
03-26-2008 04:49 PM
Profile E-Mail PM Find Quote Report
Jesus
Scripting Contest Winner
****

Avatar
Koffie, my cat ;)

Posts: 623
Reputation: 15
38 / Male / Flag
Joined: Jul 2005
RE: is there somthing wrong with this script..?
quote:
Originally posted by joosh00
var i = Math.floor((Math.random()*(sArray.length-1)));
should be
code:
Math.floor(Math.random()*sArray.length);
otherwise the last item will never be used. Math.random() is always <1 so if you multiply it by 14 you'll get a number between 0 and 13.999etc, which makes a maximum of 13 because of the Math.floor() function.
Man is least himself when he is in his own person. Give him a mask and he will tell you the truth. (Oscar Wilde)
03-26-2008 05:09 PM
Profile PM Find Quote Report
joosh00
New Member
*

Avatar

Posts: 12
30 / Male / Flag
Joined: Mar 2008
O.P. RE: is there somthing wrong with this script..?
Thanks Jesus =P

1 more problem now it wont run and when i try and quit the preferences it says

quote:
Couldn't start script "Jokes".
The Script may be defective or you may not have the proper privileges to run scripts.

And here is an updated version of my script.

code:
//This script is created by Josh Brand
//Version - 0.1
//Released
//Last Updated
//Created for the Messenger Plus!

/*Changelog
0.1 - Script Created
*/

var sArray = new Array();
sArray[0] = "How did the blonde try to kill the bird? She threw it off a cliff.";
sArray[1] = "Did you hear about the blonde secretary who cut her fingers off so that she could write short hand?";
sArray[2] = "Your mom's so fat that Nasa octually orbits her.";
sArray[3] = "I'm not a steady drinker - my hand shakes too much.'";
sArray[4] = "Yo momma so ugly, she make blind muthafuckas cry.";
sArray[5] = "1 Tequila, 2 Tequila, 3 Tequila, Floor.";
sArray[6] = "How do you start an onion race?   Onion marks! Get set! Go!";
sArray[7] = "Your mom.";
sArray[8] = "Your mom owes me money, you douche!";
sArray[9] = "Just cause you went to prom with Merv the Perv.";
sArray[10] = "Your mom is like a brick, flat on both sides and gets laid by Mexicans.";
sArray[11] = "Your Mom has a really nice hat...";
sArray[12] = "Don't worry, Your Mom is still a virgin. You were a backdoor baby.";
sArray[13] = "Your mom is poop.";
sArray[14] = "Crime doesn't pay...Does that mean my job is a crime?";
sArray[15] = "What do you call a sheep with no legs?  A cloud.";
sArray[16] = "Do you know how to save a drowning lawyer?  No? Good!";
sArray[17] = "What do you call a dog with no legs? Doesn't matter... he won't come to you anyway!";
sArray[18] = "I love deadlines. I especially like the whooshing sound they make as they go flying by.";
sArray[19] = "Why are men like blenders?You need one, but you're not quite sure why. ";
sArray[20] = "Why are guys like lava lamps?  They're fun to watch, but not very bright!";
sArray[21] = "Yo mama so old she has Jesus' beeper number! ";
sArray[22] = "Yo mama's so stupid she can't pass a blood test.";
sArray[23] = "How many Marxists does it take to screw in a light bulb?   None, the seeds of revolution and change are within the lightbulb itself.";
sArray[24] = "Yo mama's so stupid, she put lipstick on her forehead, because she wanted to make up her mind";
sArray[25] = "Yo mama so short she has to use a ladder to pick up a dime.";
sArray[26] = "How do you make a blonde laugh on a Saturday?   Tell her a joke on a Wednesday.";
sArray[27] = "Yo mama's so fat that on her drivers licence it says picture continued on other side.";
sArray[28] = "What does a blonde say after her doctor tells her that she's pregnant.   Is it mine?";
sArray[29] = "Waiter! This coffee tastes like mud. Yes sir, its fresh ground.";
sArray[30] = "What do you call a fish with no eyes?  A fsh";
sArray[31] = "Why don't aliens eat clowns.  Because they taste funny. ";
sArray[32] = "Two snowmen are standing in a field. One says to the other : Funny, I smell carrots too".";
sArray[33] = "What do you get when you cross an elephant and a rhino? el-if-i-no ";
sArray[34] = "Two peanuts walk into a bar.   One was a salted.";
sArray[35] = "What do you call a woman with one leg?  Ilene";
sArray[36] = "WHAT DID THE GHOST SAY TO THE BEE?  BOO-BEE";
sArray[37] = "What do you call a man with no arms and no legs sitting on your front porch?   Matt";
sArray[38] = "What do you call a man with no arms and no legs sitting in a pool?   Bob";
sArray[39] = "Whats best about shagging Twenty - Eight year olds?  There is Twenty of them!";
sArray[40] = "If you lend someone $20, and never see that person again; it was probably worth it.";
sArray[41] = "Keep honking. I'm reloading";


function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    if(Message.substr(0,8).toLowerCase()=="/jokes"){
        var i = Math.floor((Math.random()*(sArray.length)));
        return "[c=blue]"+sArray[i]+"[/c]";
    }

}

function OnGetScriptCommands(){
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>Jokes</Name>';
            commands+='<Description>Sends a joke</Description>';
        commands+='</Command>';
        commands+='</ScriptCommands>';
    return commands;
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
    if(MenuItemId=="jk"){
        OriginWnd.SendMessage(OnEvent_ChatWndSendMessage("", "/jokes"));
    }
    if(MenuItemId=="about"){
        WndAbout = MsgPlus.CreateWnd("WndAbout.xml", "WndAbout");
    }
}

function OnGetScriptMenu(nLocation){
    var ScriptMenu = "<ScriptMenu>\n";
    if(nLocation===2){
        ScriptMenu    +=    "<MenuEntry Id=\"jk\">Jokes</MenuEntry>";
        ScriptMenu    +=    "<Separator/>";
    }
    ScriptMenu    +=    "<MenuEntry Id=\"about\">About</MenuEntry>";
    ScriptMenu    += "</ScriptMenu>";
    return ScriptMenu;
}

This post was edited on 03-26-2008 at 05:59 PM by joosh00.
03-26-2008 05:42 PM
Profile E-Mail PM Find Quote Report
joosh00
New Member
*

Avatar

Posts: 12
30 / Male / Flag
Joined: Mar 2008
O.P. RE: is there somthing wrong with this script..?
any1..?
03-27-2008 12:03 AM
Profile E-Mail PM Find Quote Report
pollolibredegrasa
Full Member
***

Avatar
formerly fatfreechicken

Posts: 483
Reputation: 34
35 / Male / Flag
Joined: May 2005
RE: is there somthing wrong with this script..?
The script Debugger shows
code:
Error: Unterminated string constant (code: -2146827273)
       File: test.js. Line: 44.
And looking at line 44 you have an extra ". After removing that it works for me.

code:
sArray[32] = "Two snowmen are standing in a field. One says to the other : Funny, I smell carrots too".";
Hope this helps :)
;p

[Image: chickennana.gif] Vaccy is my thin twin! [Image: chickennana.gif]
03-27-2008 12:10 AM
Profile PM Find Quote Report
joosh00
New Member
*

Avatar

Posts: 12
30 / Male / Flag
Joined: Mar 2008
O.P. RE: is there somthing wrong with this script..?
OMG thank you sooo much..is this good for my first script..?
03-27-2008 12:16 AM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: is there somthing wrong with this script..?
If this is your first script... very very good, imho. You have programmed before?

(PS: if you didn't already, turn debugging options in Plus!'s preferences on, so you can check such errors yourself ;))

This post was edited on 03-27-2008 at 01:17 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
03-27-2008 01:15 AM
Profile PM Find Quote Report
joosh00
New Member
*

Avatar

Posts: 12
30 / Male / Flag
Joined: Mar 2008
O.P. RE: is there somthing wrong with this script..?
yah this is my first script, ive not done any programming before, my friend helped me a bit though.

Ive finished the whole thing and im trying to package it but i dont get how too.. and advice..?
03-27-2008 01:32 AM
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » 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