SetGarageOpen

From Multi Theft Auto: Wiki
Revision as of 08:33, 18 September 2008 by Erorr404 (talk | contribs)
Jump to navigation Jump to search

This function opens or closes the specified garage door in the world.

Syntax

void setGarageOpen ( int garageID, bool open )

Required Arguments

  • garageID: The ID that represents the garage door being opened or closed.
  • isOpen: A boolean indicating whether or not to open the door.

Returns

This function does not return anything.

Example

Click to collapse [-]
Server

This example opens a garage door when a player enters a collision shape near it:

GARAGE_ID = 25

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),
function (resource)
	local colCube = createColCuve(1337, 194, 28, 6, 10, 4)
	addEventHandler("onColShapeHit", colCube, onGarageCubeHit)
	addEventHandler("onColShapeLeave", colCube, onGarageCubeLeave)
end

function onGarageCubeHit(hitElement, matchingDimension)
	if (getElementType(hitElement) == "player") then
		if (not isGarageOpen(GARAGE_ID)) then
			setGarageOpen(GARAGE_ID, true)
		end
	end
end

function onGarageCubeLeave(leaveElement, matchingDimension)
	if (getElementType(leaveElement) == "player") then
		if (isGarageOpen(GARAGE_ID)) then
			setGarageOpen(GARAGE_ID, false)
		end
	end
end

See Also

Template:World shape functions