ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. createColSphere

Function

createColSphere

Server and clientCollision shapesIdentical to MTA:SA

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