GetGarageBoundingBox: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Tip)
 
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{client function}}
{{client function}}
This function outputs the bounding box of a garage.  
This function outputs the bounding box of a garage.
 
{{Tip|You can use the useful function [[CreateGarageColShape]] to create the garage colshape.}}
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">

Latest revision as of 00:56, 7 March 2023

This function outputs the bounding box of a garage.

[[{{{image}}}|link=|]] Tip: You can use the useful function CreateGarageColShape to create the garage colshape.

Syntax

float, float, float, float getGarageBoundingBox ( int garageID )

Required Arguments

  • garageID: The garage ID that represents the garage door that is being checked.

Returns

Returns four floats indicating the bounding box of the garage. Western X position, Eastern X position, Southern Y position, Northern Y position,, false when invalid garageID was provided.

Example

Click to collapse [-]
Client

Checks if the player is inside the bounding box of the garage and outputs the result to the chat

function garageCheck ( command, garageID )
	if not garageID then
		return
	end
	
	local west, east, south, north = getGarageBoundingBox ( garageID ) --get the bounding box of the specified garage
	local x, y, z = getElementPosition ( getLocalPlayer ( ) ) --get the position of the player
	
	if x > west and x < east and y > south and y < north then --check if the player is inside the bounding box
		outputChatBox ( "You are inside the garage" )
	else
		outputChatBox ( "You are outside the garage" )
	end
end

addCommandHandler ( "garagecheck", garageCheck )

See Also