-.Paradox.- Posted July 8, 2013 Share Posted July 8, 2013 Hello guys, i'm looking for a vehicle alarm system if player locked vehicle it will play sound lock.mp3 if vehicle unlocked play unlock.mp3 and if player hit you're it play alarm.mp3 Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 bindKey -- bind key setVehicleLocked -- lock isVehicleLocked -- check lock triggerClientEvent -- call client playSound -- sound createMarker -- marker 'onVehicleEnter' -- Event 'onVehicleStartEnter' -- Event attachElements -- marker 'onMarkerHit' -- trigger to client then play sound getElementType -- check the type of the element isElement -- check sound destroyElement -- destroy sound or marker 'onVehicleExit' -- Event 'onVehicleStartExit' -- Event Link to comment
-.Paradox.- Posted July 8, 2013 Author Share Posted July 8, 2013 addEventHandler("onClientVehicleStartEnter", root, function(thePlayer, seat) if seat == 0 then if isVehicleLocked ( source ) then local x,y,z = getElementPosition(source) audio = playSound3D("lock.mp3", x,y,z,true) end end end ) function stopMySound() stopSound(audio) end addCommandHandler ( "stopalarm", stopMySound ) Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 You didn't use what i post above. Link to comment
-.Paradox.- Posted July 8, 2013 Author Share Posted July 8, 2013 yes but thats all what i understand Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 Time to learn? Lua tutorials, manuals Main_Page Link to comment
AlvareZ_ Posted July 8, 2013 Share Posted July 8, 2013 playSound "onVehicleStartEnter" setSoundMaxDistance stopSound isVehicleLocked getElementPosition Link to comment
-.Paradox.- Posted July 8, 2013 Author Share Posted July 8, 2013 can you fix it to me? i'm kinda lazy srry for that work ._. Link to comment
-.Paradox.- Posted July 8, 2013 Author Share Posted July 8, 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) function beep(vehicle) if getVehicleOverrideLights(vehicle) ~= 2 then setVehicleOverrideLights(vehicle, 2) setTimer(setVehicleOverrideLights, 100, 1, vehicle, 1) else setVehicleOverrideLights(vehicle, 1) setTimer(setVehicleOverrideLights, 100, 1, vehicle, 2) end end Link to comment
-.Paradox.- Posted July 8, 2013 Author Share Posted July 8, 2013 No erros still not working Link to comment
-.Paradox.- Posted July 8, 2013 Author Share Posted July 8, 2013 yes i want just if player lock vehicle it play lock.mp3 sound when unlock play unlock.mp3 sound and if player hit the vehicle play alarm.mp3 sound Link to comment
iMr.3a[Z]eF Posted July 9, 2013 Share Posted July 9, 2013 did you made Client Side either? Link to comment
-.Paradox.- Posted July 9, 2013 Author Share Posted July 9, 2013 i dont know how to make it please help me Link to comment
iMr.3a[Z]eF Posted July 9, 2013 Share Posted July 9, 2013 why you have to make it download this resource: https://community.multitheftauto.com/in ... ils&id=131 Link to comment
-.Paradox.- Posted July 9, 2013 Author Share Posted July 9, 2013 i have already but i have alarm like reallife alarms but i dont know how to make it Link to comment
iMr.3a[Z]eF Posted July 9, 2013 Share Posted July 9, 2013 i have already but i have alarm like reallife alarms but i dont know how to make it you just have a sound and you wanna change it? change your sounds name as in the floder then replace it with thembe sure that the sounds name as them Link to comment
-.Paradox.- Posted July 16, 2013 Author Share Posted July 16, 2013 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 ( server ) -- by vick. -- ================= -- player element data -- -- cl_ownedvehicle -- vehicle element data -- -- cl_vehicleowner -- cl_vehiclelocked -- cl_enginestate -- resource starts - ends function initCarLocks () -- Initilize Player Element Data local players = getElementsByType ( "player" ) for k,p in ipairs(players) do removeElementData ( p, "cl_ownedvehicle" ) bindKey ( p, "l", "down", doToggleLocked ) end -- Initilize Vehicle Element Data local vehicles = getElementsByType ( "vehicle" ) for k,v in ipairs(vehicles) do removeElementData ( v, "cl_vehicleowner" ) removeElementData ( v, "cl_vehiclelocked" ) removeElementData ( v, "cl_enginestate" ) setVehicleLocked ( v, false ) setVehicleOverrideLights ( v, 0 ) end end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), initCarLocks ) addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource () ), initCarLocks ) -- player joins function cl_PlayerJoin ( ) bindKey ( source, "l", "down", doToggleLocked ) end addEventHandler ( "onPlayerJoin", getRootElement(), cl_PlayerJoin ) -- player quits function cl_PlayerQuit ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerQuit", getRootElement(), cl_PlayerQuit ) -- player dies function cl_PlayerWasted ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerWasted", getRootElement(), cl_PlayerWasted ) -- player tries to enter vehicle function cl_VehicleStartEnter ( enteringPlayer, seat, jacked ) local theVehicle = source local theOwner -- locked and not owner entering if ( getElementData ( theVehicle, "cl_vehiclelocked" ) == true ) then theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if theOwner ~= false and theOwner ~= enteringPlayer then -- make sure they dont enter --cancelEvent(); end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), cl_VehicleStartEnter ) -- player enters a vehicle function cl_PlayerDriveVehicle ( player, seat, jacked ) -- Driver Enter if ( seat == 0 ) then oldVehicle = getElementData ( player, "cl_ownedvehicle" ) -- not entering player's own owned vehicle if ( (cl_VehicleLocked(source) == true) and (cl_VehicleOwner(source) ~= player) ) then removePedFromVehicle( player ) Err_Msg("this vehicle is locked.", player) return false end -- set element data for vehicle and owner cl_SetVehicleOwner ( source, player ) end return true end addEventHandler ( "onVehicleEnter", getRootElement(), cl_PlayerDriveVehicle ) -- vehicle respawns function cl_VehicleRespawn ( exploded ) cl_RemoveVehicleOwner ( source ) end addEventHandler ( "OnVehicleRespawn", getRootElement(), cl_VehicleRespawn ) -- vehicle explosion function cl_VehicleExplode ( ) local theOwner = getElementData ( source, "cl_vehicleowner" ) if ( theOwner ~= false ) then cl_RemoveVehicleOwner ( source ) end end addEventHandler ( "onVehicleExplode", getRootElement(), cl_VehicleExplode ) -- set vehicle owner function cl_SetVehicleOwner ( theVehicle, thePlayer ) local oldVehicle = getElementData ( thePlayer, "cl_ownedvehicle" ) if ( oldVehicle ~= false ) then -- unlock old car removeElementData ( oldVehicle, "cl_vehicleowner" ) removeElementData ( oldVehicle, "cl_vehiclelocked" ) removeElementData ( oldVehicle, "cl_enginestate" ) setVehicleLocked ( oldVehicle, false ) -- set vars for new car end setElementData ( theVehicle, "cl_vehicleowner", thePlayer ) setElementData ( theVehicle, "cl_vehiclelocked", false ) setElementData ( thePlayer, "cl_ownedvehicle", theVehicle ) setElementData( theVehicle, "cl_enginestate", true ) end function cl_RemoveVehicleOwner ( theVehicle ) local theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if ( theOwner ~= false ) then removeElementData ( theOwner, "cl_ownedvehicle" ) removeElementData ( theVehicle, "cl_vehicleowner" ) removeElementData ( theVehicle, "cl_vehiclelocked" ) removeElementData ( owned, "cl_enginestate" ) end setVehicleLocked ( theVehicle, false ) end -- flash the lights twice function cl_FlashLights ( thePlayer ) setTimer ( doToggleLights, 300, 4, thePlayer, true ) end -- flash once function cl_FlashOnce ( thePlayer ) setTimer ( doToggleLights, 300, 2, thePlayer, true ) end -- get vehicle owner ( according to vehicle's element data ) function cl_VehicleOwner ( theVehicle ) return getElementData( theVehicle, "cl_vehicleowner" ) end -- is vehicle locked ( according to vehicle's element data ) function cl_VehicleLocked ( theVehicle ) return getElementData( theVehicle, "cl_vehiclelocked" ) end -- messaging functions -- send red error message function Err_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 200, 0, 10 ) end -- send message to all occupants of vehicle function Car_Msg ( strout, theVehicle ) numseats = getVehicleMaxPassengers ( theVehicle ) for s = 0, numseats do local targetPlayer = getVehicleOccupant ( theVehicle, s ) if targetPlayer ~= false then outputChatBox ( strout, targetPlayer, 30, 144, 255 ) end end end -- send aquamarine message to player function Info_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 102, 205, 170 ) end -- commands function doToggleLocked ( source ) local theVehicle , strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local vehiclename = getVehicleName ( theVehicle ) -- already locked if ( getElementData ( theVehicle, "cl_vehiclelocked") == true ) then doUnlockVehicle ( source ) else doLockVehicle ( source ) end else Err_Msg("You must have a vehicle to lock or unlock it.", source) end end function doLockVehicle ( source ) local theVehicle , strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local vehiclename = getVehicleName ( theVehicle ) -- already locked if ( getElementData ( theVehicle, "cl_vehiclelocked") == true ) then strout = "Your " .. vehiclename .. " is already locked." Err_Msg(strout, source) else setElementData ( theVehicle, "cl_vehiclelocked", true) setVehicleLocked ( theVehicle, true ) Car_Msg( "Current vehicle " .. vehiclename .. " locked.", theVehicle) Info_Msg ( "Locked vehicle " .. vehiclename .. ".", source ) if ( getVehicleController ( theVehicle ) == false ) then cl_FlashLights ( source ) end end else Err_Msg("You must have a vehicle to lock it.", source) end end function doUnlockVehicle ( source ) local theVehicle, strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local vehiclename = getVehicleName ( theVehicle ) if ( getElementData ( theVehicle, "cl_vehiclelocked") == false ) then strout = "Your " .. vehiclename .. " is already unlocked." Err_Msg(strout, source) else setElementData ( theVehicle, "cl_vehiclelocked", false) setVehicleLocked ( theVehicle, false ) Car_Msg( "Current vehicle " .. vehiclename .. " unlocked.", theVehicle ) Info_Msg ( "Unlocked vehicle " .. vehiclename .. ".", source ) if ( Link to comment
iMr.3a[Z]eF Posted July 16, 2013 Share Posted July 16, 2013 you just wanna change the sound? is this code, the resource i give it to you? Link to comment
-.Paradox.- Posted July 16, 2013 Author Share Posted July 16, 2013 yes, i was using it already. Link to comment
ElizabethVillalobos Posted September 9, 2013 Share Posted September 9, 2013 When you are bringing your vehicles at work and leave it in parking lots for most of the time, installing car alarms could shoo away burglars. Tinley Park Locksmith 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