Matty Posted August 19, 2012 Share Posted August 19, 2012 Bueno... Holas, hice este simple script de abrir una reja con la ayuda de la wiki de mta.. pero nose como hacer para que la reja vuelva a su posicion inicial.. aca el code: function gate() gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end function move () moveObject(gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297, 0, 0, 0) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), gate) addCommandHandler ( "abrir", move ) la posición inicial seria la de gatec1 Apenas estoy aprendiendo a manejarme con estas cosas... Espero que me den una ayudita Link to comment
iFoReX Posted August 19, 2012 Share Posted August 19, 2012 function gate() gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end function move () moveObject(gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297, 0, 0, 0) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), gate) addCommandHandler ( "abrir", move ) addCommandHandler ( "cerrar", function() moveObject(gatec1, 4000, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end ) C: Link to comment
Matty Posted August 19, 2012 Author Share Posted August 19, 2012 Muchas gracias @ElMota me sirvió mucho... y para que se cierre solamente con el cmd de "abrir" ? (osea, le das a /abrir y en 3 segundos se cierra) Link to comment
iFoReX Posted August 19, 2012 Share Posted August 19, 2012 creo que asi no me manejo mucho con los timers, proba esto : function gate() gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end function move () moveObject(gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297, 0, 0, 0) setTimer(cerrar,3000,1) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), gate) addCommandHandler ( "abrir", move ) function cerrar() moveObject(gatec1, 4000, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end Link to comment
Matty Posted August 19, 2012 Author Share Posted August 19, 2012 Okey. Gracias por tomarte el tiempo.. una ultima cuestión: yo para poder hacer que el cmd de "abrir" funcione solo serca de la reja, tendría que usar el evento 'onClientMarkerIt' entre otros cierto? PD: Gracias por tu ayuda ! Link to comment
iFoReX Posted August 19, 2012 Share Posted August 19, 2012 xDD, Si, tendrias que crear un marker, cerca de la reja, este marker funcionara como sensor, y onClientMarkerHit = cuando el player entra al marker, asi que si :3 Link to comment
BorderLine Posted August 19, 2012 Share Posted August 19, 2012 gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) gatec1marker = createMarker ( 1521.6103515625, 1789.4267578125, 7.57905626297,'cylinder', 15, 0, 0, 255, 0) function open(hitPlayer) moveObject (gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297) end addEventHandler("onMarkerHit",gatec1marker , open) function close(hitPlayer) moveObject (gatec1,3000,1521.6103515625, 1789.4267578125, 7.57905626297) end addEventHandler ("onMarkerLeave",gatec1marker,close) prueba esto y si te gusta. Con marcadores. Nomas editale el tamaño del marker Link to comment
Matty Posted August 19, 2012 Author Share Posted August 19, 2012 gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) gatec1marker = createMarker ( 1521.6103515625, 1789.4267578125, 7.57905626297,'cylinder', 15, 0, 0, 255, 0) function open(hitPlayer) moveObject (gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297) end addEventHandler("onMarkerHit",gatec1marker , open) function close(hitPlayer) moveObject (gatec1,3000,1521.6103515625, 1789.4267578125, 7.57905626297) end addEventHandler ("onMarkerLeave",gatec1marker,close) prueba esto y si te gusta. Con marcadores. Nomas editale el tamaño del marker Gracias @Yakuza357 por tu respuesta... Pero ahora busco como hacerle para que el cmd funcione solo serca de la reja Link to comment
iFoReX Posted August 19, 2012 Share Posted August 19, 2012 gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) gatec1marker = createMarker ( 1521.6103515625, 1789.4267578125, 7.57905626297,'cylinder', 15, 0, 0, 255, 0) function abrir() moveObject (gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297) end function open(hitPlayer) addCommandHandler("abrir",abrir) end addEventHandler("onMarkerHit",gatec1marker , open) proba esto. Link to comment
Plate Posted August 19, 2012 Share Posted August 19, 2012 Creo que seria haci gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) gatec1marker = createMarker ( 1521.6103515625, 1789.4267578125, 7.57905626297,'cylinder', 15, 0, 0, 255, 0) function abrir() moveObject (gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297) end function open(hitPlayer) addCommandHandler("abrir",abrir) end addEventHandler("onMarkerHit",getRootElement(),open) Link to comment
Matty Posted August 19, 2012 Author Share Posted August 19, 2012 sigue igual Gracias por la ayuda Link to comment
Plate Posted August 19, 2012 Share Posted August 19, 2012 No entendi muy bien lo que quisistes hacer pero proba haci gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) gatec1marker = createMarker ( 1521.6103515625, 1789.4267578125, 7.57905626297,'cylinder', 15, 0, 0, 255, 0) function abrir() moveObject (gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297) end function open(hitPlayer) addCommandHandler("abrir",abrir) end addEventHandler("onMarkerHit",getRootElement(),abrir) Link to comment
Arsilex Posted August 19, 2012 Share Posted August 19, 2012 gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) addEventHandler( "onElementClicked", resourceRoot, function( button, state, player ) if button == "left" and state == "up" then local x, y, z = getElementPosition( player ) if getDistanceBetweenPoints3D( x, y, z, getElementPosition( source ) ) < 5 and getElementDimension( player ) == getElementDimension( source ) then moveObject (gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297) end end end ) Mira esto no se si te servira pero se mueve la puerta cuando el persona esta cerca de ella y presiona encima de ella con el boton izquierdo del rato espero que te sirva. Link to comment
BorderLine Posted August 19, 2012 Share Posted August 19, 2012 gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) gatec1marker = createMarker ( 1521.6103515625, 1789.4267578125, 7.57905626297,'cylinder', 15, 0, 0, 255, 0) function enablecommand (hitPlayer) if (hitPlayer == gatec1maker) then addCommandHandler("open",open) end end addEventHandler("onMarkerHit",gatec1marker , enablecommand) function disablecommand(hitPlayer) removeEventHandler("onMarkerHit",gatec1marker , enablecommand) end addEventHandler ("onMarkerLeave",gatec1marker,disablecommand) function open() moveObject (gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297) end function close(hitPlayer) moveObject (gatec1,3000,1521.6103515625, 1789.4267578125, 7.57905626297) end addEventHandler ("onMarkerLeave",gatec1marker,close) Nose si funcione pero intenta Link to comment
JuegosPato Posted August 19, 2012 Share Posted August 19, 2012 Ya lo arregle, este es de comando y hay otros que se abren automáticamente con un marker invisible, como la de Yakuza357. door = createObject (7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0 ) function opendoor() moveObject (door, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297, 0, 0, 0) end addCommandHandler("abrir", opendoor) function closedoor() moveObject (7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end addCommandHandler("cerrar", closedoor) Link to comment
Matty Posted August 19, 2012 Author Share Posted August 19, 2012 Ya lo arregle, este es de comando y hay otros que se abren automáticamente con un marker invisible, como la de Yakuza357. door = createObject (7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0 ) function opendoor() moveObject (door, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297, 0, 0, 0) end addCommandHandler("abrir", opendoor) function closedoor() moveObject (7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end addCommandHandler("cerrar", closedoor) @JuegosPato No es eso lo que buscaba pero gracias por tomarte el tiempo. Gracias a los que me ayudaron y a la Wiki de MTA pude lograr que el cmd de abrir la reja funcione solo de serca. El code: gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) gatec1marker = createMarker ( 1521.6103515625, 1789.4267578125, 7.57905626297,'cylinder', 15, 0, 0, 255, 100) function enablecommand (hitPlayer) if (hitPlayer) then addCommandHandler("open",open) end end addEventHandler("onMarkerHit",gatec1marker , enablecommand) function disablecommand(leaveElement) if (leaveElement) then removeEventHandler("onMarkerHit",gatec1marker , enablecommand) end end addEventHandler ("onMarkerLeave",gatec1marker,disablecommand) function open() moveObject (gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297) end Solo faltaría que se cierre automáticamente como en este code: function gate() gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end function move () moveObject(gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297, 0, 0, 0) setTimer(cerrar,3000,1) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), gate) addCommandHandler ( "abrir", move ) function cerrar() moveObject(gatec1, 4000, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end echo por @ElMota Link to comment
Alexs Posted August 19, 2012 Share Posted August 19, 2012 gatec1 = createObject(7017, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) gatec1marker = createMarker ( 1521.6103515625, 1789.4267578125, 7.57905626297,'cylinder', 15, 0, 0, 255, 100) function enablecommand (hitPlayer) if (hitPlayer) then addCommandHandler("open",open) end end addEventHandler("onMarkerHit",gatec1marker , enablecommand) function disablecommand(leaveElement) if (leaveElement) then removeEventHandler("onMarkerHit",gatec1marker , enablecommand) end end addEventHandler ("onMarkerLeave",gatec1marker,disablecommand) function open() moveObject (gatec1, 4000, 1527.1838378906, 1789.4267578125, 7.57905626297) setTimer(autoclose, 5000, 1) end function autoclose () moveObject (gatec1, 1521.6103515625, 1789.4267578125, 7.57905626297, 0, 90, 0) end Link to comment
Matty Posted August 19, 2012 Author Share Posted August 19, 2012 Gracais @Alex_Steels.. La reja vuelve y todo pero, ahora el cmd funciona por fuera del Marker cuando lo pones mas de 1 vez Link to comment
Alexs Posted August 19, 2012 Share Posted August 19, 2012 function disablecommand(leaveElement) if (leaveElement) then removeCommandHandler ( "open", leaveElement ) end end addEventHandler ("onMarkerLeave",gatec1marker,disablecommand) Coloca esto en vez del otro que había. Link to comment
Matty Posted August 19, 2012 Author Share Posted August 19, 2012 function disablecommand(leaveElement) if (leaveElement) then removeCommandHandler ( "open", leaveElement ) end end addEventHandler ("onMarkerLeave",gatec1marker,disablecommand) Coloca esto en vez del otro que había. Juaass...Me funco, gracias @Alexs_Steel y a todos los que me ayudaron y respondieron... Link to comment
Recommended Posts