QoRaY Posted December 23, 2012 Posted December 23, 2012 I want to change the horn sound. How can I do this?
QoRaY Posted December 23, 2012 Author Posted December 23, 2012 horn.wav "h" Can you do it? I do not understand. I know just a lua file to save. Lua Code Please.
Baseplate Posted December 23, 2012 Posted December 23, 2012 function playMySound() local x, y, z = getElementPosition(localPlayer) local sound = playSound3D ("horn.wav", x, y, z) end function stopMySound() local soundoff = stopSound(sound) end function bindTheKeys() unbindKey("h") bindKey("h", "down", playMySound) bindKey("h", "up", stopMySound) UNTESTED! And we don't do codes but we help only, I just did for you to learn
Baseplate Posted December 23, 2012 Posted December 23, 2012 (edited) Added the meta? Edited December 23, 2012 by Guest
abu5lf Posted December 23, 2012 Posted December 23, 2012 function playMySound() local x, y, z = getElementPosition(localPlayer) local sound = playSound3D ("horn.wav", x, y, z) end function stopMySound() local soundoff = stopSound(sound) end function bindTheKeys() unbindKey("h") bindKey("h", "down", playMySound) bindKey("h", "up", stopMySound) UNTESTED! And we don't do codes but we help only, I just did for you to learn Wrong!
manve1 Posted December 23, 2012 Posted December 23, 2012 function playMySound() local x, y, z = getElementPosition(localPlayer) local sound = playSound3D ("horn.wav", x, y, z) end function stopMySound() local soundoff = stopSound(sound) end function bindTheKeys() unbindKey("h") bindKey("h", "down", playMySound) bindKey("h", "up", stopMySound) end ((missed out 'end' ))
QoRaY Posted December 23, 2012 Author Posted December 23, 2012 (edited) Does not work. Is there another code? Edited December 23, 2012 by Guest
abu5lf Posted December 23, 2012 Posted December 23, 2012 function bindHoron( key, keyState ) if isPedInVehicle( localPlayer ) then if ( keyState == 'down' ) then sound = playSound3D( 'horn.wav', getElementPosition( localPlayer ) ) attachElements( sound, getPedOccupiedVehicle( localPlayer ) ) elseif ( keyState == 'up' ) then if isElement( sound ) then stopSound( sound ) end end end end bindKey( 'h', 'down', bindHoron ) bindKey( 'h', 'up', bindHoron ) And you need disabled the control horn: toggleControl( 'horn', false )
QoRaY Posted December 23, 2012 Author Posted December 23, 2012 Is going to be one more question. Other people cannot hear. How can I fix?
DeletedAccount1111 Posted December 23, 2012 Posted December 23, 2012 trigger it to server side and back Just in case, i think he means this
manve1 Posted December 23, 2012 Posted December 23, 2012 No, triggering isn't that .... And it wouldn't work if you done this. Read the tutorial i posted: viewtopic.php?f=148&t=51192
Ab-47 Posted December 24, 2012 Posted December 24, 2012 trigger it to server side and back Just in case, i think he means this How can there be a client script as type: server? I think he means: triggerServerEvent On the other hand, wouldn't binding a new sound collide with the existing GTA sounds?
Anderl Posted December 24, 2012 Posted December 24, 2012 trigger it to server side and back Just in case, i think he means this How can there be a client script as type: server? I think he means: triggerServerEvent On the other hand, wouldn't binding a new sound collide with the existing GTA sounds? He disabled horn control.
QoRaY Posted January 29, 2013 Author Posted January 29, 2013 Can not hear other players and at the sound is coming... Help?
mateplays Posted August 31, 2016 Posted August 31, 2016 There was no problems with this script... function playMySound() local x, y, z = getElementPosition(localPlayer) local sound = playSound3D ("horn.wav", x, y, z) end function stopMySound() local soundoff = stopSound(sound) end function bindTheKeys() unbindKey("h") bindKey("h", "down", playMySound) bindKey("h", "up", stopMySound) end addEventHandler("onClientResourceStart", resourceRoot, bindTheKeys) You just missed the EventHandler.
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