Khalil Posted August 26, 2012 Share Posted August 26, 2012 Well guys, I just started lua scripting and I made a few "beginner" scripts. Anyway, I made an engine resource that start/stops vehicle engines when you do /engine. I just wanted to add sound effects to it. When someone does /engine in a vehicle, a certain sound goes off. PS. I don't want someone to do it for me, I just need a little help with it. Thanks Link to comment
scratcher911 Posted August 26, 2012 Share Posted August 26, 2012 use playSound or you can use playSoundFrontEnd for the sound from GTA Link to comment
Khalil Posted August 27, 2012 Author Share Posted August 27, 2012 Whats wrong with this? function switchEngine ( playerSource ) local theVehicle = getPedOccupiedVehicle ( playerSource ) -- Check if the player is in any vehicle and if he is the driver if theVehicle and getVehicleController ( theVehicle ) == playerSource then local state = getVehicleEngineState ( theVehicle ) setVehicleEngineState ( theVehicle, not state ) playSound ( sound.mp3, [ bool looped = false ] ) end end addCommandHandler ( "engine", switchEngine ) Link to comment
TAPL Posted August 27, 2012 Share Posted August 27, 2012 function switchEngine(player) local theVehicle = getPedOccupiedVehicle(player) if theVehicle and getVehicleController(theVehicle) == player then setVehicleEngineState(theVehicle, not getVehicleEngineState(theVehicle)) playSound("sound.mp3") end end addCommandHandler("engine", switchEngine) Link to comment
Khalil Posted August 27, 2012 Author Share Posted August 27, 2012 Error: engine\script.lua:5: attempt to call global 'playsound' If it helps, maybe there's something wrong with my meta.xml: "Khalil" type="script" name="engine" description="engine script" /> When I do /engine it works fine but the sound doesn't play.. Link to comment
denny199 Posted August 27, 2012 Share Posted August 27, 2012 lua is sensitive rename this: playSound("sound.mp3") to this: playSound("Sound.mp3") -- I made it Sound instead off sound 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