-.Paradox.- Posted July 26, 2013 Share Posted July 26, 2013 Hello i have this vehicle car lock system, and i want to locate the file when vehicle is locked it will play "files/lock.mp3"& when unlocked it will play "files/unlock.mp3" here is the code client side: -- Car Locks ( client ) -- local player localPlayer = getLocalPlayer ( ) -- playSoundNearElement addEvent ( "onPlaySoundNearElement", true ) function playSoundNearElement ( theElement, sound ) -- local sound = 5 local maxdist = 15.0 -- valid element if ( theElement ) then local x,y,z = getElementPosition ( theElement ) local x2,y2,z2 = getElementPosition ( localPlayer ) local dist = getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) -- distance is less than parameter maxdist if ( dist < maxdist ) then -- play parameter sound playSoundFrontEnd ( 5 ) -- outputChatBox ( "sound should play" ) else -- outputChatBox ( "not in range" ) end else -- outputChatBox ( "invalid element" ) end end addEventHandler ( "onPlaySoundNearElement", getRootElement(), playSoundNearElement ) server side -- Car Locks ( client ) -- local player localPlayer = getLocalPlayer ( ) -- playSoundNearElement addEvent ( "onPlaySoundNearElement", true ) function playSoundNearElement ( theElement, sound ) -- local sound = 5 local maxdist = 15.0 -- valid element if ( theElement ) then local x,y,z = getElementPosition ( theElement ) local x2,y2,z2 = getElementPosition ( localPlayer ) local dist = getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) -- distance is less than parameter maxdist if ( dist < maxdist ) then -- play parameter sound playSoundFrontEnd ( 5 ) -- outputChatBox ( "sound should play" ) else -- outputChatBox ( "not in range" ) end else -- outputChatBox ( "invalid element" ) end end addEventHandler ( "onPlaySoundNearElement", getRootElement(), playSoundNearElement ) thanks for helping Link to comment
-.Paradox.- Posted July 26, 2013 Author Share Posted July 26, 2013 function playLockingSound(vehicle) if vehicle then source = vehicle end local x,y,z = getElementPosition(source) local lockSound = playSound3D("files/lock.mp3", x, y, z) setSoundMaxDistance(lockSound, 50) attachElements(lockSound, source) beep(source) end addEvent("onClientVehicleLock", true) addEventHandler("onClientVehicleLock", root, playLockingSound) function playUnlockingSound() stopVehicleAlarm(source) local x,y,z = getElementPosition(source) local unlockSound = playSound3D("files/unlock.mp3", x, y, z) setSoundMaxDistance(unlockSound, 50) attachElements(unlockSound, source) beep(source) setTimer(beep, 200, 1, source) end addEvent("onClientVehicleUnlock", true) addEventHandler("onClientVehicleUnlock", root, playUnlockingSound) i tried not working Link to comment
HunT Posted July 26, 2013 Share Posted July 26, 2013 https://wiki.multitheftauto.com/wiki/On ... StartEnter https://wiki.multitheftauto.com/wiki/IsVehicleLocked Link to comment
-.Paradox.- Posted July 26, 2013 Author Share Posted July 26, 2013 ._. can you fix my code please? Link to comment
HunT Posted July 26, 2013 Share Posted July 26, 2013 viewtopic.php?f=91&p=383222 Search before posting Link to comment
-.Paradox.- Posted July 26, 2013 Author Share Posted July 26, 2013 Working but what about unlocking? Link to comment
HunT Posted July 26, 2013 Share Posted July 26, 2013 So . . If the the Vehicle is locked = play If the the vehicle is unlocked = play other sound True? I reply with iPhone can't give example,anyway add the else. Link to comment
-.Paradox.- Posted July 26, 2013 Author Share Posted July 26, 2013 (edited) i'm connected from iPhone too Yes. Edited July 26, 2013 by Guest Link to comment
iMr.3a[Z]eF Posted July 26, 2013 Share Posted July 26, 2013 Answer the Hunterix question. 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