wesleywillems17 Posted May 10, 2016 Posted May 10, 2016 Hello, I have made a little script but i can't stop the playSound3D It starts when you use the command start and it needs to stop when you use the command stop. But i get a error in debug Client: function startSiren() local sirenSound = playSound3D( 'siren.mp3', 2097.00, -1629.59, 18.79, true ) setSoundVolume(sirenSound,100) end addCommandHandler ( "start", startSiren ) function stopSiren() stopSound(sirenSound) end addCommandHandler ( "stop", stopSiren ) meta.xml Debug: WARNING: (SARS)Siren/client:8 Bad argument @ 'stopSound' [expected sound at argument 1, got nill] What did i do wrong?
MACIEKW89 Posted May 10, 2016 Posted May 10, 2016 Hi, Try with that : local sirenSound function startSiren() sirenSound = playSound3D("siren.mp3", 2097.00, -1629.59, 18.79, true) setSoundVolume(sirenSound,100) end addCommandHandler("start", startSiren) function stopSiren() stopSound(sirenSound) end addCommandHandler("stop", stopSiren) Or try with that : addCommandHandler("start", function() local sirenSound = playSound3D("siren.mp3", 2097.00, -1629.59, 18.79, true) setSoundVolume(sirenSound,100) addCommandHandler("stop", function() stopSound(sirenSound) end) end)
Walid Posted May 11, 2016 Posted May 11, 2016 Sorry i'm using the phone. function speaker(cmd) if cmd == "start" then sirenSound = playSound3D( 'siren.mp3', 2097.00, -1629.59, 18.79, true ) setSoundVolume(sirenSound,100) elseif cmd == "stop" then if isElement(sirenSound) then stopSound(sirenSound) end end addCommandHandler ( "start", speaker ) addCommandHandler ( "stop", speaker ) Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
Abdul KariM Posted May 11, 2016 Posted May 11, 2016 Sorry i'm using the phone. function speaker(cmd) if cmd == "start" then sirenSound = playSound3D( 'siren.mp3', 2097.00, -1629.59, 18.79, true ) setSoundVolume(sirenSound,100) elseif cmd == "stop" then if isElement(sirenSound) then stopSound(sirenSound) end end addCommandHandler ( "start", speaker ) addCommandHandler ( "stop", speaker ) if wrote " start " and sound is started ?, will be sound repeated And minus " end " use : function speaker( cmd ) if cmd == "start" then if isElement ( sirenSound ) then destroyElement ( sirenSound ) end sirenSound = playSound3D( 'siren.mp3', 2097.00, -1629.59, 18.79, true ) setSoundVolume(sirenSound,100) elseif cmd == "stop" then if isElement( sirenSound ) then destroyElement ( sirenSound ) end end end addCommandHandler ( "start", speaker ) addCommandHandler ( "stop", speaker ) or : function speaker( cmd ) if cmd == "start" then if isElement ( sirenSound ) then return end sirenSound = playSound3D( 'siren.mp3', 2097.00, -1629.59, 18.79, true ) setSoundVolume(sirenSound,100) elseif cmd == "stop" then if isElement( sirenSound ) then destroyElement ( sirenSound ) end end end addCommandHandler ( "start", speaker ) addCommandHandler ( "stop", speaker ) Good luck [ Skype : kreee89 - Discord : Abdul_KariM#1326 / طلبات البرمجة ] https://www.paypal.me/AbdulKariMx / اذا حاب تدعمني
wesleywillems17 Posted May 11, 2016 Author Posted May 11, 2016 Thx for the help! This code works: addCommandHandler("start", function() local sirenSound = playSound3D("siren.mp3", 2097.00, -1629.59, 18.79, true) setSoundVolume(sirenSound,100) addCommandHandler("stop", function() stopSound(sirenSound) end) end)
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