- Documentation
- Collision shapes
Category
Collision shapes
All Lua functions and events in the Collision shapes category, on the server and the client.
Server functions 10
addAdds a vertex to a polygon zone. WithoutCol Polygon Point indexat the end, withindex- at that position in the list (from 1). The detection area changes immediately.getReturns the polygon zone height range set withCol Polygon Height setColPolygonHeight.getReturns the position of one vertex of a polygon zone (numbered from 1).Col Polygon Point Position getReturns all vertices of a polygon zone as a table ofCol Polygon Points {x, y}pairs.getReturns the radius of a sphere, circle or tube zone.Col Shape Radius getReturns the zone's dimensions depending on its shape: sphere/circle - radius; tube - radius and height; rectangle - width and length; cuboid - width, depth, height; polygon - height.Col Shape Size removeRemoves a vertex of a polygon zone (numbered from 1). The zone must keep at least three vertices.Col Polygon Point setMoves a vertex of a polygon zone; the detection area changes immediately.Col Polygon Point Position setChanges the radius of a sphere, circle or tube zone (negative = 0).Col Shape Radius setChanges the zone's dimensions (not polygons); the numbers mean the same as inCol Shape Size getColShapeSize.
Client functions 3
createCreates a client box zone centred at (x, y, z), rotated around the vertical axis - more convenient thanCol Box createColCuboidwhen a building stands at an angle.createCreates a client cube zone centred at (x, y, z) with the given side length.Col Cube getReturns all collision zones created by scripts on this client.Col Shapes
Shared functions 10
createCreates a circle-shaped collision zone on the map - with no height limit (it covers everything above and below the circle).Col Circle createCreates a box-shaped collision zone from the corner (x, y, z): width along X, depth along Y and height upward.Col Cuboid createCreates 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;Col Polygon setColPolygonHeightsets a range.createCreates a rectangular collision zone from the corner (x, y) - with no height limit. The size is given in metres along X and Y.Col Rectangle createCreates a sphere-shaped collision zone. The zone is invisible; when a player enters or leaves it,Col Sphere onColShapeHit/onColShapeLeavefire (server) oronClientColShapeHit/onClientColShapeLeave(client). A zone can be attached to an element (attachElements) so it moves with it.createCreates a cylinder-shaped collision zone: a circle of radiusCol Tube radiusfrom heightzup byheightmetres.getConverts a colour codeColor From String "#RRGGBB"or"#RRGGBBAA"(the#is optional) or a short"#RGB"/"#RGBA"(with#) into r, g, b, a components. Without an alpha channel it returns a = 255.getReturns the collision zone type. On the client a number: 0 circle, 1 cuboid (alsoCol Shape Type createColBox/createColCube), 2 sphere, 3 rectangle, 4 polygon, 5 tube. On the server a name:"circle","cuboid","sphere","rectangle","polygon","tube".isChecks whether a point (x, y, z) lies inside a zone. It does not need anyone standing in it - it computes the geometry only.Inside Col Shape setLimits a polygon zone vertically: it detects only betweenCol Polygon Height floorandceilheights (e.g. one floor of a building).false, falseremoves the limit. The order of the numbers does not matter.
Server events 4
Client events 4
onAn element entered a client-created shape. Attach the handler to that shape or toClient Col Shape Hit root(the event does not pass through parents).onAn element left a client-created shape.Client Col Shape Leave onAn element entered a collision shape (the element-side version, on the client).Client Element Col Shape Hit onAn element left a collision shape (the element-side version, on the client).Client Element Col Shape Leave