Hello everyone, so the idea is to play a sound in the start or middle of the black screen (just when it begins to fade) What i tried is this script below, but it doesn't work for some reason. And I don't have line under function main() Need help !
function on_player_spawned() { level.playSoundLocation PlaySound("welcoming_sound"); }
You'll need to either sort through zm_utility to find a play sound function or work with the one I gave you or search through the API for a play sound function that does what you want it to do. What I wrote before was pseudo code. It's up to you to make it work. I copy'd some code from my own code. So what I put in this reply is compilable.
Hahah guys, all i wanted is to get a simple line of code, which i don't know how to correctly apply. I don't really have any time to learn all these c an js laungages just to get sound working, but thanks for tips anyway.
Hahah guys, all i wanted is to get a simple line of code
I have never used this method: level.playSoundLocation PlaySound("welcoming_sound"); I posted a way that I have used before and I know works.
Did you put "on_player_spawned();" under the main function? If you didn't do that than the function "on_player_spawned()" will not run. Functions only run when they are called. to call a function you simply take their name ex. "fname" and put "fname();" Do not call your function within itself, or call the function from somewhere where that line of code won't be run. So the best place to call a function is from the main class, or another function that perhaps does other stuff before calling your function.
Also "level.playSoundLocation" is nil unless the game knows what "playSoundLocation" is. You should have: Also if that works, it's over complicated you can simply do this: You don't even have to bother putting that code in a function. Just put it under the main class. If the code is running too early (sound plays too early). Or maybe it doesn't play at all, you may need to add "wait(time);" before the line with "GetEnt". Ex. wait(3); (Waits 3 seconds.) It's possible that if the code is run before the game starts it might not play the sound at all.
Another reason to do it my way: If all your players spawn in a circle in a vicinity of lets say 5 meters. You put the sound struct in the center. So the sound plays in some peoples left ear and some peoples right ear. Depending where you put the struct some players may hear it loud and other may hear it quiet. With my function it plays the sound on every player. Although I've realized because my way is global. If you have 4 players, it's gonna play the sound 4 times for every single player instead of just once for every player. This could be solved by using a different playsound function. That runs locally. a variety of other solutions exist as well
Last Edit: April 02, 2017, 11:24:37 pm by MegaMech43
By putting "on_player_spawned(); " under main function, you mean putting it under function main() ? I tried doing this, i got insta-killed by nothing.
Placing asound lines under function main() or on_player_spawned() causes this error - Compiler Internal Error : Uninitialized local variable 'asound'
But the most funny thing is that my code used to work on my old computer, just after the spawn, the sound played correctly. And i have to tell you that I copied the welcoming screen script from someone i don't remember. But a have concerns about this line Here is the .gsc file fragment if it interests you
Thanks for the help and diamond text script, i really liked it. By the way your minecraft castle map was really impressive, hopefully you will create something minecraft themed once more