Jump to content

Train horn script dont work


Recommended Posts

-- server side:

addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            bindKey ( player, "H", "down", playHorn ) 
            bindKey ( player, "H", "up", playHorn ) 
        end 
    end 
) 
  
addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        bindKey ( source, "H", "down", playHorn ) 
        bindKey ( source, "H", "up", playHorn ) 
    end 
) 
  
function playHorn ( thePlayer, key, keyState ) 
    local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
    if ( not theVehicle ) then 
        return 
    end 
  
    if ( getElementModel ( theVehicle ) == 537 ) then 
        triggerClientEvent ( "vehicleHorn", root, ( keyState == "down" and true or false ), theVehicle ) 
    end 
end 

-- client side:

addEvent ( "vehicleHorn", true ) 
addEventHandler ( "vehicleHorn", root, 
    function ( state, theVehicle ) 
        if isElement ( desusound ) then 
            stopSound ( desusound ) 
        end 
        if ( state ) then 
            local x, y, z = getElementPosition ( theVehicle ) 
            desusound = playSound3D ( 'hupe/ZUGHUPE.mp3', x, y, z ) 
            setSoundVolume ( desusound, 5.0 ) 
            setSoundMaxDistance ( desusound, 190 ) 
            attachElements ( desusound, theVehicle ) 
        end 
    end 
) 

Link to comment
-- server side:
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            bindKey ( player, "H", "down", playHorn ) 
            bindKey ( player, "H", "up", playHorn ) 
        end 
    end 
) 
  
addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        bindKey ( source, "H", "down", playHorn ) 
        bindKey ( source, "H", "up", playHorn ) 
    end 
) 
  
function playHorn ( thePlayer, key, keyState ) 
    local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
    if ( not theVehicle ) then 
        return 
    end 
  
    if ( getElementModel ( theVehicle ) == 537 ) then 
        triggerClientEvent ( "vehicleHorn", root, ( keyState == "down" and true or false ), theVehicle ) 
    end 
end 

-- client side:

addEvent ( "vehicleHorn", true ) 
addEventHandler ( "vehicleHorn", root, 
    function ( state, theVehicle ) 
        if isElement ( desusound ) then 
            stopSound ( desusound ) 
        end 
        if ( state ) then 
            local x, y, z = getElementPosition ( theVehicle ) 
            desusound = playSound3D ( 'hupe/ZUGHUPE.mp3', x, y, z ) 
            setSoundVolume ( desusound, 5.0 ) 
            setSoundMaxDistance ( desusound, 190 ) 
            attachElements ( desusound, theVehicle ) 
        end 
    end 
) 

dont hear the horn with it :(

EDIT:i get it to work :D but i dont know it is really works :shock:

Meta:

:D

Link to comment
  • 3 weeks later...

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