Jump to content

Need help, creating a gate


Lopez4Life

Recommended Posts

So I just started coding basic LUA, I have no idea of how it actually works.

I've got the needed object models, coordinates for a gate I'm trying to make.

I want to make it so if I do the command /open the gate moves to certain position, and if I do /close it'll move to another certain position

I have the coordinates for both /open and /close positions as I said.

Thanks for the help guys.

Hope to get some replies.

Link to comment
  
gate = createObject ( 2951, -1868.5, -3104.1999511719, 54.700000762939, 0, 0, 318) -- Gate. 
function Open ( pla ) -- the function 
    if getElementType ( pla ) == "player" then -- if he is a player. 
        if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then -- it is only for admins. 
            moveObject (othergate1, 2500, -1868.5, -3104.1999511719, 56.900001525879) -- It will move the gate. 
         end -- Closing functions and all... 
    end 
end   
addEventHandler ( "onColShapeHit", col, Open) -- Adding a event handler. 
addCommandHandler ( "open",Open) -- Adding the command. 
  
function Close ( pla ) -- Function 
    if getElementType ( pla ) == "player" then -- as i said for checking if its a player. 
        if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then -- for admins only./ 
            moveObject (othergate1, 2500,-1868.5, -3104.1999511719, 54.700000762939) -- close the gate. 
end 
end  
end 
addEventHandler ( "onColShapeLeave", col, Close ) 
addCommandHandler ("close", Close) 
  
  

gate = createObject ( 2951, y, x, z) to get the x,y,z go to freeroam and where you want to put do /getpos and replace it with it.

Link to comment

So I just modified that code to make it work the way I want it

I compiled it, got the LUAC file, what next?

  
gate = createObject ( 980, -805.59997558594, 2379.6000976563, 155, 0, 0, 318) -- Gate. 
function Open ( pla ) -- the function 
    if getElementType ( pla ) == "player" then -- if he is a player. 
        if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "legend" ) ) then -- it is only for admins. 
            moveObject (gate, 2500, -805.59997558594, 2379.6000976563, 148) -- It will move the gate. 
         end -- Closing functions and all... 
    end 
end   
addEventHandler ( "onColShapeHit", col, Open) -- Adding a event handler. 
addCommandHandler ( "open",Open) -- Adding the command. 
  
function Close ( pla ) -- Function 
    if getElementType ( pla ) == "player" then -- as i said for checking if its a player. 
        if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "legend" ) ) then -- for admins only./ 
            moveObject (gate, 2500,-805.59997558594, 2379.6000976563, 155) -- close the gate. 
end 
end 
end 
addEventHandler ( "onColShapeLeave", col, Close ) 
addCommandHandler ("close", Close) 
  

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