QoRaY Posted December 23, 2012 Share Posted December 23, 2012 I want to change the horn sound. How can I do this? Link to comment
QoRaY Posted December 23, 2012 Author Share 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. Link to comment
Baseplate Posted December 23, 2012 Share 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 Link to comment
QoRaY Posted December 23, 2012 Author Share Posted December 23, 2012 Thank you, but I can not run? Link to comment
Baseplate Posted December 23, 2012 Share Posted December 23, 2012 (edited) Added the meta? Edited December 23, 2012 by Guest Link to comment
abu5lf Posted December 23, 2012 Share 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! Link to comment
manve1 Posted December 23, 2012 Share 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' )) Link to comment
QoRaY Posted December 23, 2012 Author Share Posted December 23, 2012 (edited) Does not work. Is there another code? Edited December 23, 2012 by Guest Link to comment
abu5lf Posted December 23, 2012 Share 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 ) Link to comment
QoRaY Posted December 23, 2012 Author Share Posted December 23, 2012 THANK YOU VERY MUCH !!!!!!!!!!!!! Link to comment
QoRaY Posted December 23, 2012 Author Share Posted December 23, 2012 Is going to be one more question. Other people cannot hear. How can I fix? Link to comment
manve1 Posted December 23, 2012 Share Posted December 23, 2012 trigger it to server side and back Link to comment
DeletedAccount1111 Posted December 23, 2012 Share Posted December 23, 2012 trigger it to server side and back Just in case, i think he means this Link to comment
manve1 Posted December 23, 2012 Share 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 Link to comment
Ab-47 Posted December 24, 2012 Share 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? Link to comment
Anderl Posted December 24, 2012 Share 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. Link to comment
QoRaY Posted January 29, 2013 Author Share Posted January 29, 2013 Can not hear other players and at the sound is coming... Help? Link to comment
mateplays Posted August 31, 2016 Share 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. 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