DxSetAspectRatioAdjustmentEnabled

From Multi Theft Auto: Wiki
Revision as of 20:45, 26 June 2013 by Ccw (talk | contribs)
Jump to navigation Jump to search

This function is used to aligning the output of dxDraw calls with GTA HUD components. It can only be called during these events: onClientRender, onClientPreRender and onClientHUDRender, and is automatically disabled when these events return. So the function has to be called every frame, just like dxDraws.

Syntax

bool dxSetAspectRatioAdjustmentEnabled ( bool bEnabled [, float sourceRatio = 4/3 ] )

Required Arguments

  • bEnabled: Should the adjustment be enabled or disabled.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • sourceRatio : This should be set to the aspect ratio the dxDraw were originally designed in.

Returns

Returns true when it was changed successfully, or false otherwise.

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

scx,scy = guiGetScreenSize()

addEventHandler( "onClientRender", root,
    function()
        dxDrawText( "Hello", 300, 300 )             -- Text will be drawn at 300,300
        dxSetAspectRatioAdjustmentEnabled( true )
        dxDrawText( "Goodbye", 0.78*scx, 0.22*scy )  -- Text will be drawn just below HUD money, with any aspect ratio
    end
)

See Also