What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Code for script with sounds

Pages: (2): « First [ 1 ] 2 » Last »
Code for script with sounds
Author: Message:
Jumpfreakske
Junior Member
**

Avatar
Hardstyle!!!

Posts: 62
Reputation: -7
32 / Male / Flag
Joined: Jan 2007
O.P. Code for script with sounds
I have still a little question:
I'm making a script, and when you type one of te available
songs, then it wil play automaticly a peace of 12 seconds from that song, en I progressed over 1000 songs,
but somethimes I have more then 1 sound of a song,
And when someone type te title of the song, they get the 2 or more sounds, but only the first wil play....

Now my Question is:
Is there a code/way that the second or third sound will play automaticly after the first one,
- or is there a code that can delay de second sound with 12 seconds, en also the third one with 12 seconds after the second one????
01-27-2007 03:50 PM
Profile E-Mail PM Web Find Quote Report
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
RE: Code for script with sounds
Yes, this is perfectly possible using timers.

Use MsgPlus.AddTimer(TimerId, Elapse) to create a timer called TimerId which lasts for Elapse milliseconds (1/1000 of a second). When the timer expires, the event OnEvent_Timer(TimerId) will be called.

For example, to delay for 12 seconds then do something, you might use:
code:
MsgPlus.AddTimer("Delay", 12000);

function OnEvent_Timer(TimerId) {
   if (TimerId == "Delay") {
      // Do something!
   }
}
Hopefully my explanation is understandable. If you still have problems, you might want to have a read of the scripting documentation.
01-28-2007 06:26 AM
Profile PM Find Quote Report
Jumpfreakske
Junior Member
**

Avatar
Hardstyle!!!

Posts: 62
Reputation: -7
32 / Male / Flag
Joined: Jan 2007
O.P. RE: Code for script with sounds
do I have to put this between every sound?
or just at the end or the beginning?
01-28-2007 09:27 AM
Profile E-Mail PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: Code for script with sounds
Do like this:
Send first sound
MsgPlus.AddTimer("Delay", 12000);
Send second sound
MsgPlus.AddTimer("Delay", 12000);
Send third
01-28-2007 09:32 AM
Profile E-Mail PM Find Quote Report
Menthix
forum admin
*******

Avatar

Posts: 5537
Reputation: 102
40 / Male / Flag
Joined: Mar 2002
RE: Code for script with sounds
Jumpfreakske, please use the [Image: edit.gif] button under your post the next time to change your post or things to it.

Don't make multiple posts in a row in the same topic without somebody posting between it, this is considered double-posting and against the rules.
Finish the problem
Menthix.net | Contact Me
01-28-2007 11:10 AM
Profile E-Mail PM Web Find Quote Report
Jumpfreakske
Junior Member
**

Avatar
Hardstyle!!!

Posts: 62
Reputation: -7
32 / Male / Flag
Joined: Jan 2007
O.P. RE: Code for script with sounds
Alright, but I have stil to put this sentence:  MsgPlus.AddTimer("Delay", 12000); alway after the firest, the second en something the third sound (if I have 4sounds at ones)

if(Message == "Razzia")
{
ChatWnd.SendMessage("/sound Dj Zany - Razzia");
   MsgPlus.AddTimer("Delay", 12000);
ChatWnd.SendMessage("/sound Dj Zany - Razzia 2");
   MsgPlus.AddTimer("Delay", 12000);
ChatWnd.SendMessage("/sound Dj Zany - Razzia 3");
}

something Likes This?


RE: Code for script with sounds

If Somebody types Razzia, I wil automaticly send the
message /sound Dj Zany - Razzia,
and then it will send those 3 sounds...
but there is no delay.

Could Somebody help me with this?
01-28-2007 11:12 AM
Profile E-Mail PM Web Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: Code for script with sounds
code:
function OnEvent_ChatWndReceiveMessage(Origin, ChatWnd, Message){
ChatWindow = ChatWnd
  if(Origin != Messenger.MyName && Message == "Razzia"){
    ChatWindow.SendMessage("/sound Dj Zany - Razzia");
    MsgPlus.AddTimer("Delay1", 12000 /*length of sound*/);
  }
}

function OnEvent_Timer(TimerId){
  if(TimerId == "Delay1"){
    ChatWindow.SendMessage("/sound Dj Zany - Razzia 2");
    MsgPlus.AddTimer("Delay2", 12000 /*length of sound*/);
  }
  if(TimerId == "Delay2"){
    ChatWindow.SendMessage("/sound Dj Zany - Razzia 3");
  }
}

i am quite sure that should work... you just have to make the 12000 the length of the sound (as i have said in the code)

quote:
Originally posted by Felu
NanaFreak: What if two contacts send Razzia one after the other? Wouldn't ChatWindow be changed?
woops :S can you make my code work around that (a) seeing as its like almost my BDay

This post was edited on 01-28-2007 at 11:24 AM by NanaFreak.
01-28-2007 11:18 AM
Profile PM Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
Joined: Apr 2006
Status: Away
RE: Code for script with sounds
NanaFreak: What if two contacts send Razzia one after the other? Wouldn't ChatWindow be changed?
01-28-2007 11:21 AM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Code for script with sounds
quote:
Originally posted by Jumpfreakske
if(Message == "Razzia")
{
ChatWnd.SendMessage("/sound Dj Zany - Razzia");
   MsgPlus.AddTimer("Delay", 12000);
ChatWnd.SendMessage("/sound Dj Zany - Razzia 2");
   MsgPlus.AddTimer("Delay", 12000);
ChatWnd.SendMessage("/sound Dj Zany - Razzia 3");
}
The reason why this isn't working is because MsgPlus.AddTimer only adds a timer. It's not like the Sleep function that it'll make the script pauze for a certain period. Therefore, the right way of thinking here is:
  1. Play the first sound.
  2. Create the first timer, called "Delay1".
  3. Make a timer event.
  4. In the event, if the "Delay1" timer ends, play the second sound and create the second timer, "Delay2".
  5. Still in the event, if the "Delay2" timer ends, play the last sound.
And that's what NanaFreak's code does. :)

Just a note: the whole cyclus should be executed before a new "Razzia" message is received. Otherwise, the first cyclus will be stopped and the new one will play. This could lead to complications when this happens in two chat windows.

EDIT: Yes Felu, that's what I wanted to explain but you've beaten me. :P
When the first message arrives, the first sound will play. When another contact sends the message, the first sound will play in the new window but the other contact won't hear the other two. Also, when you close the window before all sounds are sent you get an error because the ChatWindow is invalid.

This post was edited on 01-28-2007 at 11:31 AM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-28-2007 11:28 AM
Profile E-Mail PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: Code for script with sounds
The only way to fix this, (as I know) is to create a new thread, and use sleep :). One thread per contact :D

It's really advanced, and takes a lot of resources, nothing I recommend.
01-28-2007 11:54 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