SetObjectMaterialText

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 23:07, 30 October 2016
OstGot (Talk | contribs)

← Previous diff
Current revision
OstGot (Talk | contribs)

Line 30: Line 30:
} }
</pawn> </pawn>
 +
 +{{note2|You MUST use <b>ARGB</b> color format, not RGBA like used in client messages etc.}}
{{note|[[Colors_List#Inline_color_embedding|Color embedding]] can be used for multiple colors in the text.}} {{note|[[Colors_List#Inline_color_embedding|Color embedding]] can be used for multiple colors in the text.}}

Current revision



SetObjectMaterialText was added in SA-MP 0.3e This function was added in SA-MP 0.3e and will not work in earlier versions!


Description:

Replace the texture of an object with text.


Parameters:
(objectid, text[], materialindex = 0, materialsize = OBJECT_MATERIAL_SIZE_256x128, fontface[] = "Arial", fontsize = 24, bold = 1, fontcolor = 0xFFFFFFFF, backcolor = 0, textalignment = 0)
objectidThe ID of the object to replace the texture of with text.
textThe text to show on the object. (MAX 2048 characters)
materialindexThe object's material index to replace with text.
materialsizeThe size of the material.
fontfaceThe font to use.
fontsizeThe size of the text (MAX 255).
boldBold text. Set to 1 for bold, 0 for not.
fontcolorThe color of the text, in ARGB format.
backcolorThe background color, in ARGB format.
textalignmentThe alignment of the text (default: left).


Return Values:

  • 1: The function executed successfully.
  • 0: The function failed to execute.


Example Usage:

if (strcmp("/text", cmdtext, true) == 0)
{
    new objectid = CreateObject(19353, 0, 0, 10, 0.0, 0.0, 90.0); //create the object
    SetObjectMaterialText(objectid, "SA-MP {FFFFFF}0.3{008500}e {FF8200}RC7", 0, OBJECT_MATERIAL_SIZE_256x128,
    "Arial", 28, 0, 0xFFFF8200, 0xFF000000, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
    // write "SA-MP 0.3e RC7" on the object, with orange font color and black background
    return 1;
}
Image:32px-Circle-style-warning.png

Important
Note

You MUST use ARGB color format, not RGBA like used in client messages etc.


Image:32px-Ambox_warning_orange.png

Note

Color embedding can be used for multiple colors in the text.


Related Functions

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

  • SetObjectMaterial: Replace the texture of an object with the texture from another model in the game.

Filterscripts with texturing/text support

Personal tools
In other languages