Jump to content

IDLE sound engine car


Ryosuke

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)

Link to comment

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. 

Link to comment
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
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...