Ryosuke

IDLE sound engine car

Recommended Posts

 

 

Hello, I need help to complete a slow idle script for the vehicle, but I just could not get a good result, if you can help me, thank you!

RX7_sound = {
    {"001.wav",494},
}

function replacesound(player)
  for i,OBJ in ipairs(RX7_sound) do 
   vehicle = getPedOccupiedVehicle (OBJ[2])
   if vehicle then
   sound = playSound (OBJ[1],looped = true)
   setSoundVolume(sound, 0.5)
   setSoundMaxDistance(sound,25)
  end
  end
  end
  addEventHandler("onClientResourceStart",root,replacesound)

Share this post


Link to post

Use onPlayerVehicleEnter instead... Will be more good

Share this post


Link to post

Your Code...,

RX7_sound = {
    {"001.wav",494},
}

function replacesound(player)
  for i,OBJ in ipairs(RX7_sound) do 
   vehicle = getPedOccupiedVehicle (OBJ[2])
   if vehicle then
   sound = playSound (OBJ[1],looped = true)
   setSoundVolume(sound, 0.5)
   setSoundMaxDistance(sound,25)
  end
  end
  end
  addEventHandler("onClientResourceStart",root,replacesound)

in line 8, playsound argument 2 is given as looped = true. Try to remove the word looped= and remain it as true only. 

Share this post


Link to post

What do you mean by 'slow idle'?

If you want this to work when the vehicle is braking or stopped, you'll need to find a way to detect these states, then use playSound.

Share this post


Link to post
RX7_sound = {
    {'001.wav',494},
}

function replacesound(vehicle)
	local veh = source or vehicle
	for i,OBJ inipairs(RX7_sound) do 
		if veh then
			if OBJ[2] == getElementModel(veh) then
				local x,y,z = getElementPosition(veh)
				sound = playSound3D(OBJ[1],x,y,z,true)
				attachElements(sound,veh)
				--sound = playSound(OBJ[1]) -- change to playSound3D()
				setSoundVolume(sound,0.5)
				setSoundMaxDistance(sound,25)
			end
		end
	end
end
addEventHandler('onVehicleEnter',resourceRoot,replacesound)

 

Edited by ShayF

Share this post


Link to post

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.