SetElementCollidableWith

From Multi Theft Auto: Wiki
Revision as of 17:06, 4 November 2019 by Xerox8521 (talk | contribs) (→‎Example)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This function can be used to set an element to collide with another element. An element with collisions disabled does not interact physically with the other element.
Note: You can only use this function with the element types listed below.

Syntax

bool setElementCollidableWith ( element theElement, element withElement, bool enabled ) 

OOP Syntax Help! I don't understand this!

Method: element:setCollidableWith(...)
Counterpart: isElementCollidableWith


Required Arguments

  • theElement: The element which colliding you want to change
  • withElement: The other element you wish the first entity to collide with
  • enabled: A boolean to indicate whether elements should be able to collide with eachother (true) or not (false)

Returns

Returns true if the collisions were set succesfully, false otherwise.

Example

Click to collapse [-]
Client
function ghostmode_on()
	local playerVehicle = getPedOccupiedVehicle(localPlayer) -- Get the players vehicle
	if(playerVehicle) then -- Check the return value.
		for i,v in pairs(getElementsByType("vehicle")) do --LOOP through all vehicles
			setElementCollidableWith(v, playerVehicle, false) -- Set the collison off with the other vehicles.
		end
		outputChatBox("You are now a Ghost")
	end
end
addCommandHandler("ghostmode", ghostmode_on) -- Add the /ghostmode Command.

See Also