OnClientColShapeHit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(13 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Client event}}
{{Client event}}
__NOTOC__
__NOTOC__
This event triggers whenever an element (a player, a vehicle...) enters a collision shape.
This event is triggered when a physical [[element]] hits a [[colshape]].
{{Note|The hit won't be detected if the [[element]] that entered the colshape is a colshape or projectile.}}


==Parameters==
==Parameters==
Line 7: Line 8:
element theElement, bool matchingDimension
element theElement, bool matchingDimension
</syntaxhighlight>
</syntaxhighlight>
*'''theElement:''' the element that entered the colshape.
*'''theElement:''' the [[element]] that entered the [[colshape]].
*'''matchingDimension:''' ''true'' if theElement is in the same dimension as the colshape, ''false'' otherwise.
*'''matchingDimension:''' a [[boolean]] referring to whether the hit collision shape was in the same [[dimension]] as the element.


==Source==
==Source==
Line 14: Line 15:


==Example==  
==Example==  
This example outputs "In." to the chatbox whenever a local user enters a collision shape.
This example outputs "In." to the chatbox whenever the local user enters a collision shape.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onClientColShapeHit( theElement, matchingDimension )
function onClientColShapeHit( theElement, matchingDimension )
     if ( theElement == getLocalPlayer() ) then  -- Checks whether the entering element is the local player
     if ( theElement == localPlayer ) then  -- Checks whether the entering element is the local player
         outputChatBox( "In." )  --Outputs.
         outputChatBox( "In." )  --Outputs.
     end
     end
end
end
addEventHandler("onClientColShapeHit",getRootElement(),onClientColShapeHit)
addEventHandler("onClientColShapeHit", root, onClientColShapeHit)
</syntaxhighlight>
</syntaxhighlight>
This example outputs to the chatbox if the local user is in the same dimension as the collision shape or not.
<syntaxhighlight lang="lua">
myZone = createColSphere (2490, -1668, 12.5, 25) -- Creates a collision sphere.
function dimensionChecker (theElement, matchingDimension)
    if matchingDimension then -- Checks whether the entering element is in the same dimension as the collision shape.
        outputChatBox ("The element is in the same dimension.")
    else
        outputChatBox ("The element is not in the same dimension.")
    end
end
addEventHandler ("onClientColShapeHit", myZone, dimensionChecker)
</syntaxhighlight>
[[pl:onClientColShapeHit]]


==See Also==
==See Also==

Latest revision as of 06:33, 24 June 2019

This event is triggered when a physical element hits a colshape.

[[{{{image}}}|link=|]] Note: The hit won't be detected if the element that entered the colshape is a colshape or projectile.

Parameters

element theElement, bool matchingDimension
  • theElement: the element that entered the colshape.
  • matchingDimension: a boolean referring to whether the hit collision shape was in the same dimension as the element.

Source

The source of this event is the colshape that was hit.

Example

This example outputs "In." to the chatbox whenever the local user enters a collision shape.

function onClientColShapeHit( theElement, matchingDimension )
    if ( theElement == localPlayer ) then  -- Checks whether the entering element is the local player
        outputChatBox( "In." )  --Outputs.
    end
end
addEventHandler("onClientColShapeHit", root, onClientColShapeHit)

This example outputs to the chatbox if the local user is in the same dimension as the collision shape or not.

myZone = createColSphere (2490, -1668, 12.5, 25) -- Creates a collision sphere.

function dimensionChecker (theElement, matchingDimension)
    if matchingDimension then -- Checks whether the entering element is in the same dimension as the collision shape.
        outputChatBox ("The element is in the same dimension.")
    else
        outputChatBox ("The element is not in the same dimension.")
    end
end
addEventHandler ("onClientColShapeHit", myZone, dimensionChecker)

See Also

Client colshape events


Client event functions