Jump to content

Vehicle lock sound.


DzMGZXL

Recommended Posts

That's because the is played Client Side.
triggerClientEvent(source, "onLock", root) -- arg1. Source of the event is source, arg2. "onLock" the event, arg3. sent to? All a.k.a root. 

can you please help me make it when everyone can hear sound?I use root doesn't work.

Link to comment
client:
addEvent ( "playSoundForAllPlayers" , true) 
addEventHandler("playSoundForAllPlayers", root, 
function() 
playSound3D(...) 
end) 

And in server, use this whenever you want to play the sound.

triggerClientEvent("playSoundForAllPlayers", root) 

Read this on another post

Doesn't work :|

Link to comment
addEvent("lockUnlockOutsideVehicle", true) 
addEventHandler("lockUnlockOutsideVehicle", getRootElement(), lockUnlockOutside) 

what is the point of this? are you triggering it from client side? because if so you are triggering from Client the server and back to client.

I use it because i have locks with key "K" and i trigger it in server side.

Link to comment
  • Moderators
triggerClientEvent( 
root,-- target 
"onLock",-- event 
vehicle -- vehicle = source  
) 

-- this was correct -- 
addEvent("onLock",true) 
addEventHandler("onLock",root, 
function() 
    if isElement(source) then 
        local x,y,z = getElementPosition(source) -- source = vehicle 
        playSound3D("CarAlarmChirp.mp3",x,y,z) 
    end 
end) 

Edited by Guest
Link to comment
triggerClientEvent( 
root,-- target 
"onLock"-- event 
vehicle -- vehicle = source  
) 

-- this was correct -- 
addEvent("onLock",true) 
addEventHandler("onLock",root, 
function() 
    if isElement(source) then 
        local x,y,z = getElementPosition(source) -- source = vehicle 
        playSound3D("CarAlarmChirp.mp3",x,y,z) 
    end 
end) 

Still doesn't work.

Link to comment
Then you made a mistake somewhere else.

Debug your code using debug lines else I can't help you.

client

addEvent("onLock",true) 
addEventHandler("onLock",root, 
function() 
    if isElement(source) then 
        local x,y,z = getElementPosition(source) -- source = vehicle 
        playSound3D("CarAlarmChirp.mp3",x,y,z) 
    end 
end) 

And in SERVER

triggerClientEvent("onLock", root) 

Link to comment
  • Moderators

If you don't take over my code correctly, it will not work!

triggerClientEvent( 
    root,-- target 
    "onLock",-- event 
    vehicle -- vehicle = source 
    ) 

IS -_-" AAARRRRGRRRRR!!

triggerClientEvent(root,"onLock",vehicle) 

Link to comment
If you don't take over my code correctly, it will not work!
triggerClientEvent( 
    root,-- target 
    "onLock",-- event 
    vehicle -- vehicle = source 
    ) 

IS -_-" AAARRRRGRRRRR!!

triggerClientEvent(root,"onLock",vehicle) 

Thanks now everything works perfect! :)

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