Jump to content

Ayuda con este script!


Matty

Recommended Posts

Posted

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 :D

mattybanner.jpg

...Learning Scripting...

State: Rookie, Noob

[AP3]=Matty!=

My Skype: mattias.netz

Posted
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:

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Posted

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) :roll:

mattybanner.jpg

...Learning Scripting...

State: Rookie, Noob

[AP3]=Matty!=

My Skype: mattias.netz

Posted

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 
  

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Posted

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 :o!

mattybanner.jpg

...Learning Scripting...

State: Rookie, Noob

[AP3]=Matty!=

My Skype: mattias.netz

Posted
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

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted
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 ;)

mattybanner.jpg

...Learning Scripting...

State: Rookie, Noob

[AP3]=Matty!=

My Skype: mattias.netz

Posted
  
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.

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Posted

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) 

Visita Full GameZ DayZ Mod

Server IP: mtasa://158.69.125.144:29015

Posted

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) 

Visita Full GameZ DayZ Mod

Server IP: mtasa://158.69.125.144:29015

Posted
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.

rsilex.png.0e6ad382b3fdc3cbe6390e3e847572c9.png
Posted
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

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted

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) 

My nickname is: Pato

I am a good mapper, an apprentice in scripting and a talented in photoshop.

Scripting & Mapping server -bmx-

430x73.png

Posted
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

mattybanner.jpg

...Learning Scripting...

State: Rookie, Noob

[AP3]=Matty!=

My Skype: mattias.netz

Posted
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 

Developer @ MYVAL

Posted

Gracais @Alex_Steels.. La reja vuelve y todo pero, ahora el cmd funciona por fuera del Marker cuando lo pones mas de 1 vez :|

mattybanner.jpg

...Learning Scripting...

State: Rookie, Noob

[AP3]=Matty!=

My Skype: mattias.netz

Posted
function disablecommand(leaveElement) 
if (leaveElement) then 
  removeCommandHandler ( "open", leaveElement ) 
end 
end 
addEventHandler ("onMarkerLeave",gatec1marker,disablecommand) 

Coloca esto en vez del otro que había.

Developer @ MYVAL

Posted
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...

mattybanner.jpg

...Learning Scripting...

State: Rookie, Noob

[AP3]=Matty!=

My Skype: mattias.netz

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...