maauroo Posted September 22, 2012 Share Posted September 22, 2012 Hola Me Gustaria que me ayuden a poner alarma al vehiculo con sonido .Wav y que se active cuando esta bloqueado el auto y cuando me lo intenta abrir que suene la alarma.. Agradesco su ayuda... Link to comment
Xperia Posted September 22, 2012 Share Posted September 22, 2012 ¿Pero a que suene al coche, y ya esta, o que cuando alguien que no sea el dueño del coche, y este bloqueado, lo intenta brir y suene una alarma y un mensaje en el chat al dueño ? Link to comment
DefearT Posted September 23, 2012 Share Posted September 23, 2012 Creo que lo que se refiere es a que cuando alguien ose, cual quiere player intente entrar en el vehiculo suene el archivo .wav, creo que aun tengo un archivo que lo estaba haciendo algo parecido pero no lo eh terminado, te lo dejo aver que puedes hacer.. Link to comment
DefearT Posted September 23, 2012 Share Posted September 23, 2012 Este es el Client-Side localPlayer = getLocalPlayer ( ) addEvent ( "onPlaySoundNearElement", true ) function playSoundNearElement ( theElement, sound ) local maxdist = 15.0 if ( theElement ) then local x,y,z = getElementPosition ( theElement ) local x2,y2,z2 = getElementPosition ( localPlayer ) local dist = getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) if ( dist < maxdist ) then playSoundFrontEnd ( 5 ) else end else end end addEventHandler ( "onPlaySoundNearElement", getRootElement(), playSoundNearElement ) addEvent("prendeAlarma",true) Alarmas = {} function alarmita(auto) local x,y,z = getElementPosition(auto) Alarmas[auto] = playSound3D("alarm.wav",x,y,z,true) attachElements(Alarmas[auto],auto) setSoundMaxDistance(Alarmas[auto],20) setSoundVolume(Alarmas[auto],2) end addEventHandler ("prendeAlarma", getRootElement(), alarmita) addEvent("apagaAlarma",true) function apagame(auto) stopSound(Alarmas[auto]) end addEventHandler("apagaAlarma",getRootElement(), apagame) addEvent("AlarmaCulia",true) function apagatectm() for k,v in pairs(Alarmas) do if(not isElement( k )) then stopSound(v); Alarmas[k] = nil; end end end addEventHandler("AlarmaCulia", getRootElement(), apagatectm) Y este el Server-Side function initCarLocks () local players = getElementsByType ( "player" ) for k,p in ipairs(players) do removeElementData ( p, "cl_ownedvehicle" ) bindKey ( p, "l", "down", doToggleLocked ) end local vehicles = getElementsByType ( "vehicle" ) for k,v in ipairs(vehicles) do removeElementData ( v, "cl_vehicleowner" ) removeElementData ( v, "cl_vehiclelocked" ) setVehicleLocked ( v, false ) end end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), initCarLocks ) addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource () ), initCarLocks ) function cl_PlayerJoin ( ) bindKey ( source, "l", "down", doToggleLocked ) end addEventHandler ( "onPlayerJoin", getRootElement(), cl_PlayerJoin ) function cl_PlayerQuit ( ) local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerQuit", getRootElement(), cl_PlayerQuit ) function cl_PlayerWasted ( ) local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerWasted", getRootElement(), cl_PlayerWasted ) function cl_VehicleStartEnter ( enteringPlayer, seat, jacked ) local theVehicle = source local theOwner if ( getElementData ( theVehicle, "cl_vehiclelocked" ) == true ) then theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if theOwner ~= false and theOwner ~= enteringPlayer then end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), cl_VehicleStartEnter ) function cl_PlayerDriveVehicle ( player, seat, jacked ) if ( seat == 0 ) then oldVehicle = getElementData ( player, "cl_ownedvehicle" ) if ( (cl_VehicleLocked(source) == true) and (cl_VehicleOwner(source) ~= player) ) then removePedFromVehicle( player ) Err_Msg("This vehicle is locked.", player) return false end cl_SetVehicleOwner ( source, player ) end return true end addEventHandler ( "onVehicleEnter", getRootElement(), cl_PlayerDriveVehicle ) function cl_VehicleRespawn ( exploded ) cl_RemoveVehicleOwner ( source ) end addEventHandler ( "OnVehicleRespawn", getRootElement(), cl_VehicleRespawn ) function cl_VehicleExplode ( ) local theOwner = getElementData ( source, "cl_vehicleowner" ) if ( theOwner ~= false ) then cl_RemoveVehicleOwner ( source ) end end addEventHandler ( "onVehicleExplode", getRootElement(), cl_VehicleExplode ) function cl_SetVehicleOwner ( theVehicle, thePlayer ) local oldVehicle = getElementData ( thePlayer, "cl_ownedvehicle" ) if ( oldVehicle ~= false ) then removeElementData ( oldVehicle, "cl_vehicleowner" ) removeElementData ( oldVehicle, "cl_vehiclelocked" ) setVehicleLocked ( oldVehicle, false ) end setElementData ( theVehicle, "cl_vehicleowner", thePlayer ) setElementData ( theVehicle, "cl_vehiclelocked", false ) setElementData ( thePlayer, "cl_ownedvehicle", theVehicle ) 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" ) end setVehicleLocked ( theVehicle, false ) end function cl_FlashLights ( thePlayer ) setTimer ( doToggleLights, 300, 4, thePlayer, true ) end function cl_FlashOnce ( thePlayer ) setTimer ( doToggleLights, 300, 2, thePlayer, true ) end function cl_VehicleOwner ( theVehicle ) return getElementData( theVehicle, "cl_vehicleowner" ) end function cl_VehicleLocked ( theVehicle ) return getElementData( theVehicle, "cl_vehiclelocked" ) end function Err_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 200, 0, 10 ) end 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 function Info_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 102, 205, 170 ) end 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 ) 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 ) 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 ( getVehicleController ( theVehicle ) == false ) then cl_FlashOnce ( source ) end end else Err_Msg("You must have a vehicle to unlock it.", source) end end function doToggleLights ( source, beep ) local theVehicle if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then if ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then setVehicleOverrideLights ( theVehicle, 2 ) if ( beep == true ) then local theElement = theVehicle triggerClientEvent ( getRootElement(), "onPlaySoundNearElement", getRootElement(), theElement, 5) end else setVehicleOverrideLights ( theVehicle, 1 ) end else Err_Msg("You must have a vehicle to control the lights.", source ) end end addCommandHandler ( "lock", doLockVehicle ) addCommandHandler ( "unlock", doUnlockVehicle ) Espero que lo puedas hacer algo aver si te funciona, PD: Nunca lo eh provado.. Link to comment
Renkon Posted September 23, 2012 Share Posted September 23, 2012 Deja como mínimo el script fuente de donde conseguiste eso.. Además, creo que es mucho mas facil un playSound3D Link to comment
maauroo Posted September 23, 2012 Author Share Posted September 23, 2012 El problema que no suena.. cual es el problema ?? Link to comment
DefearT Posted September 23, 2012 Share Posted September 23, 2012 La fuente la empese de la comunidad hay un resource de bloquear los vehiculos y ps y empese con la musica que cuando estubieran abriendola y esta bloqueado ps sonara la musica pero no se si funciona, pruebalo aver que tal.. Link to comment
maauroo Posted September 23, 2012 Author Share Posted September 23, 2012 Puse El Script Que Me Pasaron Pero No Suena La Alarma.. Como Puedo Arreglar Ese Problema ?? Link to comment
Alexs Posted September 23, 2012 Share Posted September 23, 2012 Ya intentaste con: addEventHandler("onClientVehicleStartEnter", root, function(thePlayer, seat) if seat == 0 then if isVehicleLocked ( source ) then local x,y,z = getElementPosition(source) playSound3D("tuaudio.wav", x,y,z) end end end ) ?? Link to comment
maauroo Posted September 23, 2012 Author Share Posted September 23, 2012 Funciona Bien Pero como puedo hacer la funcion para que siga sonando hasta que el dueño lo desactive?? Link to comment
BorderLine Posted September 24, 2012 Share Posted September 24, 2012 agregale el argumento a playSound de loop al sonido agregarle una variable a playSound3D("tuaudio.wav", x,y,z) y usar stopSound a la funcion de desactivar desactivando el sonido de playSound... Link to comment
maauroo Posted September 24, 2012 Author Share Posted September 24, 2012 Como le puedo meter el variable a esta funcion? addEventHandler("onClientVehicleStartEnter", root, function(thePlayer, seat) if seat == 0 then if isVehicleLocked ( source ) then local x,y,z = getElementPosition(source) playSound3D("tuaudio.wav", x,y,z) end end end ) Link to comment
BorderLine Posted September 24, 2012 Share Posted September 24, 2012 addEventHandler("onClientVehicleStartEnter", root, function(thePlayer, seat) if seat == 0 then if isVehicleLocked ( source ) then local x,y,z = getElementPosition(source) audio = playSound3D("tuaudio.wav", x,y,z,true) end end end ) -- y dentro de la funcion para que desactive agregas stopSound(audio) Link to comment
maauroo Posted September 24, 2012 Author Share Posted September 24, 2012 Y Como le puedo poner la funcion Que Cuando Este Desbloqueado Detenga La Alarma ? Link to comment
Xperia Posted September 24, 2012 Share Posted September 24, 2012 Prueba con: if () then stopSound(audio) Link to comment
maauroo Posted September 24, 2012 Author Share Posted September 24, 2012 mm Lo Tengo Asi: addEventHandler("onClientVehicleStartEnter", root, function(thePlayer, seat) if seat == 0 then if isVehicleLocked ( source ) then local x,y,z = getElementPosition(source) audio = playSound3D("tuaudio.wav", x,y,z,true) end end end ) function stopMySound() stopSound(audio) end addCommandHandler ( "stopsound", stopMySound ) Pero en ves de la funcion comando, que tuaudio.wav se detenga cuando el vehiculo esta desbloqueado. se entiende ? Link to comment
Arsilex Posted September 25, 2012 Share Posted September 25, 2012 intenta trigear un evento desde cuando el dueño abre el coche pos que se active esto.. Link to comment
maauroo Posted September 25, 2012 Author Share Posted September 25, 2012 Emm no entendi Me podrias dar la funcion para que se desactive la alarma cuando lo desbloquea? Link to comment
Renkon Posted September 25, 2012 Share Posted September 25, 2012 Usa stopSound, cuando el auto se desbloquee Link to comment
maauroo Posted September 26, 2012 Author Share Posted September 26, 2012 pero me falta la funcion desbloqueo me entiendes ?? Link to comment
Recommended Posts