Jump to content

Car Alarm


myonlake

Recommended Posts

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 by myonlake
Link to comment

EDIT 2: Fixed, added "source" there :P

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 :D

Yeah, thanks anyways! :P

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