Jump to content

[REQ]Helicopter Sounds Replacement


Recommended Posts

  • 2 weeks later...
function updateEngineSound() 
    local allVehicles = getElementsByType("vehicle") 
    for index, veh in ipairs (allVehicles) do  
        local model = getElementModel(veh) 
        if model == 580 then 
            if getVehicleEngineState(veh) then 
                local x, y, z = getElementPosition(veh) 
  
                local sound = getElementData(veh, "engineSound") 
  
                    sound = playSound3D("sounds/song.mp3", x, y, z, true) 
                    setElementData(veh, "engineSound", sound) 
                end 
  
                if isSoundPaused(sound) then 
                    setSoundPaused(sound, false) 
                end 
  
                local velocityX, velocityY, velocityZ = getElementVelocity(veh) 
                local actualspeed = (velocityX^2 + velocityY^2 + velocityZ^2)^(0.5) 
                local mph = actualspeed * 50 * 111.847 
  
                 
                local minSoundSpeed = 0.25 
                local soundSpeed = mph/(80+80/minSoundSpeed) + minSoundSpeed 
              
                setSoundSpeed (sound, soundSpeed) 
  
   
                setElementPosition(sound, x, y, z) 
  
            else -- otherwise (so if the engine is off) 
  
                setSoundPaused(sound, true) 
            end  
        end  
    end  
end 
setTimer(updateEngineSound, 50, 0)  
  

Link to comment
function updateEngineSound() 
    local allVehicles = getElementsByType("vehicle") 
    for index, veh in ipairs (allVehicles) do  
        local model = getElementModel(veh) 
        if model == 580 then 
            if getVehicleEngineState(veh) then 
                local x, y, z = getElementPosition(veh) 
  
                local sound = getElementData(veh, "engineSound") 
  
                    sound = playSound3D("sounds/song.mp3", x, y, z, true) 
                    setElementData(veh, "engineSound", sound) 
                end 
  
                if isSoundPaused(sound) then 
                    setSoundPaused(sound, false) 
                end 
  
                local velocityX, velocityY, velocityZ = getElementVelocity(veh) 
                local actualspeed = (velocityX^2 + velocityY^2 + velocityZ^2)^(0.5) 
                local mph = actualspeed * 50 * 111.847 
  
                 
                local minSoundSpeed = 0.25 
                local soundSpeed = mph/(80+80/minSoundSpeed) + minSoundSpeed 
              
                setSoundSpeed (sound, soundSpeed) 
  
   
                setElementPosition(sound, x, y, z) 
  
            else -- otherwise (so if the engine is off) 
  
                setSoundPaused(sound, true) 
            end  
        end  
    end  
end 
setTimer(updateEngineSound, 50, 0)  
  

and

Thanks alot!

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...