Jump to content

3D sound is not stopping?


Recommended Posts

Server triggers clientside, but it is not working... (server trigger: triggerEvent ("stopDrillSound", getRootElement()))

drillSound = {}
drillSound["path"] = "files/sounds/drill/drill.mp3"
drillSound["looped"] = true
drillSound["radius"] = 25
drillSound["volume"] = 10

function playDrillSound(soundX, soundY, soundZ)
	drillSoundEffect = playSound3D (drillSound["path"], soundX, soundY, soundZ, drillSound["looped"])
end
addEvent ("drillSound", true)
addEventHandler ("drillSound", getRootElement(), playDrillSound)

function stopDrillSound()
	if drillSoundEffect then destroyElement (drillSoundEffect) end
end
addEvent ("stopDrillSound", true)
addEventHandler ("stopDrillSound", getRootElement(), stopDrillSound)

The sound gets played, but it won't stop, i tried stopSound as well but it was not successful. 

Link to comment
4 minutes ago, NOONE said:

to stop the sound 

it is better then the EventHandler

there must be a more simple way...

 

6 minutes ago, pa3ck said:

outputChatBox(tostring(drillSoundEffect)) -- try this and see what it returns @stopDrillSound


onClientRender:IHIJ4X9.png

addEventHandler ("onClientRender", getRootElement(), function()
    outputChatBox(tostring(drillSoundEffect))
end)

 

Edited by rusztamas
Link to comment

You'll need to debug this issue better. When you create the sound, do an outputChatBox(tostring(soundEffect)) to see the userdata value. When you want to remove it, do an outputChatBox again to compare the soundEffect userdata value and one after you do the stopSound(soundEffect). 

Btw, you are not using onClientRender to create sound right?

Link to comment
12 minutes ago, pa3ck said:

You'll need to debug this issue better. When you create the sound, do an outputChatBox(tostring(soundEffect)) to see the userdata value. When you want to remove it, do an outputChatBox again to compare the soundEffect userdata value and one after you do the stopSound(soundEffect). 

Btw, you are not using onClientRender to create sound right?

Client:
on the start of the sound there should be a blue text displayed in the chatbox, it is getting displayed. when it should end, (10s later) there should be a red text displayed, but the red text is not even getting displayed, however the serverside triggers the right event, and other stuff within that function everything works correct.
 

drillSound = {}
drillSound["path"] = "files/sounds/drill/drill.mp3"
drillSound["looped"] = true
drillSound["radius"] = 25
drillSound["volume"] = 10

function playDrillSound(soundX, soundY, soundZ)
	drillSoundEffect = playSound3D (drillSound["path"], soundX, soundY, soundZ, drillSound["looped"])
	outputChatBox("#0000FF"..tostring(drillSoundEffect).."", 255, 255, 255, true)
end
addEvent ("drillSound", true)
addEventHandler ("drillSound", getRootElement(), playDrillSound)

function stopDrillSound()
	if drillSoundEffect then destroyElement (drillSoundEffect) end
	outputChatBox("#FF0000"..tostring(drillSoundEffect).."", 255, 255, 255, true)
end
addEvent ("stopDrillSound", true)
addEventHandler ("stopDrillSound", getRootElement(), stopDrillSound)

Server:
 

function openSafeWithDrill()
	drillTimer = setTimer ( function()
		moveObject (safeDoor, timers["safeMovementTime"], positions["safeDoorOpenPositionX"], positions["safeDoorOpenPositionY"], positions["safeDoorOpenPositionZ"])
		triggerEvent ("closeSafeDoor", getRootElement())
		triggerEvent ("createLoots", getRootElement())
		if isElement (saw) then destroyElement (saw) end
		triggerEvent ("stopDrillSound", getRootElement())
	end, 10000, 1)
end
addEvent ("openSafeWithDrill", false)
addEventHandler ("openSafeWithDrill", getRootElement(), openSafeWithDrill)

http://i.imgur.com/6x7RkKH.png
What is wrong? :(

Edited by rusztamas
Link to comment

triggerEvent =/= triggerClientEvent

To trigger from Client -> Server: triggerServerEvent

To trigger from Server -> Client: triggerClientEvent

To trigger from Client -> Client: triggerEvent

To trigger from Server -> Server: triggerEvent

Edited by pa3ck
  • Like 2
Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...