ID:147485
 
im trying to play music within a certain area, i wanted to know what is so wrong with my code

Play_Song(S as sound)
set category = "Admin"
area()<<sound(S,1)
If you wanted to play a song in a certain area then you would need something along these lines;

area/sounds                              //This is the root for the sounds that will be played in an area.
    Forest                               // All sounds belonging to the forest go under this child root.
        Entered()                        // When a person/mob/client has "Entered()" this area you have put on your world the following sound will play to them.
            src << sound('FOREST.wav',1) // This is the sound that will play, and it will continue to "loop". If you wanted it not to loop, change the "1" to a "0" (zero).
        Exited()                         // Once the person/mob/client has "Exited()" the area, their sound will be stopped.
            src.stop_sfx()               // This procedure is called to make sure all the sound channels in the DreamSeeker are nulled.

mob/proc/stop_sfx()                      // This is the actual procedure that will be called once the person/mob/client has "Exited()" from the area you set.
    if(!src.key || !src.client) return   // If there is no client or no key being called by this check then the procedure will not proceed, therefore stopping it from continuously being ran, ultimately making it safe from crashing the server.

    src << sound(null, channel=1) // This makes channel 1 null, and stops all sounds playing on this channel if there are any playing.
    src << sound(null, channel=2) // This makes channel 2 null, and stops all sounds playing on this channel if there are any playing.
    src << sound(null, channel=3) // This makes channel 3 null, and stops all sounds playing on this channel if there are any playing.
    src << sound(null, channel=4) // This makes channel 4 null, and stops all sounds playing on this channel if there are any playing.
    src << sound(null, channel=5) // This makes channel 5 null, and stops all sounds playing on this channel if there are any playing.
    src << sound(null, channel=6) // This makes channel 6 null, and stops all sounds playing on this channel if there are any playing.
    src << sound(null, channel=7) // This makes channel 7 null, and stops all sounds playing on this channel if there are any playing.
    src << sound(null, channel=8) // This makes channel 8 null, and stops all sounds playing on this channel if there are any playing.


That will in general work with your game, though you can't just copy and paste it due to the indentations being incorrect.

If you have to give compliments, direct them to Spuzzum, as it was he who created that for me within EoE and he deserves full credits for it.

All I deserver credits for is basically the explanation for you, I know how that runs and I know what to do with it, though the explanations are there for you to learn from it.

Anyway, like I said, Spuzzum deserves full credit for this not I.

As for your procedure, you're going to have to "use" that verb manually, as that is what it seems to be, a verb.

You set it to the Admin category, which really it should even be as a verb if you want it played in a certain area for those who enter it.

Also, with you setting "S as sound" the calling "S" in the area(), I doubt you will get anything outputted because you technically set "sound" as a list.

So to play the sounds, you would need to create a list called "sound" and have your sounds in there in a list. After that you would need to manually pick the sound, and in general you're going the wrong way.

--Lee

[EDIT; Mellifluous] I made a slight modification from changing the "usr" to "src" within the "Entered()" and "Exited()" procedures.

It was a minor mistake played on my part and I should have known better, but thanks to Garthor this was sorted.
In response to Mellifluous
Except, you know, you shouldn't be using usr in Entered() or Exited().
In response to Garthor
Garthor wrote:
Except, you know, you shouldn't be using usr in Entered() or Exited().

Ya, they REALLY need to change that example in the reference. =\
In response to Goku72
It's there to throw off the weak-minded. *Laughs evilly on behalf of whoever typed up the DM Reference*
In response to Goku72
Goku72 wrote:
Garthor wrote:
Except, you know, you shouldn't be using usr in Entered() or Exited().

Ya, they REALLY need to change that example in the reference. =\

"They" did.

Lummox JR