[SOLVED][ZSCRIPT] Pause Every Sound In Game: HELP
Posted: Tue Jan 16, 2024 2:12 pm
I would like to make a monster that can deafen the player and knowing about S_PauseSound that's used in the TimeFreezer powerup, I decided to make a simple power that just pause all the sounds and music, although it seems that is not that immediate...
At first, I just thought that calling for S_PauseSound in InitEffect would have done the trick, but apparently I still have to give the player the timefreezer flag for the sound pausing function to work :/
Not only that, but if I don't have this bit
in my EndEffect, the game crashes whenever the powerup ends and this is making me even more confused...
What is going on here???
Noticing that when the player has this powerup active every sound is paused (good) except for when he picks up items (?), I started to think of a way to play a specific sound when the powerup activates (or even when it's active until it ends), but for now I got no luck.
Is there a way?
This is the code I'm using right now:
Any help in understanding what is going on and how to play a specific sound with this powerup is highly appreciated! thx
At first, I just thought that calling for S_PauseSound in InitEffect would have done the trick, but apparently I still have to give the player the timefreezer flag for the sound pausing function to work :/
Not only that, but if I don't have this bit
Code: Select all
for(int i = 0; i < MAXPLAYERS; ++i) {
if (playeringame[i] && players[i].timefreezer != 0) {
return;
}
}
What is going on here???
Noticing that when the player has this powerup active every sound is paused (good) except for when he picks up items (?), I started to think of a way to play a specific sound when the powerup activates (or even when it's active until it ends), but for now I got no luck.
Is there a way?
This is the code I'm using right now:
Code: Select all
Class Deafen : Powerup
{
Default
{
Powerup.Duration -3;
}
override void InitEffect() {
Super.InitEffect();
if (Owner == null || Owner.player == null) {
return;
}
S_PauseSound(false, false);
Owner.player.timefreezer = 1;
}
override void EndEffect() {
Super.EndEffect();
if (Owner != null && Owner.player != null) {
Owner.player.timefreezer = 0;
}
for(int i = 0; i < MAXPLAYERS; ++i) {
if (playeringame[i] && players[i].timefreezer != 0) {
return;
}
}
S_ResumeSound(false);
}
}