SetElementCollidableWith: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{Client function}}
{{Client function}}
{{Needs Example}}
__NOTOC__  
__NOTOC__  
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.<br>
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.<br>
Line 27: Line 26:


function ghostmode_on()
function ghostmode_on()
local localPlayer = getLocalPlayer() -- Getting the Local Player
local v = getPedOccupiedVehicle(localPlayer) -- Get her's Vehicle ID
local v = getPedOccupiedVehicle(localPlayer) -- Get her's Vehicle ID
for index,vehicle in ipairs(getElementsByType("vehicle")) do --LOOP through all Vehicles
for index,vehicle in ipairs(getElementsByType("vehicle")) do --LOOP through all Vehicles
Line 39: Line 37:
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
{{Note|When you do not know what "addCommandHandler" is Check the Wiki Page.}}


==See Also==
==See Also==
{{Client element functions}}
{{Client element functions}}

Revision as of 07:46, 29 February 2012

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 ) 

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 v = getPedOccupiedVehicle(localPlayer) -- Get her's Vehicle ID
	for index,vehicle in ipairs(getElementsByType("vehicle")) do --LOOP through all Vehicles
		setElementCollidableWith(vehicle, v, false) -- Set the Collison off with the Other vehicles.
	end
	outputChatBox("You are now a Ghost :P",thePlayer)
end
addCommandHandler("ghostmode", ghostmode_on) -- Add the /ghostmode Command.


See Also