Stanley Sathler Posted December 5, 2011 Share Posted December 5, 2011 Hi again, guys. How you can see, I'm still trying make something with Lua. Yeah, that's hard for me. I'm trying make a "gate movement". So I maked this code: -- PORTUGUES -- -- Nome: AbrePortoes.lua -- Funcao: automatiza o movimento de portoes -- Autor: Stanley Sathler - Ingame: |MS-13|F|-Sathler -- ENGLISH -- -- Name: OpenGates.lua -- Function: automates the movement of gates -- Author: Stanley Sathler - Ingame: |MS-13|F|-Sathler local portao_interior_1 = getElementByID("portao_interior_1") local portao_interior_2 = getElementByID("portao_interior_2") local zona_portao = createColTube(213.0, 1875.0, 12.10, 5.0, 5.0) function AbrePortao(jogador, na_dimensao) moveObject(portao_interior_1, 3000, 219.899, 1785.59, 12.10) moveObject(portao_interior_2, 3000, 207.699, 1785.59, 12.10) end addEventHandler("onColShapeHit", zona_portao, AbrePortao) function FechaPortao(jogador, na_dimensao) moveObject(portao_interior_1, 3000, 216.799, 1785.59, 12.10) moveObject(portao_interior_2, 3000, 211.199, 1785.59, 12.10) end addEventHandler("onColShapeLeave", zona_portao, FechaPortao) The objective is move the gate by side (your original position is the same of the indicated on "FechaPortao()" function). But he's moving to the bottom of the map (y position), and not x position. Anyone knows what I do? ): Thank you for attention, Stanley Sathler. Link to comment
tropez Posted December 5, 2011 Share Posted December 5, 2011 Why these positions are so small ? Code looks good. Link to comment
Jaysds1 Posted December 5, 2011 Share Posted December 5, 2011 Don't listen to tropez, The problem is that the "getElementByID" function is incorrect, First you have to make a gate by using "createObject()" and you could use the map editor to help you and save the gates in a file. after doing this, just copy and paste the gate position and model Id in to the script( the createObject(Model ID, GATE position)) then the gates would start moving after the player hit the colTube. Link to comment
Aibo Posted December 5, 2011 Share Posted December 5, 2011 Don't listen to Jaysds1. The problem is that Jaysds1 can't read: objects move fine, just not in the right direction. so what is the point of createObject()? getElementByID() is made for getting elements by ID that is specified in a map file. code looks good, check gate position values in your map file maybe. Link to comment
Stanley Sathler Posted December 5, 2011 Author Share Posted December 5, 2011 I tried change the "z" position instead of "y" but it didn't work too. I tried use createObject() but it didn't work too [2]. The gates were not created. I think that problem is in moveObject() or in getElementByID(). Anyone can help me? ): Link to comment
Stanley Sathler Posted December 5, 2011 Author Share Posted December 5, 2011 Hey guys, calm down! What is this? This is a forum, a comunnity. - I've working in the code and I'm right: the gate is moving in y position, and not in x. I use a getElementPosition for see the inicial position of the gate. And use an outputChatBox() for show the position later of movement. The X is the same of the initial, but the Y is: 1802.511. I'm lost ): Link to comment
tropez Posted December 5, 2011 Share Posted December 5, 2011 Could you paste updated code ? Link to comment
Aibo Posted December 5, 2011 Share Posted December 5, 2011 also map file part where the gate is placed Link to comment
myonlake Posted December 5, 2011 Share Posted December 5, 2011 @Stanley: As the others already said, show us the latest version of your .map and .lua file(s). Link to comment
Towncivilian Posted December 5, 2011 Share Posted December 5, 2011 Moron banned (he was nowofresh & lua_scripter) for flaming & multiple accounts. Thread pruned. Link to comment
Stanley Sathler Posted December 5, 2011 Author Share Posted December 5, 2011 There is the updated code: -- PORTUGUES -- -- Nome: AbrePortoes.lua -- Funcao: automatiza o movimento de portoes -- Autor: Stanley Sathler - Ingame: |MS-13|F|-Sathler -- ENGLISH -- -- Name: OpenGates.lua -- Function: automates the movement of gates -- Author: Stanley Sathler - Ingame: |MS-13|F|-Sathler local portao_interior_1 = getElementByID("portao_interior_1") local portao_interior_2 = getElementByID("portao_interior_2") local posX, posY, posZ = getElementPosition(portao_interior_1) local zona_portao = createColTube(213.0, 1875.0, 12.10, 5.0, 5.0) function AbrePortao(jogador, na_dimensao) moveObject(portao_interior_1, 5000, 216.80000305176, 1875.5999755859, 12.10000038147) moveObject(portao_interior_2, 5000, 211.19999694824, 1875.5999755859, 12.10000038147) outputChatBox("Local 1: "..posX.." | "..posY.." | "..posZ.."", getRootElement()) end addEventHandler("onColShapeHit", zona_portao, AbrePortao) function FechaPortao(jogador, na_dimensao) moveObject(portao_interior_1, 5000, 216.799, 1785.59, 12.10) moveObject(portao_interior_2, 5000, 211.199, 1785.59, 12.10) posX, posY, posZ = getElementPosition(portao_interior_1) outputChatBox("Local 2: "..posX.." | "..posY.." | "..posZ.."", getRootElement()) end addEventHandler("onColShapeLeave", zona_portao, FechaPortao) NOTE: in this code, later of movement the code takes only portao_interior_1 position (because I won't use this part of the code) And here, the part of .map with gates objects: <object id="portao_interior_1" doublesided="true" model="2951" interior="0" dimension="0" posX="216.80000305176" posY="1875.5999755859" posZ="12.10000038147" rotX="0" rotY="0" rotZ="0"></object> <object id="portao_interior_2" doublesided="true" model="2951" interior="0" dimension="0" posX="211.19999694824" posY="1875.5999755859" posZ="12.10000038147" rotX="0" rotY="0" rotZ="0"></object> Link to comment
Jaysds1 Posted December 5, 2011 Share Posted December 5, 2011 try this: https://wiki.multitheftauto.com/wiki/GetResourceMapRootElement Link to comment
Aibo Posted December 5, 2011 Share Posted December 5, 2011 eh, judging by the first script posted and a map file, you got your Y position wrong in script. map file: 1875.5999755859 script: 1785.59 you can drop 0.0099755859, no big deal, im talking about 90 units difference between 1785 and 1875. Link to comment
Stanley Sathler Posted December 5, 2011 Author Share Posted December 5, 2011 Shit Aibo, how you do this? O: Thank you so much, man. You're right, this script is working now. *_* I love you now, haha Thank you so much for all that tried help me too. Each detail posted here was important for my education. Link to comment
Aibo Posted December 5, 2011 Share Posted December 5, 2011 well i suggested that in my first post, because there is no way it would move on Y axis, unless the specified position is wrong. 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