(03-16-2013, 12:31 AM)plutomaniac Wrote: 2) How do sounds work exactly? Sometimes, unless I put the sounds very apart the second one is not being played. For example if I write the below, the second one is not heard at all. Basically I want one sound to play after the other:
PlayGuiSound("sound1", 1);
PlayGuiSound("sound2", 1); //I also tried PlayMusic function, same result
3) Does PreloadSound help with something like performance etc...?
2) By writing
PlayGuiSound("sound1", 1);
PlayGuiSound("sound2", 1);
it will play the sounds at the same time. If you want the second sound to play after the first sound finishes, you can use a timer. Add a timer so that once it reaches 0, the second sound will play. For example if the first sound was 3 seconds long:
void OnStart()
{
PlayGuiSound("sound1.snt", 1); //Play first sound (remember to have extension, I think .ogg works too)
AddTimer("second_sound", 3.0f, "SecondSound"); //Will do SecondSound after 3 seconds
}
void SecondSound(string &in asTimer)
{
PlayGuiSound("sound2.snt", 1);
}
Don't forget that you can also use
PlaySoundAtEntity if you want to play the sound at a certain entity. Using
PlayGuiSound does not use 3D at all.
3) Preloading is basically to improve performance. It will load the sound/particle system before it is played so that you don't get a mini lag spike when its played/created. Here's a thread that was created not too long ago:
http://www.frictionalgames.com/forum/thread-20577.html
Edit: Robosprog's code is perfectly fine, but for this situation (something happens when item is picked up), it would probably be better to use
SetEntityPlayerInteractCallback. This is Robosrog's code modified:
void OnStart()
{
SetEntityPlayerInteractCallback("pickuptinder", "PickUpTinder, true);
}
void PickUpTinder(string &in asEntity)
{
SetMessage("Messages", "Dialogue", 3.50); // The category, then the text entry.
}