depato123 Posted June 27, 2013 Share Posted June 27, 2013 ¿hay algún recurso de alarma? por ejemplo si un usuario quiera abrir un auto que esta cerrado suene la alarma Link to comment
depato123 Posted June 27, 2013 Author Share Posted June 27, 2013 Puedes utilizar playSound ¿y para que ocurra cada vez que alguien intente entrar a un auto cerrado/lockeado? Link to comment
MTA Team 0xCiBeR Posted June 27, 2013 MTA Team Share Posted June 27, 2013 Usas: onVehicleStartEnter if playSound En el If obtienes si esta cerrado, con el evento onVehicleStartEnter, trigeas tu funcion, con playSound reporoduces el sonido..Tambien podes trigear alguna funcion Client-Side para reproducir el sonido en un punto exacto globalmente.. Link to comment
BorderLine Posted June 28, 2013 Share Posted June 28, 2013 Fijate que en playSound, el segundo argumento es para definir si se reproducira segida mente. No pongas true, sino al activar el lock, sonara muchas veces. tendria que ser algo asi playSound(filePath, false) ahora si usas el scrit por serverside, podrias usar sonidos que vienen en GTA por defecto usando playSoundFrontEnd Link to comment
depato123 Posted June 28, 2013 Author Share Posted June 28, 2013 Intente esto pero no me funcionó function onVehicleStartEnter local sound = playSound("sounds/alarma.mp3", false) setSoundVolume(sound, 0.5) end addEventHandler("onClientPlayerWasted", getLocalPlayer(), onVehicleStartEnter) Link to comment
AlvareZ_ Posted June 28, 2013 Share Posted June 28, 2013 onClientPlayerWasted (?), eso es cuando muera el jugador Link to comment
BorderLine Posted June 28, 2013 Share Posted June 28, 2013 te ayudare. intenta asi function alarm(thePlayer) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) x,y,z = getElementPosition(playervehicle) if isVehicleLocked ( playervehicle ) then local sound = playSound3D("sounds/alarma.mp3",x,y,z, false) setSoundVolume(sound, 0.5) end end addEventHandler("onClientVehicleStartEnter", getRootElement(),alarm) Link to comment
depato123 Posted June 28, 2013 Author Share Posted June 28, 2013 onClientPlayerWasted (?), eso es cuando muera el jugador me olvide de sacarlo cuando copie lo de la wiki Link to comment
depato123 Posted June 28, 2013 Author Share Posted June 28, 2013 (edited) te funciono lo que te di? no, no funciono le hice unos pequeños cambios y sigue sin funcionar ------ Alarma de autos ---------- function alarm(thePlayer) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) x,y,z = getElementPosition(playervehicle) if isVehicleLocked ( playervehicle ) then local sound = playSound3D("alarma.mp3",x,y,z, false) setSoundVolume(sound, 0.5) end end addEventHandler("onClientVehicleStartEnter", getRootElement(),alarm) ¿pero esta alarma se debe activar cuando alguien intenta entrar a un vehículo cerrado? Edited June 28, 2013 by Guest Link to comment
depato123 Posted June 28, 2013 Author Share Posted June 28, 2013 type="script" version="1.0.0" /> Link to comment
BorderLine Posted June 28, 2013 Share Posted June 28, 2013 intenta asi type="script" version="1.0.0" /> function alarm(thePlayer) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) x,y,z = getElementPosition(playervehicle) if isVehicleLocked ( playervehicle ) then local sound = playSound3D("alarma.mp3",x,y,z, false) setSoundVolume(sound, 0.5) end end addEventHandler("onClientVehicleEnter", getRootElement(),alarm) Link to comment
depato123 Posted June 28, 2013 Author Share Posted June 28, 2013 intenta asi... Sigue sin funcioar... :_ Link to comment
AlvareZ_ Posted June 28, 2013 Share Posted June 28, 2013 function alarm(thePlayer) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) x,y,z = getElementPosition(thePlayer) if isVehicleLocked ( playervehicle ) then local sound = playSound3D("alarma.mp3",x,y,z, false) setSoundVolume(sound, 0.5) end end addEventHandler("onClientVehicleEnter", getRootElement(),alarm) Link to comment
BorderLine Posted June 28, 2013 Share Posted June 28, 2013 Perdon. Estaba desde mi celular, ahora termine el codigo y lo probe y funciona SERVERSIDE function alarm(thePlayer, seat) x,y,z = getElementPosition(source) if isVehicleLocked (source) then triggerClientEvent ( "Alarm", getRootElement(), x, y, z ) cancelEvent() end end addEventHandler("onVehicleStartEnter", getRootElement(),alarm) Clientside function Alarm(x,y,z) nv = playSound3D("alarm.mp3", x,y,z, false) setSoundVolume(nv, 0.5) setSoundMaxDistance(nv, 20) end addEvent("Alarm",true) addEventHandler( "Alarm", root, Alarm) Lo demas ya va por tu parte segir modificandolo Link to comment
Otto Posted June 28, 2013 Share Posted June 28, 2013 Cuenta la leyenda que antes se utilizaban las secciones del foro correctamente.. Link to comment
Alexs Posted June 28, 2013 Share Posted June 28, 2013 SERVERSIDE function alarm(thePlayer, seat) local x,y,z = getElementPosition(source) if isVehicleLocked (source) then triggerClientEvent ( "Alarm", root, x, y, z ) --Quite el cancelEvent por que el vehículo ya esta bloqueado y reemplaze getRootElement por la variable 'root'. end end addEventHandler("onVehicleStartEnter", root,alarm) Clientside function Alarm(x,y,z) local nv = playSound3D("alarm.mp3", x,y,z, false) setSoundVolume(nv, 0.5) setSoundMaxDistance(nv, 20) end addEvent("Alarm",true) addEventHandler( "Alarm", root, Alarm) Link to comment
depato123 Posted June 29, 2013 Author Share Posted June 29, 2013 Gracias Alexs y Yakuza, Ahora ¿como puedo hacer para que prenda y apague las luces mientras suena la alarma? y que la alarma suene por un tiempo determinado Link to comment
AlvareZ_ Posted June 29, 2013 Share Posted June 29, 2013 Para el tiempo de alarma usa: setTimer Para las luces: setVehicleOverrideLights -- o setVehicleLightState Link to comment
depato123 Posted June 29, 2013 Author Share Posted June 29, 2013 Intente hacer esto para la funcion de que suene el sonido por tiempo pero no me sirve ahora client side: function Alarm(x,y,z) local nv = playSound3D("alarm.mp3", x,y,z, true) setTimer ( function() setSoundVolume(nv, 0.5) setSoundMaxDistance(nv, 20) end, 5000, 1 ) end addEvent("Alarm",true) addEventHandler( "Alarm", root, Alarm) Link to comment
AlvareZ_ Posted June 29, 2013 Share Posted June 29, 2013 Perdona me falto la funcion setSoundPaused, Intesta esto function Alarm(x,y,z) local nv = playSound3D("alarm.mp3", x,y,z, false) setSoundVolume(nv, 0.5) setSoundMaxDistance(nv, 20) setTimer(setSoundPaused, 5000, 1, nv, true) end addEvent("Alarm",true) addEventHandler( "Alarm", root, Alarm) Link to comment
depato123 Posted June 29, 2013 Author Share Posted June 29, 2013 Cambie la repeticion del sonido por un sonido mas largo y tienen algun ejemplo de los de las luces no entendí bien y intente con esto function Alarm(x,y,z) local nv = playSound3D("alarm.mp3", x,y,z, false) setSoundVolume(nv, 0.5) setSoundMaxDistance(nv, 20) if getVehicleOverrideLights( vehicle ) ~= 2 then setVehicleOverrideLights( vehicle, 2 ) else setVehicleOverrideLights( vehicle, 1 ) end end addEvent("Alarm",true) addEventHandler( "Alarm", root, Alarm) Link to comment
AlvareZ_ Posted June 29, 2013 Share Posted June 29, 2013 En lo siguiente lo que hará es para el sonido a los 6 segundos, en donde las luces prenderán y apagaran dime si te funciona function Alarm(x,y,z) local nv = playSound3D("alarm.mp3", x,y,z, false) setSoundVolume(nv, 0.5) setSoundMaxDistance(nv, 20) setTimer(setVehicleOverrideLights, 1000, 1, theVehicle, 1) setTimer(setVehicleOverrideLights, 2000, 1, theVehicle, 2) setTimer(setVehicleOverrideLights, 3000, 1, theVehicle, 1) setTimer(setVehicleOverrideLights, 4000, 1, theVehicle, 2) setTimer(setVehicleOverrideLights, 5000, 1, theVehicle, 1) setTimer(setSoundPaused, 6000, 1, nv, true) end end addEvent("Alarm",true) addEventHandler( "Alarm", root, Alarm) Link to comment
Recommended Posts