setGarageOpen | Multi Theft Auto: Wiki Skip to content

setGarageOpen

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


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

Note

setGarageOpen does not work with ID 32 (Pay 'n' Spray near Royal Casino). This garage has been disabled by Rockstar Games due to floor collision issues (see TheJizzy's video "BETA Leftovers and Glitches" at 12:12 timestamp). You can remove the door by using removeWorldModel and recreating it for later with moveObject .

Syntax

setGarageOpen ( )

Code Examples

server

This example opens a garage door when a player enters a collision shape near it, and closes it when they leave:

local GARAGE_ID = 25
-- create a collision shape and attach event handlers to it when the resource starts
addEventHandler("onResourceStart", resourceRoot, function (resource)
local garageCube = createColCuboid(1337, 194, 28, 6, 10, 4)
addEventHandler("onColShapeHit", garageCube, onGarageCubeHit)
addEventHandler("onColShapeLeave", garageCube, onGarageCubeLeave)
end)
-- open the door when someone enters the garage's collision shape
function onGarageCubeHit(hitElement, matchingDimension)
if getElementType(hitElement) ~= "player" then
return
end
-- check to make sure the door is closed
-- open if they are closed
setGarageOpen(GARAGE_ID, not isGarageOpen(GARAGE_ID))
end
-- close the door when someone leaves the garage's collision shape
function onGarageCubeLeave(leaveElement, matchingDimension)
if getElementType(leaveElement) ~= "player" then
return
end
-- check to make sure the door is open
-- close if they are opened
setGarageOpen(GARAGE_ID, not isGarageOpen(GARAGE_ID))
end

See Also

World Functions