Code for script with sounds - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Code for script with sounds (/showthread.php?tid=71094)
Code for script with sounds by Jumpfreakske on 01-27-2007 at 03:50 PM
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????
RE: Code for script with sounds by phalanxii on 01-28-2007 at 06:26 AM
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.
RE: Code for script with sounds by Jumpfreakske on 01-28-2007 at 09:27 AM
do I have to put this between every sound?
or just at the end or the beginning?
RE: Code for script with sounds by vikke on 01-28-2007 at 09:32 AM
Do like this:
Send first sound
MsgPlus.AddTimer("Delay", 12000);
Send second sound
MsgPlus.AddTimer("Delay", 12000);
Send third
RE: Code for script with sounds by Menthix on 01-28-2007 at 11:10 AM
Jumpfreakske, please use the 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.
RE: Code for script with sounds by Jumpfreakske on 01-28-2007 at 11:12 AM
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?
RE: Code for script with sounds by NanaFreak on 01-28-2007 at 11:18 AM
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 can you make my code work around that seeing as its like almost my BDay
RE: Code for script with sounds by Felu on 01-28-2007 at 11:21 AM
NanaFreak: What if two contacts send Razzia one after the other? Wouldn't ChatWindow be changed?
RE: Code for script with sounds by Matti on 01-28-2007 at 11:28 AM
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:
- Play the first sound.
- Create the first timer, called "Delay1".
- Make a timer event.
- In the event, if the "Delay1" timer ends, play the second sound and create the second timer, "Delay2".
- 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.
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.
RE: Code for script with sounds by vikke on 01-28-2007 at 11:54 AM
The only way to fix this, (as I know) is to create a new thread, and use sleep . One thread per contact
It's really advanced, and takes a lot of resources, nothing I recommend.
RE: Code for script with sounds by Felu on 01-28-2007 at 11:57 AM
code: var ChatWnds = new Array();
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message == "Razzia"){
ChatWnd.SendMessage("/sound Dj Zany - Razzia");
ChatWnds[ChatWnds.length-1] = ChatWnd;
MsgPlus.AddTimer("Delay1"+[ChatWnds.length-1], 12000);
}
}
function OnEvent_Timer(TimerId){
switch(TimerId.substr(0,6)){
case "Delay1":
ChatWnds[TimerId.substr].SendMessage("/sound Dj Zany - Razzia 2");
MsgPlus.AddTimer("Delay2"+[TimerId.substr], 12000);
break;
case "Delay2":
ChatWnds[TimerId.substr].SendMessage("/sound Dj Zany - Razzia 3");
break;
}
}
There you go!
RE: Code for script with sounds by vikke on 01-28-2007 at 12:01 PM
Good job Felu!
RE: Code for script with sounds by Jumpfreakske on 01-29-2007 at 09:48 PM
Oke, it works, But I have a case where their are 6 sounds:
So when you typ a word, it wil send 6 sounds with delays.
But what if the person wants to stop those sounds after 3 or 4, or when he want to here something else.
because now he has to close the chatwindow to stop the sounds from playing, so I need something like this:
if message === QUIT
then do following thing: stop sounds!
can anyone make this for me?
|