Jump to content

Train horn script dont work


Recommended Posts

Posted

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

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

Posted
I don't understand what you mean.

why you dont use the script? :o its a cool for rp :) its too nice

train coming,player on the rail :shock:

train driver horn with the train and the player on the rail hear that :D

  • 3 weeks later...
Posted
Please use private messages for such questions.

problem on the train horn script. No player hear the horn only the player who takes the horn :(

any ideas?

the horn must hear like a normal gta car horn in the multiplayer :)

Posted
The script I posted has to work.

Thanks it works :D but is it availible to make the sound like a audio player? i mean if the play press H then the sound comes in full of time. 1x press then play the sound complete :lol:

Posted
What do you mean?

just i mean when the player press H then the sound comes automaticly,no stoping when the player doesnt press H.Like a windows media player.You press play (H key) and the windows media player play the sound to the end.

sorry for my bad english :oops:

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