Graphics::drawText: Difference between revisions

From RAGE Multiplayer Wiki
(Updated drawText With The Proper Parameters)
Line 1: Line 1:
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.graphics.drawText(text, fontId, colourRGBA, scaleX, scaleY, outline, x, y[, z]);</syntaxhighlight>
<syntaxhighlight lang="javascript">mp.game.graphics.drawText(text, [x, y [, z]], { font, color, scale, outline });</syntaxhighlight>
=== Required Arguments ===
=== Required Arguments ===
*'''text:''' String: text to show
*'''text:''' String: text to show
*'''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)
*'''fontId:''' Int: font id
*'''fontId:''' Int: font id
*'''colourRGBA:''' Array: Color of the text plus alpha
*'''colourRGBA:''' Array: Color of the text plus alpha
Line 8: Line 11:
*'''scaleY:''' Float: Y scale (1.0 is a good value)
*'''scaleY:''' Float: Y scale (1.0 is a good value)
*'''outline:''' Bool: Text has borders or not
*'''outline:''' Bool: Text has borders or not
*'''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)
===Return value===
===Return value===
Unknown
Unknown
Line 19: Line 19:
mp.events.add('render', () => {
mp.events.add('render', () => {
     // Draw to screen.
     // Draw to screen.
     mp.game.graphics.drawText("Text at the top of the screen", 7, [255, 255, 255, 185], 1.2, 1.2, true, 0.5, 0.005);
     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.
     // Draw to world.
     mp.game.graphics.drawText("Text in the world", 7, [255, 255, 255, 185], 1.2, 1.2, true, -1234, 1337, 15);
     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
    });
});
});
</syntaxhighlight>
</syntaxhighlight>

Revision as of 02:48, 12 December 2017

Syntax

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

Required Arguments

  • text: String: text to show
  • 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)
  • fontId: Int: font id
  • colourRGBA: Array: Color of the text plus alpha
  • scaleX: Float: X scale of the text (1.0 is a good value)
  • scaleY: Float: Y scale (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
    });
});

Fonts

ChaletLondon - ID: 0



HouseScript - ID: 1



Monospace - ID: 2



CharletComprimeColonge - ID: 4



Pricedown - ID: 7

See also