From GT-MP
Jump to: navigation, search
Client-Side Function
System-users.png Client-Side Javascript.png JavaScript

Draws the text on the screen this frame. You should call this during onUpdate.

Dialog-warning.png NOTE: At the moment a maximum of 99 chars can be displayed. This limit will be raised to 395 in version 0.1.7.


API.drawText(string caption, double xPos, double yPos, double scale, int r, int g, int b, int alpha, int font, int justify, bool shadow, bool outline, int wordWrap);

Required Arguments

  • caption: the text that should be drawn. Of string type.
  • xPos: the horizontal position of the text. Of double type.
  • yPos: the vertical position of the text. Of double type.
  • scale: the scale (or size) multiplier of the text. Of double type.
  • r: The red color option. 0-255. Of int type.
  • g: The green color option. 0-255. Of int type.
  • b: The blue color option. 0-255. Of int type.
  • alpha: The alpha (transparency) option. 0-255. Of int type.
  • font: The index of the font. Of int type. See Fonts for a list.
  • justify: The justification of the text. 0 - text starts from the left. 1 - text is centered. 2 - text starts from the right. Of int type.
  • shadow: Whether the text should have a shadow. Of bool type.
  • outline: Whether an outline should be drawn around the text. Of bool type.
  • wordWrap: The word wrap length of the text. Of int type.

Font Types/IDs

Click to see the full image

Usage example(s)

var screen = API.getScreenResolutionMaintainRatio(); // Gets client's resolution.
var posX = screen.Width / 2; // Centered horizontal position.
var posY = screen.Height / 2; // Centered vertical position.

API.onUpdate.connect( // Rendering event.
    function () {
        API.drawText("Example Text", posX, posY, 1, 255, 255, 255, 255, 6, 1, true, true, 200); // Drawing the text!!