Jump to content

Attaching Elements


DrifTech

Recommended Posts

Posted

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

Posted

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.

Posted
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.

Projects:

Slothbot | Maximap

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...