Jump to content

How to make autogate auto open?


Siu

Recommended Posts

Creat gates first, then use markers or cuboid with on hit function move gate to xyz positions for open gate and for close the gate use on leave function see below code

Code

local time = 4000  -- time for the gate open and close
local gate = createObject(0, 0, 0, 0, 0, 0, 0) --(object id, x, y, z, rx, ry, rz)
local marker = createMarker(0, 0, 0, "cylinder", 13, 255, 0, 0, 0) --(x, y, z,

function moveGate(hitPlayer, matchingDimension)
	moveObject(gate, time, 0, 0, 0, 0, 0, 0) --(position when the gate is open (gate, time, x, y, z, rx, ry, rz)
end
addEventHandler("onMarkerHit", marker, moveGate)

function moveBack()
  moveObject(gate, time, 0, 0, 0, 0, 0, 0) --(position when the gate is close same of "local gate = createObject..." but just(x, y, z, rx, ry, rz) not put id
end
addEventHandler("onMarkerLeave", marker, moveBack)

-- for work with commands put addCommandHandler("open", moveGate) and addCommandHandler("close", moveBack)

 

You can make this without commands also use created cuboid function and remove commandhandler function 

Like this :

Code : 

 gate = createObject( 971, 2334.8000488281, 2444.1000976563, 8.3000001907349, 0, 0, 58 ) --Object ID (Airport Gate=978) & Co-Ordinates of your gates start of position. 
   gatecol = createColCircle ( 2334.8000488281, 2444.1000976563, 15 ) --Co-Ordinates "X" and "Y" and the radius, I use 15 as default. 
  
function openagates(thePlayer) 
        if getElementModel( thePlayer ) == 267 then --Will open only if the player is in the male staff skin 
        moveObject ( gate, 3000, 2334.8000488281, 2444.1000976563, 0 ) --The speed in which 7000 is slow and 2000 is fast to open, Co-Ordinates for the gate to move to. 
        end 
end 
addEventHandler( "onColShapeHit", gatecol, openagates ) --Event Handler to trigger the function 
  
function closegates (thePlayer) 
    moveObject ( gate, 971, 2334.8000488281, 2444.1000976563, 8.3000001907349, 0, 0, 58) 
end 
addEventHandler ( "onColShapeLeave", root, closegates ) 

 

Edited by Khadeer143
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...