What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » How To Call Upon Random Files

Pages: (2): « First « 1 [ 2 ] Last »
How To Call Upon Random Files
Author: Message:
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: RE: How To Call Upon Random Files
quote:
Originally posted by Vexor
Ok then, I tried this from a while ago when i went to that site, and this is what i came up with.

and no surprises, but I cannot get it to work. it is simple, but well I hope it will get me started in loading random things from scripts.

any ideas how i can make this work?

I tried everything "I" can think of.

code:
function getaSound()
{
   var whichsound=get_random();

    var quote=new Array(2)
     quote[0]="Chimes.WAV";
     quote[1]="Ding.WAV";
  }
 
function OnEvent_ChatWndCreated(ChatWnd)
{
var ChatWndContacts = ChatWnd.Contacts;
if(ChatWndContacts.Count == 1)
{
var e = new Enumerator(ChatWndContacts);
var Contact = e.item();
{
MsgPlus.DisplayToastContact(Messenger.MyName , "Has Just Opened A Window With" , Contact.Name , getaSound );

}
}
}





well getaSound doesn't return a audio file... try something like:

code:
function getaSound()
{
   var whichsound=get_random();

    var quote=new Array(2)
     quote[0]="Chimes.WAV";
     quote[1]="Ding.WAV";
     return quote[whichsound];
}

 
07-24-2006 10:39 AM
Profile E-Mail PM Find Quote Report
Vexor
Full Member
***

Avatar
Pure Capital Gain

Posts: 162
Reputation: 7
42 / Male / –
Joined: Jan 2006
O.P. RE: How To Call Upon Random Files
How do i get my other function to open that command? as in from the
code:
MsgPlus.DisplayToastContact(Messenger.MyName , "Has Just Opened A Window With" , Contact.Name , sound[whichsound]);
I am trying this and it is not working.? is it wrong?
--EDIT--

ok I have been playing around a bit more and after pulling some old scripts apart, i managed to find a few with different out lays on how to trigger from a different function.

can you let me know what you thinka nd what ineed to change to get this to work.

code:

function getaSound(){
var whichsound=get_random();
var sound=new Array(2)
  sound[0]="CHIMES.WAV";
  sound[1]="LeaveMeAlone.mp3";
return sound[whichsound];
}

function OnEvent_ChatWndCreated(ChatWnd){
var ChatWndContacts = ChatWnd.Contacts;
if(ChatWndContacts.Count == 1)
{
  var e = new Enumerator(ChatWndContacts);
  var Contact = e.item();
  {
   MsgPlus.DisplayToastContact(Messenger.MyName , "Has Just Opened A Window With" , Contact.Name , "");
   getaSound();
  }
}
}



Really do need help.

This post was edited on 07-24-2006 at 11:24 AM by Vexor.
[Testing A Bunch Of Different Betas']
[Image: DaFuca.png]
07-24-2006 11:03 AM
Profile PM Find Quote Report
Pai
Full Member
***

w00t !

Posts: 203
Reputation: 2
– / Male / –
Joined: Sep 2003
RE: How To Call Upon Random Files
what's get_random() anyway ? to generate a random number you have to use Math.Random() ... unless you created a function to do this and named it get_random(), but as you didn't post them I have to ask :p

then, you don't use sound[whichsound] again in the toast, you first call the function and assign the result to a variable, which already contains the filename. Something like this:

code:
var fileName = getaSound();
MsgPlus.DisplayToastContact(Messenger.MyName , "Has Just Opened A Window With" , Contact.Name , fileName);

Remember, the files must be  in your script's directory. If you have them in a subdirectory like "sounds", you have to use:
code:
MsgPlus.DisplayToastContact(Messenger.MyName , "Has Just Opened A Window With" , Contact.Name , "sounds\"+fileName);
07-24-2006 11:25 AM
Profile PM Find Quote Report
Vexor
Full Member
***

Avatar
Pure Capital Gain

Posts: 162
Reputation: 7
42 / Male / –
Joined: Jan 2006
O.P. RE: How To Call Upon Random Files
code:
function get_random(){
var ranNum=Math.floor(Math.random()*2);
return ranNum;
}

function getaSound(){
var whichSound=get_random();

var sound=new Array(2)
sound[0]="CHIMES.WAV";
sound[1]="LeaveMeAlone.mp3";
alert(sound[whichSound]);
}

function OnEvent_ChatWndCreated(ChatWnd){
var ChatWndContacts = ChatWnd.Contacts;
if(ChatWndContacts.Count == 1)
{
  var e = new Enumerator(ChatWndContacts);
  var Contact = e.item();
  {
   var fileName = getaSound();
   MsgPlus.DisplayToastContact(Messenger.MyName , "Has Just Opened A Window With" , Contact.Name , fileName);
  }
}
}





This still doe snot work and Ihave all that you have said to put in there. what am i missing here?

--EDIT--

code:
function getaSound(){
var whichSound=get_random();

var sound=new Array(2)
sound[0]="CHIMES.WAV";
sound[1]="LeaveMeAlone.mp3";
alert(sound[whichSound]);
}
was ment to be
code:
function getaSound(){
var whichSound=get_random();

var sound=new Array(2)
sound[0]="CHIMES.WAV";
sound[1]="LeaveMeAlone.mp3";
return sound[whichSound];
}

Sorry for your trouble. I got it working now.

Thank you all so much.

This post was edited on 07-24-2006 at 11:40 AM by Vexor.
[Testing A Bunch Of Different Betas']
[Image: DaFuca.png]
07-24-2006 11:38 AM
Profile 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