Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Szuran

I'd like to write a script that plays a sound upon entering the level.

Question

I'd like to have a unique sound opening a certain level, for example: Map 02 opens with a maniacal laughter that only plays once.

 

Could you show me how to write an ACS script to do so?

 

Let's assume the sound file is called SOUND and is in the folder GEETINGS in pk3.

 

#Library "GREETINGS"
#Include "ZCommon.ACS"

Script "GREETINGS" ENTER NET

 

That's how far my knowledge goes, and it's probaby wrong already. What would be next?

Edited by Szuran

Share this post


Link to post

13 answers to this question

Recommended Posts

  • 0

Open the script editor in your map editor (F10 in the case of UDB) and type it there, then compile it with the "compile script" button in the same script editor window, this way you can have per-map scripts.

#Include "ZCommon.ACS"

Script "GREETING" OPEN 
{  
ActivatorSound("greets",127); 
}

 

Share this post


Link to post
  • 0

After you have imported your sound file and made sure it's defined for use in game in the SNDINFO lump, you can use either use PlaySound or ActivatorSound to play it, I'd recommend changing the script type to OPEN if you intend to make it support multiplayer so it only gets played when the map gets loaded first time or reloaded rather than each time a player enters the game:

 

In your SNDINFO lump:

greets dsgreets

In your script file (whether the one in your map or library):

Script "GREETING" OPEN
{
 ActivatorSound("greets",127);
}

Make sure your sound file is placed under the main sounds/ folder in your .pk3 file

Edited by sluggard

Share this post


Link to post
  • 0

But how to make sure this only gets played in Map 02? I'd like to have a different sound for every map.

Share this post


Link to post
  • 0
25 minutes ago, sluggard said:

Open the script editor in your map editor (F10 in the case of UDB) and type it there, then compile it with the "compile script" button in the same script editor window, this way you can have per-map scripts.

 

Something isn't working.

 

My script compiles, I did it in GZDB, Map01, and it looks like this:

 

#Library "GREET"
#Include "ZCommon.ACS"

Script "GREET" OPEN
{
 ActivatorSound("greet",127);
}

 

The file is called GREET and I have greet greet in SNDINFO. I placed the file in pk3/sounds

 

I have GREET in LoadACS.

 

What am I missing?

 

 

Share this post


Link to post
  • 0

Are you sure your sound file is in one of the supported sound formats? named correctly? not followed by .mp3 or .wav or something like that?

Share this post


Link to post
  • 0

I redid it, exactly the same as before, and now it works. Don't know why. Thank you for your help!

Share this post


Link to post
  • 0
1 hour ago, sluggard said:

You're welcome!

 

One more question, because even though I did compile it in Map01, the script launches at the start of any map. May I ask what specific thing I should do to tie it to one map only?

Share this post


Link to post
  • 0

Did you also write it in your Library? If so remove the one in your library and it should only play in the map where you have the script.

Share this post


Link to post
  • 0

This is so strange, It should be tied to the map where you compile it, I'm out of ideas lol, I was going to suggest you recompile your library without that script but keep it if you want to have other kinds of scripts that happen on all maps.

Share this post


Link to post
  • 0

I think I'll just find a workaround - write greetings so they fit any map and make them randomly chosen at the beginning.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×