Jump to content

Ryosuke

Members
  • Posts

    38
  • Joined

  • Last visited

Everything posted by Ryosuke

  1. 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
  2. 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)
  3. Hi, I really need some help! To adjust the speed of sound with the RPM of the vehicle, can anyone help me? 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 mph = actualspeed * 70 * 111.847 local minSoundSpeed = 0.15 local soundSpeed = mph/(1000+1000/minSoundSpeed) + minSoundSpeed setSoundSpeed (sound[veh], soundSpeed) 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)
  4. Really, that did not help much. The problem is the issue of changing the speed of sound when the gears pass :\
  5. Well the script is almost perfect! . Just missing the part of synchrony in the gearshift, someone to help me? 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 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 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)
  6. 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
  7. Thanks friend, I'll try to use this tip to work out the system
  8. 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)
  9. is just use Visible set Component to activate and deactivate parts of vehicles such as bumper and etc.
  10. Object 1831 is attached to the vehicle, how can I move it in sync with a sound even when it is stuck? function Turbo2(player) if getPedOccupiedVehicle(player) then local car = getPedOccupiedVehicle(player) local carID = getElementModel(car) if carID == 560 then PosX = 0 PosZ = 1.4 PosY = 0.4 elseif carID == 422 then PosX = 0 PosZ = -2.15 PosY = 0.2 else return end if carID == 560 then ConX = 0 ConZ = 1.4 ConY = 0.4 elseif carID == 422 then ConX = 0 ConZ = -2.23 ConY = 0.205 else return end x,y,z = getElementPosition(player) local turbo = createObject(1830, x, y, z+30) local turbo1 = createObject(1831, x, y, z+30) setObjectScale ( turbo, 1.5) setObjectScale ( turbo1, 1.5) attachElements(turbo, car,PosX,PosZ,PosY) attachElements(turbo1, car,ConX,ConZ,ConY) -- Modificação car:setData("obj_1831",turbo1) -- FIM addEventHandler ( "onVehicleExplode", root, Exploded ) addEventHandler ( "onPlayerQuit", root, Exploded ) end end addCommandHandler("com", Turbo2)
×
×
  • Create New...