SetColPolygonHeight: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Fixed MTA version, example, added more explanation to function and the parameters)
(Remove obsolete Requirements section)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Server client function}}
{{Server client function}}
__NOTOC__
__NOTOC__
{{New feature/item|3.0160|1.5.8|20807|This function is used to change the height of an existing [[createColPolygon|colshape polygon]].
{{Added feature/item|1.5.9|1.5.8|20807|This function is used to change the height of an existing [[createColPolygon|colshape polygon]].
By default, a colshape polygon is infinitely tall.}}
By default, a colshape polygon is infinitely tall.}}


Line 11: Line 11:


===Required Arguments===  
===Required Arguments===  
*'''shape:''' The [[colshape]] polygon
*'''shape:''' The [[colshape]] polygon.
*'''floor:''' The polygon floor (lowest Z coordinate). Parse ''false'' to reset this value to 0.
*'''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.
*'''ceil:''' The polygon ceiling (highest Z coordinate). Parse ''false'' to reset this value to infinitely tall.
Line 19: Line 19:


==Example==
==Example==
{{Needs_Example}}
This example sets every polygon colshape's max heigh to 50 units once resource starts.
 
<section name="Server" class="server" show="true">
==Requirements==
<syntaxhighlight lang="lua">
{{Requirements|1.5.8-9.20807|1.5.8-9.20807|}}
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)
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Collision_shape_functions}}
{{Collision_shape_functions}}

Latest revision as of 17:25, 7 November 2024

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
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)

See Also