Theres a noob that needs help

MrMessyHair

Noob in BLua
Hello, I want to know how to make a sound play only when something happens, and automatically stops when it's not ocurring. In this case, when the player gets invincibility.

Here is the code if somebody asks.

freeslot("sfx_inv")
sfxinfo[sfx_inv].caption = "Sparlkes"

addHook("PlayerThink", function(player)
if player.mo then
if (player.powers[pw_invulnerability])
if not S_SoundPlaying(player.mo, sfx_inv)
S_StartSound(player.mo, sfx_inv)
end
end
end
end)
 
Last edited:
Hello, I want to know how to make a sound play only when something happens, and automatically stops when it's not ocurring. In this case, when the player gets invincibility.

Here is the code if somebody asks.

freeslot("sfx_inv")
sfxinfo[sfx_inv].caption = "Sparlkes"

addHook("PlayerThink", function(player)
if player.mo then
if (player.powers[pw_invulnerability])
if not S_SoundPlaying(player.mo, sfx_inv)
S_StartSound(player.mo, sfx_inv)
end
end
end
end)
"sparlkes" thats probably why
 
now talking seriously. how i do to make the sound stop playing when invulnerability ends?
i think S_StopSound works
Post automatically merged:

addHook("PlayerThink", function(player)
if player.mo then
if (player.powers[pw_invulnerability]) = 0*TICRATE then
S_StopSound(player.mo, sfx_inv)
end
end
end)
 
Last edited:
there should be an extra equal sign as this is an if statement
oh right,thank you!
Post automatically merged:

Does'nt work
Post automatically merged:


It says: lua:6: unexpected symbol near "="
addHook("PlayerThink", function(player)
if player.mo then
if (player.powers[pw_invulnerability]) == 0*TICRATE then
S_StopSound(player.mo, sfx_inv)
end
end
end)

correct code now i think
 
Thanks bro, you helped me a lot.
Sorry for not reading it, I was in another place and don't take the computer there.
 
no, just play the sound when the player gets invulnerability. like if the invulnerability stars are doing the sound. but for some reason when i don't get invulnerability all game sounds stops
 

Who is viewing this thread (Total: 0, Members: 0, Guests: 0)

Back
Top