onColShapeHit
Client-side
Server-side
Shared
The hit won't be detected if the element that entered the colshape is a colshape.
Parameters
element hitElement, bool matchingDimension
- hitElement: 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
element: The source of this event is the colshape that got hit by a player or vehicle.
Code Examples
server
This example creates a hill area for aKing of the hillgamemode. When a player enters or leaves the area, it's announced in the chatbox.
-- create our hill area for our gamemodelocal hillArea = createColRectangle ( -2171.0678710938, 678.17950439453, 15, 15 )
-- add hill_Enter as a handler for when a player enters the hill areafunction hill_Enter ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --if the element that entered was player --let's get the name of the player local nameOfThePlayer = getPlayerName ( thePlayer ) --announce to everyone that the player entered the hill outputChatBox ( nameOfThePlayer.." entered the zone!", root, 255, 255, 109 ) endendaddEventHandler ( "onColShapeHit", hillArea, hill_Enter )
-- add hill_Enter as a handler for when a player leaves the hill areafunction hill_Exit ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --if the element that left was player --check if the player is not dead if isPlayerDead ( thePlayer ) ~= true then --let's get the name of the player local nameOfThePlayer = getPlayerName ( thePlayer ) --if he was alive, announce to everyone that the player has left the hill outputChatBox ( nameOfThePlayer.." left the zone!", root, 255, 255, 109 ) end endendaddEventHandler ( "onColShapeLeave", hillArea, hill_Exit )
See Also
Colshape Events
Colshape Functions
- createColCircle
- addColPolygonPoint
- createColCuboid
- createColPolygon
- createColRectangle
- createColSphere
- getColPolygonPointPosition
- createColTube
- getColPolygonPoints
- getColPolygonHeight
- getColShapeSize
- getColShapeRadius
- getColShapeType
- getElementColShape
- getElementsWithinColShape
- isElementWithinColShape
- isInsideColShape
- removeColPolygonPoint
- setColPolygonHeight
- setColPolygonPointPosition
- setColShapeRadius
- setColShapeSize