Jump to content

Help me out please


mint3d

Recommended Posts

Ok so I made a script it works but I need help adding some stuff like I need all players in vehicle to hear it and it only plays sound if you are the driver and you do /handbrake please help me out or tell me what events to use

Edited by Guest
Link to comment

I don't understand sorry playSound3D uses coordinates and also You how to make it so only the driver will do /handbrake and it plays sound

function handbrake (handbrake)  
    local x, y, z = getElementPosition ( handbrake ) 
    attachElements ( sound, handbrake, 0, 0, 5 ) 
    local sound = playSound3D("handbrake.mp3", 0, 0, 0, false)  
    setSoundVolume(sound, 1)  
  
end 
  
addCommandHandler ( "handbrake", handbrake ) 

Link to comment

try

function handbrake () 
    local x, y, z = getElementPosition ( localPlayer ) 
    attachElements ( sound, handbrake, 0, 0, 5 ) 
    local sound = playSound3D("handbrake.mp3", 0, 0, 0, false) 
    setSoundVolume(sound, 1) 
  
end 
  
addCommandHandler ( "handbrake", handbrake ) 

Link to comment
  
addCommandHandler("handbrake",function() 
    local x,y,z = getElementPosition(localPlayer) 
    local sound = playSound3D("handbrake.mp3",0,0,0,false) 
    setSoundMaxDistance(sound,50) 
    setSoundVolume(sound,1) 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    attachElements(sound,vehicle) 
end) 
  

Link to comment
addCommandHandler("handbrake",function() 
    local x,y,z = getElementPosition(localPlayer) 
    local sound = playSound3D("handbrake.mp3",0,0,0,false) 
    setSoundMaxDistance(sound,50) 
    setSoundVolume(sound,1) 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    attachElements(sound,vehicle) 
end) 
  

Ok this works but I can use /handbrake and the sound plays even if I am not the driver any help on that?

Link to comment
addCommandHandler("handbrake",function() 
    local x,y,z = getElementPosition(localPlayer) 
    local sound = playSound3D("handbrake.mp3",0,0,0,false) 
    setSoundMaxDistance(sound,50) 
    setSoundVolume(sound,1) 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    attachElements(sound,vehicle) 
end) 
  

Ok this works but I can use /handbrake and the sound plays even if I am not the driver any help on that?

getVehicleController 

Link to comment

sorry.

try this:

  
addCommandHandler("handbrake",function() 
if(isPedInVehicle(localPlayer)) then 
    local x,y,z = getElementPosition(localPlayer) 
    local sound = playSound3D("handbrake.mp3",x,y,z,false) 
    setSoundMaxDistance(sound,50) 
    setSoundVolume(sound,1) 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    attachElements(sound,vehicle,0,0,0) 
end 
end) 

Link to comment
addCommandHandler("handbrake",function() 
    local x,y,z = getElementPosition(localPlayer) 
    local sound = playSound3D("handbrake.mp3",0,0,0,false) 
    setSoundMaxDistance(sound,50) 
    setSoundVolume(sound,1) 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    attachElements(sound,vehicle) 
end) 
  

Only the driver can hear the sound... I want everyone in car to hear it

Link to comment

ok try

addCommandHandler("handbrake",function(p) 
if(isPedInVehicle(p)) then 
    local x,y,z = getElementPosition(p) 
triggerClientEvent("onHandbrakeStart",p,x,y,z)     
end 
end) 
  
addEvent("onHandbrakeStart",true) 
addEventHandler("onHandbrakeStart",root, 
function(x,y,z) 
local sound = playSound3D("handbrake.mp3",x,y,z,false) 
    setSoundMaxDistance(sound,50) 
    setSoundVolume(sound,1) 
    local vehicle = getPedOccupiedVehicle(source) 
    attachElements(sound,vehicle,0,0,0) 
end) 

Link to comment
addCommandHandler ( "handbrake", 
    function ( p ) 
        if ( isPedInVehicle ( p ) and getPedOccupiedVehicleSeat ( p ) == 0 ) then 
            local x, y, z = getElementPosition ( p ) 
            triggerClientEvent ( p, "onHandbrakeStart", p, x, y, z )     
        end 
    end 
) 

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