Ryosuke Posted June 6, 2018 Share Posted June 6, 2018 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
Gat Posted June 7, 2018 Share Posted June 7, 2018 Use onPlayerVehicleEnter instead... Will be more good Link to comment
Z4Zy Posted June 7, 2018 Share Posted June 7, 2018 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
DNL291 Posted June 7, 2018 Share Posted June 7, 2018 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. Link to comment
ShayF2 Posted June 7, 2018 Share Posted June 7, 2018 (edited) 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 June 7, 2018 by ShayF 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