Fabio(GNR) Posted September 24, 2010 Share Posted September 24, 2010 I want to create a script that plays sound when enters marker and stops when enters another marker, i finished the start script, but idk whats wrong? when i enter the marker nothing happens, no errors on debugscript, en btw when i accidentally used script as server it said nil value cause it was server but it does detect the marker, but doesnt play the sound, btw the sound is pretty big, a bit less then 10 mb code: function soundclub(hitElement, matchingDimension) local sound = playSound("club.mp3") setSoundVolume(sound, 0.6) end local myMarker2 = createMarker ( 48.590377807617,2252.8537597656,270.80096948242, "arrow", 1.0, 120, 255, 0, 170 ) addEventHandler("onMarkerHit", myMarker2, soundclub) Meta: <meta> <info author="aa" version="1.0" type="misc" name="sound" description="Play's sound" /> <script src="Untitled 1.lua" type="client" /> <file src="club.mp3" /> </meta> Link to comment
12p Posted September 24, 2010 Share Posted September 24, 2010 Are you sure the sound path is OK? And do you see the marker above the ground, right? Link to comment
dzek (varez) Posted September 24, 2010 Share Posted September 24, 2010 onMarkerHit is server side event.. Use onClientMarkerHit instead.. I hope you know the difference between server and client side.. because In that the sound won't be synchronised Link to comment
Fabio(GNR) Posted September 24, 2010 Author Share Posted September 24, 2010 Are you sure the sound path is OK? And do you see the marker above the ground, right? Yes, i put the sound file in the resource root folder, so example: sound.mp3 (if it was a mp3) but it doesn't play, yes. cause it detects marker too. Thanks for responding EDIT: onMarkerHit is server side event..Use onClientMarkerHit instead.. I hope you know the difference between server and client side.. because In that the sound won't be synchronised Srry didn't see your post, ill try that it will work i think EDIT2: Thanks it worked, varez thi is like the tenth time you helped me out Thanks alot!! EDIT3: 1 more thing now when i walk trough the marker the sound get played over the other, is there any way to let it know its still playing? And making it available when its done? Link to comment
50p Posted September 25, 2010 Share Posted September 25, 2010 There is no way to check if sound is already playing. If MTA Devs accepted my patch, you'd be able to detect when the sound has stopped or started playing. Currently, there is no way to check if sound is being played. Link to comment
CowTurbo Posted September 25, 2010 Share Posted September 25, 2010 enyway use stopSound function , when marker hits, and then start it again. so it wont be over played, but will be started again Link to comment
dzek (varez) Posted September 25, 2010 Share Posted September 25, 2010 you can set global value determinig if sound is played, on start set to true, and set it back to false with setTimer Link to comment
Fabio(GNR) Posted September 25, 2010 Author Share Posted September 25, 2010 you can set global value determinig if sound is played, on start set to true,and set it back to false with setTimer Sorry, i don't really get it, does it mean that if the marker is walked trough, that it will start disable it for that player and enable it again when the timer is done?? Link to comment
Fabio(GNR) Posted September 25, 2010 Author Share Posted September 25, 2010 yup And, how to do that Could you explain some more? Thanks!! Link to comment
dzek (varez) Posted September 25, 2010 Share Posted September 25, 2010 isPlaying = false function soundclub(hitElement, matchingDimension) if not isPlaying then isPlaying=true stopSound(sound) local sound = playSound("club.mp3") setSoundVolume(sound, 0.6) setTimer(function() isPlaying=false end, 32500, 1) end end like that Link to comment
Fabio(GNR) Posted September 25, 2010 Author Share Posted September 25, 2010 (edited) There is no way to check if sound is already playing. If MTA Devs accepted my patch, you'd be able to detect when the sound has stopped or started playing. Currently, there is no way to check if sound is being played. your patch?? isPlaying = false function soundclub(hitElement, matchingDimension) if not isPlaying then isPlaying=true stopSound(sound) local sound = playSound("club.mp3") setSoundVolume(sound, 0.6) setTimer(function() isPlaying=false end, 32500, 1) end end like that Thanks i'll try btw does the /lua code thing still works??? Thanks EDIT: it didn't work ill try debugscript now.... Edited September 25, 2010 by Guest Link to comment
dzek (varez) Posted September 25, 2010 Share Posted September 25, 2010 you mean [lua] [/lua] tags? yup, its working Link to comment
Fabio(GNR) Posted September 25, 2010 Author Share Posted September 25, 2010 (edited) you mean tags? yup, its working Ok.... But it didnt give me any errors with debugscript... but it did play it over the other.... EDIT: Page 2 ------>> Edited September 25, 2010 by Guest Link to comment
Fabio(GNR) Posted September 25, 2010 Author Share Posted September 25, 2010 what?? Thanks i'll try btw does the /lua code thing still works??? Thanks EDIT: it didn't work ill try debugscript now.... the sound, when i walk trough the second time it starts a new one but doesn't stop the old one so two are playing at the same time....can't we try this with a command instead of marker and then make the command avaible after the lenght? Link to comment
dzek (varez) Posted September 25, 2010 Share Posted September 25, 2010 And My solution is not working? Link to comment
Fabio(GNR) Posted September 25, 2010 Author Share Posted September 25, 2010 And My solution is not working? No, well maybe its me but i tested it first with marker now i changed to command, maybe i broke something: function soundclub (playerSource) local sound = playSound("club.mp3",true) setSoundVolume(sound, 0.7) end addCommandHandler ( "clubstart", soundclub ) isPlaying = false function soundclub(playerSource) if not isPlaying then isPlaying=true stopSound (sound) local sound = playSound("club.mp3") setSoundVolume(sound, 0.7) setTimer(function() isPlaying=false end, 600000, 1) end end Link to comment
dzek (varez) Posted September 25, 2010 Share Posted September 25, 2010 You have two functions with same name.one is overwriting older function. You can remove first one Link to comment
CowTurbo Posted September 25, 2010 Share Posted September 25, 2010 hmm there isnt needed for command.. just, make it like varez sayd local isPlaying = false -- hmm, dont know is local needed, but i think it is? local myMarker2 = createMarker ( 48.590377807617,2252.8537597656,270.80096948242, "arrow", 1.0, 120, 255, 0, 170 ) function soundclub(hitElement, matchingDimension) if not isPlaying then isPlaying=true stopSound(sound) local sound = playSound("club.mp3") setSoundVolume(sound, 0.6) setTimer(function() isPlaying=false end, 32500, 1) end end addEventHandler("onMarkerHit", myMarker2, soundclub) Link to comment
Fabio(GNR) Posted September 25, 2010 Author Share Posted September 25, 2010 thanks varez, and CowTurbo will try now EDIT: it worked Great!! But can i ask one more question how to make a command to make it stop? The one on the wiki doesn't work/explain Thanks really thanks!! btw: stop what i have so far: function stopclub (playerSource) stopSound("club.mp3") end addCommandHandler ( "clubstop", stopclub ) Link to comment
Castillo Posted September 25, 2010 Share Posted September 25, 2010 thanks varez, and CowTurbo will try now EDIT: it worked Great!! But can i ask one more question how to make a command to make it stop? The one on the wiki doesn't work/explain Thanks really thanks!! btw: stop what i have so far: function stopclub (playerSource) stopSound("club.mp3") end addCommandHandler ( "clubstop", stopclub ) try, function stopclub () stopSound(sound) end addCommandHandler ( "clubstop", stopclub ) Link to comment
dzek (varez) Posted September 25, 2010 Share Posted September 25, 2010 Also Remove "local" from line 10 of cowturbo snippet Link to comment
Fabio(GNR) Posted September 25, 2010 Author Share Posted September 25, 2010 thanks varez, and CowTurbo will try now EDIT: it worked Great!! But can i ask one more question how to make a command to make it stop? The one on the wiki doesn't work/explain Thanks really thanks!! btw: stop what i have so far: function stopclub (playerSource) stopSound("club.mp3") end addCommandHandler ( "clubstop", stopclub ) try, function stopclub () stopSound(sound) end addCommandHandler ( "clubstop", stopclub ) ok ill try EDIT: Also Remove "local" from line 10 of cowturbo snippet No i used the command, thing not his varez, thanks again it worked by deleting local :P:P:P You are really helpful Link to comment
Fabio(GNR) Posted September 26, 2010 Author Share Posted September 26, 2010 Only 1 bug, when you started it, and then you stop it, start won't work anymore, how to fix?? :D EDIT: Never mind, i setted the timer to 10 min or so never waited so long, changed to 1000 and its fixed 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