Jump to content

Problem with Audio


Dzsipszi

Recommended Posts

I wanna to play a sound when enter a vehicle. I write this script and it doesn't work..

function enterVehicle ( player, seat, jacked ) 
    local sound = playSound("sound/venter.mp3") 
    setSoundVolume(sound, 0.5) 
end 
  
addEventHandler("onVehicleStartEnter", getRootElement(), enterVehicle ) 

Link to comment
I wanna to play a sound when enter a vehicle. I write this script and it doesn't work..
function enterVehicle ( player, seat, jacked ) 
    local sound = playSound("sound/enter.mp3") 
    setSoundVolume(sound, 0.5) 
end 
  
addEventHandler("onVehicleStartEnter", getRootElement(), enterVehicle ) 

Try this.

Link to comment
    function enterVehicle ( player, seat, jacked ) 
        local sound = playSound("enter.mp3") 
        setSoundVolume(sound, 0.5) 
    end 
      
    addEventHandler("onVehicleStartEnter", getRootElement(), enterVehicle ) 

still nothing..

    
        "Dzsipszi" type="script" description="Car-Sounds"/> 
      
        

Try this.

Link to comment

Not Tested

Client:

function playTheSound( x, y, z, vehicle ) 
    local sound = playSound3D( "sound.mp3", x, y, z ) 
    if (isElement( vehicle )) then  
        attachElements( sound, vehicle )  
    end 
end 
addEvent( "playTheSound", true ) 
addEventHandler( "playTheSound", root, playTheSound ) 

Server:

function enterVehicle( thePlayer ) 
    local x, y, z = getElementPosition( thePlayer ) 
    if (isPedInVehicle( thePlayer )) then 
        local vehicle = getPedOccupiedVehicle( thePlayer ) 
        triggerClientEvent( root, "playTheSound", root, x, y, z, vehicle ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", root, enterVehicle ) 

Link to comment

Client-side code:

addEventHandler( "onClientVehicleStartEnter", root, 
    function( player ) 
        if ( player == localPlayer ) then 
            setSoundVolume( playSound( "sound/venter.mp3" ), 0.5 ); 
        end 
    end 
) 

meta.xml:

<meta> 
    <info author = "Dzsipszi" type = "script" description = "Car-Sounds"/> 
          
    <script src = "enter.lua" type = "client"/> 
    <file src = "enter.mp3"/> 
</meta> 

Link to comment

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