Code for script with sounds |
Author: |
Message: |
Jumpfreakske
Junior Member
Hardstyle!!!
Posts: 62 Reputation: -7
32 / /
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 |
|
|
phalanxii
Full Member
Posts: 146 Reputation: 5
32 / /
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 |
|
|
Jumpfreakske
Junior Member
Hardstyle!!!
Posts: 62 Reputation: -7
32 / /
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 |
|
|
vikke
Senior Member
Posts: 900 Reputation: 28
31 / /
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 |
|
|
Menthix
forum admin
Posts: 5537 Reputation: 102
40 / /
Joined: Mar 2002
|
RE: Code for script with sounds
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.
|
|
01-28-2007 11:10 AM |
|
|
Jumpfreakske
Junior Member
Hardstyle!!!
Posts: 62 Reputation: -7
32 / /
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 |
|
|
NanaFreak
Scripting Contest Winner
Posts: 1476 Reputation: 53
32 / /
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 can you make my code work around that 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 |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
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 |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
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:
- 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.
This post was edited on 01-28-2007 at 11:31 AM by Matti.
|
|
01-28-2007 11:28 AM |
|
|
vikke
Senior Member
Posts: 900 Reputation: 28
31 / /
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
It's really advanced, and takes a lot of resources, nothing I recommend.
|
|
01-28-2007 11:54 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|