Graphics::drawText: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(More technical details on text editing.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''In RageMP 0.3.2 RC-1 due to a bug, message parameter needs to be at least 16 characters long.'''
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.graphics.drawText(text, [x, y [, z]], { font, color, scale, outline, centre });</syntaxhighlight>
<pre>
mp.game.graphics.drawText(text, [x, y [, z]], { font, color, scale, outline, centre });
</pre>
 
=== Required Arguments ===
=== Required Arguments ===
*'''text:''' String: text to show
*'''text:''' String: structured text to show (utilizes [[Fonts_and_Colors]] and [https://en.wikipedia.org/wiki/Control_character Control Characters])
*'''x:''' Float: X position in the screen (0.0 to 1.0)
*'''x:''' Float: X position in the screen (0.0 to 1.0)
*'''y:''' Float: Y position in the screen (0.0 to 1.0)
*'''y:''' Float: Y position in the screen (0.0 to 1.0)
Line 11: Line 13:
*'''scale:''' Array ([x, y]): scale of the text (1.0 is a good value)
*'''scale:''' Array ([x, y]): scale of the text (1.0 is a good value)
*'''outline:''' Bool: Text has borders or not
*'''outline:''' Bool: Text has borders or not
===Return value===
===Return value===
Unknown
Unknown
==Example==
==Example==
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
{{ClientsideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<pre>
<syntaxhighlight lang="javascript">
mp.events.add('render', () => {
mp.events.add('render', () => {
     // Draw to screen.
     // Draw to screen.
Line 32: Line 35:
       scale: [1.2, 1.2],  
       scale: [1.2, 1.2],  
       outline: true,
       outline: true,
       centre: trye
       centre: true
    });
 
    // Draw to screen using red color on a next line.
    mp.game.graphics.drawText("Text at the top of the screen\n~r~Next line in red color", [0.5, 0.005], {
      font: 7,
      color: [255, 255, 255, 185],
      scale: [1.2, 1.2],
      outline: true
     });
     });
});
});
</syntaxhighlight>
</pre>
</div>
}}


==Fonts==
==Fonts==
<span style="font-size:130%; line-height: 1.31em;">'''ChaletLondon - ID: 0'''</span>
<span style="font-size:130%; line-height: 1.31em;">'''ChaletLondon - ID: 0'''</span>
<gallery>
<gallery>

Latest revision as of 20:33, 22 August 2020

Syntax

mp.game.graphics.drawText(text, [x, y [, z]], { font, color, scale, outline, centre });

Required Arguments

  • text: String: structured text to show (utilizes Fonts_and_Colors and Control Characters)
  • x: Float: X position in the screen (0.0 to 1.0)
  • y: Float: Y position in the screen (0.0 to 1.0)
  • z: Float: Include Z parameter when rendering to a 3D space (change X and Y to world co-ordinates)
  • font: Int: font id
  • color: Array: Color of the text plus alpha
  • scale: Array ([x, y]): scale of the text (1.0 is a good value)
  • outline: Bool: Text has borders or not

Return value

Unknown

Example

Client-Side
mp.events.add('render', () => {
    // Draw to screen.
    mp.game.graphics.drawText("Text at the top of the screen", [0.5, 0.005], { 
      font: 7, 
      color: [255, 255, 255, 185], 
      scale: [1.2, 1.2], 
      outline: true
    });

    // Draw to world.
    mp.game.graphics.drawText("Text in the world", [-1234, 1337, 15], { 
      font: 7, 
      color: [255, 255, 255, 185], 
      scale: [1.2, 1.2], 
      outline: true,
      centre: true
    });

    // Draw to screen using red color on a next line.
    mp.game.graphics.drawText("Text at the top of the screen\n~r~Next line in red color", [0.5, 0.005], { 
      font: 7, 
      color: [255, 255, 255, 185], 
      scale: [1.2, 1.2], 
      outline: true
    });
});

Fonts

ChaletLondon - ID: 0



HouseScript - ID: 1



Monospace - ID: 2



CharletComprimeColonge - ID: 4



Pricedown - ID: 7

See also