AlphaMark Posted September 15, 2013 Share Posted September 15, 2013 Hello i have an question. How do i make sounds local? i want to make this local: function playTheSound() local sound = playSound("Jihad.mp3", false) setSoundVolume(sound, 1) end addEvent("playTheSound", true) addEventHandler("playTheSound", getRootElement(), playTheSound) Link to comment
Baseplate Posted September 15, 2013 Share Posted September 15, 2013 Like playing it for a single person? try triggering it serversided. triggerClientEvent(element, "playTheSound", element) Link to comment
AlphaMark Posted September 15, 2013 Author Share Posted September 15, 2013 No, I want that only serveral people can hear it if they ar close to the player that plays the sound Link to comment
bandi94 Posted September 15, 2013 Share Posted September 15, 2013 playSound3D attachElements Link to comment
AlphaMark Posted September 15, 2013 Author Share Posted September 15, 2013 Then it should look like this:? (Im just an beginner) function playTheSound() local x,y,z = getElementPosition(thePlayer) local uSound = playSound3D( 'Jihad.mp3', x, y, z, false) setSoundMaxDistance( uSound, 100 ) setSoundVolume(sound, 1) end addEvent("playTheSound", true) addEventHandler("playTheSound", getRootElement(), playTheSound) Link to comment
AlphaMark Posted September 15, 2013 Author Share Posted September 15, 2013 I cant figure out how i should make it. Link to comment
Castillo Posted September 15, 2013 Share Posted September 15, 2013 'thePlayer' is not defined there, also, how are you triggering "playTheSound"? Link to comment
AlphaMark Posted September 15, 2013 Author Share Posted September 15, 2013 It gets triggered by this script: function createExplosionForPlayer(thePlayer,command) timer = setTimer (createJihadForPlayer, 2500, 1, thePlayer, x, y, z) triggerClientEvent("playTheSound", getRootElement()) end addCommandHandler("Jihad", createExplosionForPlayer) addCommandHandler("jihad", createExplosionForPlayer) function createJihadForPlayer(thePlayer, x, y, z) local x,y,z = getElementPosition(thePlayer) local createdExplosion = createExplosion(x,y,z,2) local createdExplosion = createExplosion(x,y,z,9) local createdExplosion = createExplosion(x,y,z,10) if (createdExplosion == true) then outputChatBox(getPlayerName(thePlayer).." comitted a Jihad!") end end Link to comment
Castillo Posted September 15, 2013 Share Posted September 15, 2013 function createExplosionForPlayer ( thePlayer, command ) timer = setTimer ( createJihadForPlayer, 2500, 1, thePlayer, x, y, z ) triggerClientEvent ( "playTheSound", getRootElement(), thePlayer ) end addCommandHandler ( "Jihad", createExplosionForPlayer ) addCommandHandler ( "jihad", createExplosionForPlayer ) function createJihadForPlayer ( thePlayer, x, y, z ) local x, y, z = getElementPosition ( thePlayer ) local createdExplosion = createExplosion ( x, y, z, 2 ) local createdExplosion = createExplosion ( x, y, z, 9 ) local createdExplosion = createExplosion ( x, y, z, 10 ) if ( createdExplosion == true ) then outputChatBox ( getPlayerName ( thePlayer ) .." comitted a Jihad!" ) end end function playTheSound ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) local uSound = playSound3D ( 'Jihad.mp3', x, y, z, false ) setSoundMaxDistance ( uSound, 100 ) setSoundVolume ( uSound, 1 ) end addEvent ( "playTheSound", true ) addEventHandler ( "playTheSound", getRootElement(), playTheSound ) Link to comment
AlphaMark Posted September 15, 2013 Author Share Posted September 15, 2013 :lua:3: ')' expected near 'thePlayer' Link to comment
Castillo Posted September 15, 2013 Share Posted September 15, 2013 Copy the code again. Link to comment
AlphaMark Posted September 15, 2013 Author Share Posted September 15, 2013 Thanks! Its working now 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