BanNsS1 Posted August 14, 2012 Share Posted August 14, 2012 I've created a event to reproduce a sound when the player press a key staying in a vehicle. It works but... If the car is stopped (0km/h) the sound volume is so low. If the car velocity is 120km/h the sound is reproduced with the desired volume. This is my code: local soundlockint = false function sonidoBloqueoVehiculoInterior( vehicle ) local x, y, z = getElementPosition(vehicle) local int = getElementInterior(vehicle) local dim = getElementDimension(vehicle) local px, py, pz = getElementPosition(getLocalPlayer()) if (getDistanceBetweenPoints3D(x, y, z, px, py, pz)<35) then local soundlockint = playSound3D("sounds/puertas_vehiculo_interior.mp3", x, y, z, false) setSoundMaxDistance(soundlockint, 10) setElementDimension(soundlockint, dim) setElementInterior(soundlockint, int) setSoundVolume(soundlockint, 0.5) end if (isPedInVehicle(getLocalPlayer())) then setSoundVolume(sound, 0.5) end end addEvent("PlayLockOrUnlockInteriorSound", true) addEventHandler("PlayLockOrUnlockInteriorSound", getResourceRootElement(), sonidoBloqueoVehiculoInterior) ¿Volume depending on the vehicle speed? ¿How to fix? Link to comment
Buffalo Posted August 14, 2012 Share Posted August 14, 2012 Well why are you using playSound3D? If you are playing this sound only for local player, use playSound instead. If not, try attaching sound element to vehicle. Link to comment
BanNsS1 Posted August 14, 2012 Author Share Posted August 14, 2012 No, the script plays the sound for all players arround the vehicle (max distance 10) setSoundMaxDistance(soundlockint, 10) Link to comment
BanNsS1 Posted August 14, 2012 Author Share Posted August 14, 2012 Really i dont know why the volume changes according the vehicle speed. Link to comment
BanNsS1 Posted August 20, 2012 Author Share Posted August 20, 2012 I realised the reason. When the car is stopped, the sound of the engine is so low. When a new sound is played for the element vehicle it gets first the vehicle volume and then the playSound volume. 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