Jump to content

[HELP] Change the horn sound


QoRaY

Recommended Posts

Posted
bindKey  
playSound3D 

╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗

║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║

║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║

║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║

╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝

«سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك»

M7mdAl7arthy : لتواصل سكايب

Posted
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

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

╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗

║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║

║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║

║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║

╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝

«سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك»

M7mdAl7arthy : لتواصل سكايب

Posted
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' ))

Looking for tutorials or information? check out: www.simpleask.co.uk

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

╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗

║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║

║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║

║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║

╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝

«سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك»

M7mdAl7arthy : لتواصل سكايب

Posted

You're welcome.

╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗

║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║

║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║

║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║

╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝

«سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك»

M7mdAl7arthy : لتواصل سكايب

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

And now Aurora is back again, pm for more info.

Ex. Lead dev & L6 Staff at AUR, NGC, MTA RP & SAA.

Ex. Developer at Community of Social Gamers - CSG

Ex Founder of International Gaming Community - IGC and Union of Individual Players- UIP

9o6E8.png Ab-47

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

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

  • 1 month later...
  • 3 years later...
Posted

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.

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