rusztamas Posted June 30, 2017 Share Posted June 30, 2017 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
rusztamas Posted June 30, 2017 Author Share Posted June 30, 2017 why do i need a timer? Link to comment
pa3ck Posted June 30, 2017 Share Posted June 30, 2017 (edited) outputChatBox(tostring(drillSoundEffect)) -- try this and see what it returns @stopDrillSound Edited June 30, 2017 by pa3ck Link to comment
Amine#TN Posted June 30, 2017 Share Posted June 30, 2017 to stop the sound it is better then the EventHandler Link to comment
rusztamas Posted June 30, 2017 Author Share Posted June 30, 2017 (edited) 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: addEventHandler ("onClientRender", getRootElement(), function() outputChatBox(tostring(drillSoundEffect)) end) Edited June 30, 2017 by rusztamas Link to comment
pa3ck Posted June 30, 2017 Share Posted June 30, 2017 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
rusztamas Posted June 30, 2017 Author Share Posted June 30, 2017 (edited) 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 June 30, 2017 by rusztamas Link to comment
pa3ck Posted June 30, 2017 Share Posted June 30, 2017 (edited) 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 June 30, 2017 by pa3ck 2 Link to comment
rusztamas Posted June 30, 2017 Author Share Posted June 30, 2017 thank you! i just copy pasted the line agains and i was not paying enough attention. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now