Ryosuke Posted January 16, 2017 Share Posted January 16, 2017 Help me. I got the snore script on the vehicles. But he has a continuous snoring. How can I synchronize with the gears? . Give me some examples please 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 local x, y, z = getElementPosition(veh) local sound = getElementData(veh, "engineSound") if not sound then sound = playSound3D("sounds/engine.wav", x, y, z, true) setElementData(veh, "engineSound", sound,false) end if isSoundPaused(veh) then setSoundPaused(sound, false) end local velocityX, velocityY, velocityZ = getElementVelocity(veh) local actualspeed = (velocityX^2 + velocityY^2 + velocityZ^2)^(0.5) local mph = actualspeed * 70 * 111.847 local minSoundSpeed = 0.15 local soundSpeed = mph/(1000+1000/minSoundSpeed) + minSoundSpeed setSoundSpeed (sound, soundSpeed) setElementPosition(sound, x, y, z) else setSoundPaused(sound, true) end end end end addEventHandler ("onClientPreRender", root, updateEngineSound) Link to comment
Moderators IIYAMA Posted January 16, 2017 Moderators Share Posted January 16, 2017 (edited) getVehicleCurrentGear local gear = getVehicleCurrentGear ( veh ) or 1 local actualspeed = ((velocityX^2 + velocityY^2 + velocityZ^2)^(0.5)) * ((11 - gear) /10) You could try something like this. Although I have no idea how to do it perfectly. Another solution would be playing another sound. Also I added the gear data to the actually speed. Which isn't really semantic solution. But you will figure it out! Edited January 16, 2017 by IIYAMA Link to comment
Ryosuke Posted January 16, 2017 Author Share Posted January 16, 2017 Thanks friend, I'll try to use this tip to work out the system Link to comment
Moderators IIYAMA Posted January 16, 2017 Moderators Share Posted January 16, 2017 Also here you can get the max amount of gears: (which seem to be 5, not sure if you can set more) https://wiki.multitheftauto.com/wiki/GetVehicleHandling 1 Link to comment
Ryosuke Posted January 16, 2017 Author Share Posted January 16, 2017 In fact, you do not have to use the gears specifically. But rather with each speed obtaining a different speed in the sound. Like that, every km / h it changes the local SoundSpeed kmh = actualspeed * 180 SoundSpeed = 0.15 .I tried to write a code for this but gave some errors 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