Jump to content

Final Adjustments Sound system in vehicles


Ryosuke

Recommended Posts

I finished some adjustments, but to be perfect I need to create some kind of delay in the gearshift so it would be more realistic. some help ?

local sound = {}

function updateEngineSound() 
    local allVehicles = getElementsByType("vehicle") 
    for index, veh in ipairs (allVehicles) do 
        local model = getElementModel(veh) 
        if model == 411 then 
            if getVehicleEngineState(veh) then 
                if isElement(sound[veh]) then 
                    local gear = getVehicleCurrentGear ( veh ) or 1
                    local velocityX, velocityY, velocityZ = getElementVelocity(veh) 
                    --local actualspeed = ((velocityX^2 + velocityY^2 + velocityZ^2)^(0.5)) * ((11 - gear) /10)
                    local rpm =((velocityX^2 + velocityY^2 + velocityZ^2)^(0.5)) * 161
                    local mph = rpm * 80 * 111.847 / gear
                    local minSoundSpeed = 0.15
                    local soundSpeed 
                    if (gear == 0) then
                        mph = rpm * 50 * 111.840
                    end
                   --soundSpeed = mph/(2000+2000/minSoundSpeed) + 0.20 
                    soundSpeed = mph/(100000/minSoundSpeed) + minSoundSpeed
                    setSoundSpeed (sound[veh], soundSpeed) 
                    outputChatBox(gear)
                else
                    local x, y, z = getElementPosition(veh)
                    sound[veh] = playSound3D("sounds/engine.wav", x, y, z, true)
                    attachElements(sound[veh], veh)
                end 
      else
                if isElement(sound[veh]) then
                    destroyElement(sound[veh])
                end
            end
        end 
    end 
end 
addEventHandler("onClientPreRender", root, updateEngineSound) 

Link to comment
1 hour ago, Kutlu35 said:

im not good on scripting but i thing this is usefully for your script.

https://www.mta-sa.org/thread/14444-release-custom-engine-sound/

 

Direct Download(Car-Sound-Scriptfor-infernus):

https://www.mta-sa.org/attachment/773-custom-infernus-sound-zip/

I just created this script for a reason! Improve the sound quality and create a more realistic system!, What I mean is to adjust the gearshift without the use of handling, but in the last case I can use it, since this resouce that you passed me is much worse than the my

 

Link to comment

Can't you just use a simple bool? For example isShiftingUp.

If it's true, start reducing soundSpeed to simulate the RPM dropping. If applicable you can also play some gear shifting sound here.

Then once the shifting is done, set the bool back to false to resume the sound simulation?

Link to comment
On 22.01.2017 at 03:53, Elvis Willian said:

I just created this script for a reason! Improve the sound quality and create a more realistic system!, What I mean is to adjust the gearshift without the use of handling, but in the last case I can use it, since this resouce that you passed me is much worse than the my

 

i send you link cuz this have gearshift system. You can read the lua file and see gear(rpm) system how does work. Good luck

Edited by Kutlu35
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...