- Documentation
- Shared functions
- createColPolygon
Function
createColPolygon
Creates a collision zone shaped as any polygon on the map (e.g. a gang territory outline). The first two numbers are the centre point (element position), then x, y pairs of vertices - at least three. No height limit by default; setColPolygonHeight sets a range.
Syntax
colshape createColPolygon(float fCenterX, float fCenterY, float fX1, float fY1, float fX2, float fY2, float fX3, float fY3 [, float ...])Arguments
fCenterXfloat- Centre point X.
fCenterYfloat- Centre point Y.
fX1float- First vertex X.
fY1float- First vertex Y.
fX2float- Second vertex X.
fY2float- Second vertex Y.
fX3float- Third vertex X.
fY3float- Third vertex Y.
...float, optional- More x, y pairs.
Returns
The new zone, or false with fewer than 3 vertices.
Example
local grove = createColPolygon(2490, -1665, 2430, -1720, 2540, -1720, 2540, -1620, 2430, -1620)
addEventHandler("onColShapeHit", grove, function(element)
if getElementType(element) == "player" then outputChatBox("Teren Grove Street Families", element) end
end)
See also
addColPolygonPointAdds a vertex to a polygon zone. Withoutindexat the end, withindex- at that position in the list (from 1). The detection area changes immediately.setColPolygonHeightLimits a polygon zone vertically: it detects only betweenfloorandceilheights (e.g. one floor of a building).false, falseremoves the limit. The order of the numbers does not matter.getColPolygonPointsReturns all vertices of a polygon zone as a table of{x, y}pairs.