SetColPolygonHeight

From Multi Theft Auto: Wiki
Revision as of 09:21, 15 February 2021 by Remaked (talk | contribs) (→‎Example)
Jump to navigation Jump to search

BETA: FROM VERSION 1.5.8 r20807 ONWARDS
This function is used to change the height of an existing colshape polygon. By default, a colshape polygon is infinitely tall.

Syntax

bool setColPolygonHeight( colshape shape, float floor, float ceil )  

OOP Syntax Help! I don't understand this!

Method: colshape:setHeight(...)

Required Arguments

  • shape: The colshape polygon
  • floor: The polygon floor (lowest Z coordinate). Parse false to reset this value to 0.
  • ceil: The polygon ceiling (highest Z coordinate). Parse false to reset this value to infinitely tall.

Returns

Returns true if the polygon was changed, false if invalid arguments were passed.

Example

This example sets every polygon colshape's max heigh to 50 units once resource starts.

Click to collapse [-]
Server side script
function setPolygonsHeight()
    for i, v in ipairs(getElementsByType("colshape")) do
        if (getColShapeType(v) == 4) then -- if it's a polygon colshape do it otherwise don't
            setColPolygonHeight(v, false, 50)
        end
    end
end
addEventHandler("onResourceStart", resourceRoot, setPolygonsHeight)

Requirements

Minimum supported server 1.5.8-9.20807
Minimum supported client 1.5.8-9.20807

Note: Using this function/event requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.5.8-9.20807" client="1.5.8-9.20807" />

See Also

BETA: FROM VERSION 1.5.8 r20807 ONWARDS
BETA: FROM VERSION 1.5.8 r20807 ONWARDS