Jump to content

Vehicle lock sound.


DzMGZXL

Recommended Posts

Posted (edited)
triggerClientEvent(source, "onLock", source) 

Now it works but sound can hear only that who lock car

Edited by Guest
Posted

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. 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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

Posted
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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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

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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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

  • Moderators
Posted (edited)
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

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

If you really want to do it like this; client locks -> server request to lock and play the sound -> client request for the sound. You should create a createColSphere with the desired size and get all the elements in there with getElementsWithinColShape. Loop over these and make them all do a triggerClientEvent() to the sound function.

logo-small.png?v=3 tiny-sapdfr.png

 

If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]

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

  • Moderators
Posted

Then you made a mistake somewhere else.

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

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
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) 

  • Moderators
Posted

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) 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
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! :)

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