DxIsAspectRatioAdjustmentEnabled: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Add example)
(Add requirement)
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:


{{New feature/item|3.0140|1.3.3|5547|
{{New feature/item|3.0140|1.3.3|5547|
This function gets the current aspect ratio set by [[DxSetAspectRatioAdjustmentEnabled]].
This function gets the current aspect ratio set by [[dxSetAspectRatioAdjustmentEnabled]].
}}
}}


Line 12: Line 12:


===Returns===
===Returns===
*'''boolean:''' returns '''true''' when enabled by [[DxSetAspectRatioAdjustmentEnabled]], '''false''' otherwise.
*'''boolean:''' returns '''true''' when enabled by [[dxSetAspectRatioAdjustmentEnabled]], '''false''' otherwise.
*'''float:''' aspect ratio set by [[DxSetAspectRatioAdjustmentEnabled]]
*'''float:''' aspect ratio set by [[dxSetAspectRatioAdjustmentEnabled]]
 
==Requirements==
{{Requirements|n/a|1.3.3-9.05547}}


==Example==
==Example==
This example will draw the aspect ratio to screen if aspect ratio was set.
This example will draw the aspect ratio to screen if aspect ratio was enabled previously.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler("onClientRender", root, function()
addEventHandler("onClientRender", root, function()
    dxSetAspectRatioAdjustmentEnabled(true)
     local enabled, ratio = dxIsAspectRatioAdjustmentEnabled()
     local enabled, ratio = dxIsAspectRatioAdjustmentEnabled()

Latest revision as of 01:44, 13 December 2019

This function gets the current aspect ratio set by dxSetAspectRatioAdjustmentEnabled.

Syntax

bool, float dxIsAspectRatioAdjustmentEnabled ( )

Returns

Requirements

Minimum server version n/a
Minimum client version 1.3.3-9.05547

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.3.3-9.05547" />

Example

This example will draw the aspect ratio to screen if aspect ratio was enabled previously.

addEventHandler("onClientRender", root, function()
    dxSetAspectRatioAdjustmentEnabled(true)

    local enabled, ratio = dxIsAspectRatioAdjustmentEnabled()
	
    if(enabled) then
        dxDrawText("Aspect ratio is: " .. ratio, 250, 250)
    end
end)

See Also