- Documentation
- Shared functions
- createColSphere
Function
createColSphere
Creates a sphere-shaped collision zone. The zone is invisible; when a player enters or leaves it, onColShapeHit / onColShapeLeave fire (server) or onClientColShapeHit / onClientColShapeLeave (client). A zone can be attached to an element (attachElements) so it moves with it.
Syntax
colshape createColSphere(float fX, float fY, float fZ, float fRadius)Arguments
fXfloat- Centre X.
fYfloat- Centre Y.
fZfloat- Centre Z.
fRadiusfloat- Radius in metres.
Returns
The new zone.
Example
local safeZone = createColSphere(2495, -1665, 13, 30)
addEventHandler("onColShapeHit", safeZone, function(hitElement, matchingDimension)
if getElementType(hitElement) == "player" and matchingDimension then
outputChatBox("Jestes w strefie bezpiecznej", hitElement, 0, 255, 0)
end
end)
Notes
On the server zones detect players (not peds or vehicles without a player).
See also
createColTubeCreates a cylinder-shaped collision zone: a circle of radiusradiusfrom heightzup byheightmetres.isInsideColShapeChecks whether a point (x, y, z) lies inside a zone. It does not need anyone standing in it - it computes the geometry only.onColShapeHitAn element entered a collision shape.