Jump to content

MTA Gate auto-open ! Help me please !


xSet

Recommended Posts

  • Moderators
settings = {
	objectID = GATEOBJECTID, -- fill up data
	closedPos = {x,z,y, rx,rz,ry}, -- fill up datas
	openedPos = {x,z,y, rx,rz,ry}, -- fill up datas
	
    duration = 2000, -- 2 sec (moving 2 sec)
    openedDuration = 5000, -- 5 sec (close after 5 sec)
    
    openRadius = 5,
	
	openInfo = "gate opened",
	closeInfo = "gate closed",
	
	opened = false, -- dont edit this
}

settings.gateObject = createObject(settings.objectID, settings.closedPos[1],settings.closedPos[2],settings.closedPos[3],settings.closedPos[4],settings.closedPos[5],settings.closedPos[6])
settings.openCol = createColSphere(settings.closedPos[1],settings.closedPos[2],settings.closedPos[3],settings.openRadius)

function gate()
	if not settings.opened then
		moveObject(settings.gateObject, settings.duration, settings.openedPos[1],settings.openedPos[2],settings.openedPos[3],settings.openedPos[4],settings.openedPos[5],settings.openedPos[6])
		outputChatBox(settings.openInfo, getRootElement())
	else
		moveObject(settings.gateObject, settings.duration, settings.closedPos[1],settings.closedPos[2],settings.closedPos[3],settings.closedPos[4],settings.closedPos[5],settings.closedPos[6])
		outputChatBox(settings.closeInfo, getRootElement())
	end
	settings.opened = not settings.opened
end

addEventHandler("onColShapeHit", settings.openCol, function() if not settings.opened then gate() setTimer(gate, settings.openedDuration, 1) end end)

 

Edited by gpetersz
  • Like 1
Link to comment
Quote

Any good scripter that can help with making a autoopenning gate?

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)

:shock:

You need create a files with meta.xml and gate.lua, and put in meta.xml <script src="gates.lua" type="server"></script>

Edited by ~DeV~
  • Like 1
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...