natives.setTextColour
Function Client Only ![]()
Online and Offline
Available since Client 1.0.0
void natives.setTextColour(int r, int g, int b, int a)
The natives.setTextColour function is used to Sets the RGBA colour and opacity of text drawn on the screen.
Parameters
| 1) | int | r | Red component (0–255). |
| 2) | int | g | Green component (0–255). |
| 3) | int | b | Blue component (0–255). |
| 4) | int | a | Alpha component (0–255), controls opacity (0 = fully transparent, 255 = fully opaque). |
Return
| void | This function doesn't return a value. |
Notes
- - Must be called before natives.displayTextWithLiteralString or similar text drawing functions- The alpha channel defines transparency: 0 invisible, 255 fully visible- Combine with natives.setTextScale and natives.setTextFont for complete styling.
Examples
Example 1 - JavaScript:
addEventHandler("OnDrawnHUD", function() {
// White text with 80% opacity natives.setTextScale(0.30, 0.30); natives.setTextFont(0); natives.setTextColour(255, 255, 255, 200);
natives.displayTextWithLiteralString(new Vec2(0.05, 0.10), "STRING", "Text with opacity 200/255");
});
Compatibility
There isn't any compatibility information for this function.