HU/dxGetTextWidth: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function hu}} This function retrieves the theoretical width of a certain piece of text, if it were to be drawn using dxDrawText. '''NOTE:''' This fun...")
 
Line 37: Line 37:


==Lásd még==
==Lásd még==
{{Drawing_functions}}
{{Drawing_functions hu}}


[[en:dxGetTextWidth]]
[[en:dxGetTextWidth]]

Revision as of 12:59, 28 November 2018

This function retrieves the theoretical width of a certain piece of text, if it were to be drawn using dxDrawText.

NOTE: This function is relative to the client's screen resolution.

Szintaxis

float dxGetTextWidth ( string text, [float scale=1, mixed font="default", bool bColorCoded=false] )

OOP Syntax Help! I don't understand this!

Note: This syntax requires you to ignore the font argument above
Method: font:getTextWidth(...)

Kötelező paraméterek

  • text: A string representing the text for which you wish to retrieve with width for.

Tetszőleges paraméterek

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.

  • scale: The size of the text.
  • font: Either a custom DX font element or the name of a built-in dx font:
    • "default": Tahoma
    • "default-bold": Tahoma Bold
    • "clear": Verdana
    • "arial": Arial
    • "sans": Microsoft Sans Serif
    • "pricedown": Pricedown (GTA's theme text)
    • "bankgothic": Bank Gothic Medium
    • "diploma": Diploma Regular
    • "beckett": Beckett Regular
    • "unifont": Unifont
  • bColorCoded: Should we exclude color codes from the width? (false will include the hex in the length)

Visszatérési éték

Returns the float of the width of the text.

Példa

Click to collapse [-]
Example

This will show you the width of a message in a normal chatbox sent by a player

function dxwidth(msg)
    chatbox = getChatboxLayout()
    local length = dxGetTextWidth(msg,chatbox["chat_scale"][1])
    outputChatBox(tostring(length))
end
addEventHandler("onClientChatMessage",root,dxwidth)

Lásd még