Jump to content

Moving Gate


Kasem

Recommended Posts

hi , as the title says i have a question about Moving gate , i create a base with left and right gate , all what i need how to script to move both in the same time :

This for one gate :

Gate = createObject(986,586,-1906.099609375,3,0,0,355.74279785156) 
  
function gateOpen() 
moveObject(Gate,500,579.29998779297,-1905.5999755859,3) 
end 
addCommandHandler("open", gateOpen) 
  
function gateClose() 
moveObject(Gate,500,586,-1906.099609375,3) 
end 
addCommandHandler("close", gateClose) 

Screenchot :

mta_screen_2014_02_09_14_26_21.png

Link to comment
  • Moderators
local gateMoveTable = { 
    {    
        ["element"] =   createObject(986,586,-1906.099609375,3,0,0,355.74279785156), 
        ["open"]    =   {500,579.29998779297,-1905.5999755859,3}, 
        ["close"]   =   {500,586,-1906.099609375,3} 
    }--, 
    --[[{ -- gate 2 
        ["element"] =   createObject(), 
        ["open"]    =   {}, 
        ["close"]   =   {} 
    },]] 
    --[[{ -- gate 3 
        ["element"] =   createObject(), 
        ["open"]    =   {}, 
        ["close"]   =   {} 
    }]] 
     
} 
  
  
local manageGate = function (player,command) 
    for i=1,#gateMoveTable do 
        local gateTable = gateMoveTable[i] 
        moveObject(gateTable["element"],unpack(gateTable[command])) 
    end 
end 
addCommandHandler("open", manageGate) 
addCommandHandler("close", manageGate) 
  

and you can move much more gates at the same time with this.

By simply using a loop through the tables.

Link to comment

sorry i don't undrestand can u do it for me i need more experience in lua language :

coordonation :  
  
- Gate 1 : (986,586,-1906.099609375,3,0,0,355.74279785156) 
  
Open coodonation : (Gate,500,579.29998779297,-1905.5999755859,3) 
Close coodonation : (Gate,586,-1906.099609375,3) 
  
Gate 2 : (985,593.900390625,-1906.6999511719,3,0,0355.74279785156) 
  
Open coodonation : (Gate,500,600.70001220703,-1907.1999511719,3) 
Close coodonation : (Gate,593.900390625,-1906.6999511719,3) 

how to script it together ?? can u do it for me use coordonation and please give the Meta.xml

Link to comment

ok bro thx i will do it now :wink:

Edit : Ok correct or not

local gateMoveTable = { 
    {    
        ["element"] =   createObject(986,586,-1906.0999755859,3,0,0,355.74279785156), 
        ["open"]    =   {500,579.20001220703,-1905.5999755859,3}, 
        ["close"]   =   {500,586,-1906.0999755859,3}, 
    } 
    { 
        ["element"] =   createObject(985,593.90002441406,-1906.6999511719,3,0,0,355.74279785156), 
        ["open"]    =   {500,600.59997558594,-1907.1999511719,3}, 
        ["close"]   =   {500,593.90002441406,-1906.6999511719,3}, 
    } 
} 
  
  
local manageGate = function (player,command) 
    for i=1,#gateMoveTable do 
        local gateTable = gateMoveTable[i] 
        moveObject(gateTable["element"],unpack(gateTable[command])) 
    end 
end 
addCommandHandler("open", manageGate) 
addCommandHandler("close", manageGate) 

Error : Loading script failed: Death-race\gate.lua:7: '}' expected near '{'

Link to comment
  • Moderators

Almost :D

local gateMoveTable = { 
    {   
        ["element"] =   createObject(986,586,-1906.0999755859,3,0,0,355.74279785156), 
        ["open"]    =   {500,579.20001220703,-1905.5999755859,3}, 
        ["close"]   =   {500,586,-1906.0999755859,3}--,  last item doesn't need a , 
    }, --  you are missing a , 
    { 
        ["element"] =   createObject(985,593.90002441406,-1906.6999511719,3,0,0,355.74279785156), 
        ["open"]    =   {500,600.59997558594,-1907.1999511719,3}, 
        ["close"]   =   {500,593.90002441406,-1906.6999511719,3}--,  last item doesn't need a , 
    } 
} 
  

Link to comment

i think there is something wrong here :

  
marker = createMarker(576,-2031.5,5.4000000953674,"cylinder",255,0,0,255) 
  
function teleport(player) 
setElementPosition(player,576.099609375,-2035,5.4000000953674) 
end 
end 
end 
addEventHandler("onClientMarkerHit", getRootElement(), teleport)  
  

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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