mint3d Posted April 4, 2014 Share Posted April 4, 2014 (edited) 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 September 20, 2014 by Guest Link to comment
cheez3d Posted April 4, 2014 Share Posted April 4, 2014 playSound3D() attachElements() Link to comment
mint3d Posted April 4, 2014 Author Share Posted April 4, 2014 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
manawydan Posted April 4, 2014 Share Posted April 4, 2014 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
Karuzo Posted April 4, 2014 Share Posted April 4, 2014 @manawaydan: that will create the sound in the coordinate: 0,0,0 so that doesnt make sense. Link to comment
cheez3d Posted April 4, 2014 Share Posted April 4, 2014 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
mint3d Posted April 4, 2014 Author Share Posted April 4, 2014 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
iPrestege Posted April 4, 2014 Share Posted April 4, 2014 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
manawydan Posted April 4, 2014 Share Posted April 4, 2014 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
mint3d Posted April 4, 2014 Author Share Posted April 4, 2014 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
manawydan Posted April 4, 2014 Share Posted April 4, 2014 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
mint3d Posted April 4, 2014 Author Share Posted April 4, 2014 This is really close but I still can do /handbrake if I am passenger I only want driver to be able to do it Link to comment
Woovie Posted April 4, 2014 Share Posted April 4, 2014 Check seat position of source. Link to comment
TrapLord Studios™ Posted April 4, 2014 Share Posted April 4, 2014 Alright, use this. Would help alot, getPedOccupiedVehicleSeat Link to comment
mint3d Posted April 4, 2014 Author Share Posted April 4, 2014 Tried everything I can and it still don't work for only driver Link to comment
Castillo Posted April 5, 2014 Share Posted April 5, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now