TextDrawCreate

From SA-MP Wiki

Jump to: navigation, search


Creates a textdraw.


Parameters:
(Float:x, Float:y, text[])
xX-Coordinate
yY-Coordinate
text[]The text in the textdraw.


ReturnsThe ID of the created textdraw


// This variable is used to store the id of the textdraw
// so that we can use it throught the script
new Text:welcomeText; 
 
public OnGameModeInit()
{
    // This line is used to create the textdraw. 
    // Note: This creates a textdraw without any formatting.
    welcomeText = TextDrawCreate(240.0,580.0,"Welcome to my SA-MP server");
    return 1;
}
 
public OnPlayerConnect(playerid)
{
    //This is used to show the player the textdraw when they connect.
    TextDrawShowForPlayer(playerid,welcomeText);
}


Image:32px-Circle-style-warning.png Important Notes:
  • Maximum length of textdraw is 800 characters. Longer text will crash the client.
  • If you use color codes (such as ~R~ ~G~) beyond 255th character the client will crash trying to display the textdraw.
  • If you choose values for y that are less than 1, the first text row will be invisible and only the shadow is visible.
  • text[] must NOT be empty or the server will crash! If you need a textdraw that shows nothing, use " " (a space) or _ (underscore)
  • If the last character in the text is a space (" "), the text will all be blank.
  • If part of the text is off-screen, the colour of the text will not show, only the shadow (if enabled) will.


Image:32px-Ambox_warning_orange.png Notes:
  • The x,y coordinate is the top left coordinate for the text draw area based on a 640x480 "canvas" (irrespective of screen resolution). If you plan on using TextDrawAlignment with alignment 3 (right), the x,y coordinate is the top right coordinate for the text draw.
  • This function merely CREATES the textdraw, you must use TextDrawShowForPlayer to show it.


Related Functions

The following functions may be useful, as they are related to this function in one way or another.


Personal tools