DrifTech Posted October 1, 2009 Share Posted October 1, 2009 I am developing a resource that will disable the horn and play a Server Defined sound (cooler horn) instead, i am able to play it but unable to get the sound to stay with the car. Help anyone? I know very little code Link to comment
Gamesnert Posted October 2, 2009 Share Posted October 2, 2009 MTA can't attach sounds and some other elements so far if I remember correctly. Though client-side you can use onClientRender or onClientPreRender to move the sound towards the car every frame. And, with that, hear it near the car. Might require some thinking, but shouldn't be too hard. Link to comment
DrifTech Posted October 2, 2009 Author Share Posted October 2, 2009 Thanks, ill try it out now... Link to comment
DrifTech Posted October 9, 2009 Author Share Posted October 9, 2009 I have absolutely no idea how to make this work... Can any of this forums scripter's give me a hand? My goal is to attach a play3dSound to a vehicle so when it plays, which is only when a press a key, it follows car. Link to comment
Gamesnert Posted October 9, 2009 Share Posted October 9, 2009 local attached = {} function attachSoundTo(sound,element) if isElement(sound) and isElement(element) then attached[sound]=element return true end return false end function moveAttachedSoundsToElements() for sound,element in pairs(attached) do if isElement(sound) and isElement(element) then setElementPosition(sound,getElementPosition(element)) else attached[sound]=nil end end end addEventHandler("onClientRender",getRootElement(),moveAttachedSoundsToElements) Just a quick script. Not sure if there are any errors in it or anything, probably isn't the best solution either, but it should give you an idea on how to do it. Just use function attachSoundTo on your sound + vehicle and done. 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