Jump to content

[Help]Car lock sound.


DzMGZXL

Recommended Posts

Hello! So i want make the script when player lock car it's play sound anyone can help me?This is the part from my car lock script!Anyone can script in it lock sound please?

function lockUnlockOutside(vehicle) 
    if (not source or exports.global:isPlayerAdmin(source)) or ( getElementData(vehicle, "Impounded") or 0 ) == 0 then 
        local dbid = getElementData(vehicle, "dbid") 
         
        if (isVehicleLocked(vehicle)) then 
            setVehicleLocked(vehicle, false) 
            exports.global:sendLocalMeAction(source, "presses on the key to unlock the vehicle. ((" .. getVehicleName(vehicle) .. "))") 
            exports.logs:dbLog(source, 31, {  vehicle }, "UNLOCK FROM OUTSIDE") 
            if not (exports.global:hasItem(source, 3, dbid) or (getElementData(source, "faction") > 0 and getElementData(source, "faction") == getElementData(vehicle, "faction"))) then 
                exports.logs:logMessage("[CAR-UNLOCK] car #" .. dbid .. " was unlocked by " .. getPlayerName(source), 21) 
            end 
        else 
            setVehicleLocked(vehicle, true) 
            exports.global:sendLocalMeAction(source, "presses on the key to lock the vehicle. ((" .. getVehicleName(vehicle) .. "))") 
            exports.logs:dbLog(source, 31, {  vehicle }, "LOCK FROM OUTSIDE") 
            if not (exports.global:hasItem(source, 3, dbid) or (getElementData(source, "faction") > 0 and getElementData(source, "faction") == getElementData(vehicle, "faction"))) then 
                exports.logs:logMessage("[CAR-LOCK] car #" .. dbid .. " was locked by " .. getPlayerName(source), 21) 
            end 
        end 
  
        if (storeTimers[vehicle] == nil) or not (isTimer(storeTimers[vehicle])) then 
            storeTimers[vehicle] = setTimer(storeVehicleLockState, 180000, 1, vehicle, dbid) 
        end 
    end 
end 
addEvent("lockUnlockOutsideVehicle", true) 
addEventHandler("lockUnlockOutsideVehicle", getRootElement(), lockUnlockOutside) 

Link to comment

LekRoots don't post if you don't know how you're going to help him

Get the position of the car with

getElementPosition 

play the locking sound using

playSound3D 

Also use this to change max sound distance so it will not be heard by all the players around the server

setSoundMaxDistance 

and finally use this to attach the 3d sound to the car

attachElements 

  • Like 1
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...