myonlake Posted September 8, 2011 Share Posted September 8, 2011 (edited) Hello, I am trying to do a car alarm system, but it doesn't play the sound when I try to enter a locked car. Here's the client sided code (only client side). function beepClient(thePlayer) local playervehicle = getPedOccupiedVehicle(thePlayer) if isVehicleLocked(playervehicle) then local x, y, z = getElementPosition(thePlayer) local beep = playSound3D("beep.mp3", x, y, z, false) setSoundVolume(beep, 1.0) setSoundMaxDistance(beep, 100) end end addEventHandler("onClientVehicleEnter", getRootElement(), beepClient) I have set the file to the meta.xml and everything seems just fine, but this doesn't give up any error anywhere, and it just simply doesn't work. Maybe it's just a little thing that I cannot regonize right now. Edited May 30, 2019 by myonlake Link to comment
Discord Moderators Zango Posted September 8, 2011 Discord Moderators Share Posted September 8, 2011 I think onClientVehicleEnter is called when the player finished entering the vehicle. Your player never gets to that point if the vehicle is locked. Try using onClientVehicleStartEnter Link to comment
myonlake Posted September 8, 2011 Author Share Posted September 8, 2011 EDIT 2: Fixed, added "source" there EDIT: Now it's doing an error with the "isVehicleLocked" -function. I think onClientVehicleEnter is called when the player finished entering the vehicle. Your player never gets to that point if the vehicle is locked.Try using onClientVehicleStartEnter Oh, just found out the same thing myself Yeah, thanks anyways! 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