Skip to content

Commit a723b93

Browse files
committed
Working with Text chapter
1 parent a46f360 commit a723b93

File tree

12 files changed

+158
-0
lines changed

12 files changed

+158
-0
lines changed

astro.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ export default defineConfig({
9292
{ label: 'Negating Conditions', slug: 'negating-conditions' },
9393
{ label: 'Multiple Conditions', slug: 'multiple-conditions' },
9494
],
95+
},
96+
{
97+
label: "Chapter IV: Working with Text",
98+
items: [
99+
{label: 'Text Types', slug: 'text-types'},
100+
{label: 'Basic Messages', slug: 'basic-messages'},
101+
{label: 'Formatted Messages', slug: 'formatted-messages'},
102+
{label: 'Text Draws', slug: 'text-draws'},
103+
{label: 'Debug Messages', slug: 'debug-messages'},
104+
105+
]
95106
}
96107
],
97108
}),

public/img/ch-04-01.png

2.8 MB
Loading

public/img/ch-04-02.png

3.44 MB
Loading

public/img/ch-04-03.png

2.63 MB
Loading

public/img/ch-04-04.png

1.82 MB
Loading

public/img/ch-04-05.png

2.69 MB
Loading

public/img/ch-04-06.png

2.06 MB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Text Types
3+
description: Displaying text messages on the screen
4+
slug: text-types
5+
---
6+
7+
Text messages play an important role in many scripts. They can appear as part of the user interface, for example, in menus, or serve as subtitles, gameplay instructions, or debugging information.
8+
9+
The game provides several built-in methods for displaying text on screen:
10+
11+
- [Help box](/basic-messages#help-boxes) – a small black rectangle in the top-left corner, often used to provide contextual help
12+
13+
- [Mission text](/basic-messages#mission-text) – large, centered, or bottom-screen text, typically used for mission objectives or subtitles.
14+
15+
- [Text Draw](/text-draws) – short text elements displayed at specific coordinates, commonly used for showing information such as player position or debug values.
16+
17+
CLEO 5 introduces an additional display type: the yellow [trace message](/debug-messages), shown on the left side of the screen. It is especially useful for debugging and logging script behavior.
18+
19+
Most text messages remain visible for a fixed duration — from a single frame to several seconds — though they can also be shown repeatedly in a loop to stay visible longer.
20+
21+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: Basic Messages
3+
description: Showing different types of messages
4+
slug: basic-messages
5+
tableOfContents: true
6+
---
7+
8+
## Help Boxes
9+
10+
In the base game, text commands require a GXT key - an 8-character string referencing one of the predefined text entries in the active GXT file (for example, `american.gxt` when the game language is set to English).
11+
12+
For example, to display a help box with the text 'San Andreas', you need to use the command `PRINT_HELP` with the key `'SAN_AND'`:
13+
14+
```sb
15+
PRINT_HELP {key} 'SAN_AND'
16+
```
17+
18+
<img src="/img/ch-04-01.png" alt="Help box example" />
19+
20+
:::tip
21+
How one could find what key refers to what text? There is an online tool
22+
that lets you navigate all standard game messages and their keys:
23+
https://public.sannybuilder.com/GXT/search/?game=SA%20PC. It supports all
24+
available languages and can work with user-provided GXT files.
25+
:::
26+
27+
Sometimes you need custom text that doesn’t exist in the original GXT files. There are two easy ways to do this:
28+
29+
1. CLEO supports custom text dictionary format called `FXT`, which allows you to define new keys and messages without having to edit GXT files. FXT files are loaded automatically from the `CLEO_TEXT` folder.
30+
31+
Each FXT file contains a list of plain text entries in the following format:
32+
33+
```
34+
<KEY> <TEXT>
35+
```
36+
37+
2. Use CLEO commands that accept strings directly, without using a GXT key. For example, to display the same help box use:
38+
39+
```sb
40+
PRINT_HELP_STRING {text} "San Andreas"
41+
```
42+
43+
Notice that because the text is longer than 8 characters, you need to use double quotes.
44+
45+
## Mission Text
46+
47+
Here is some other message commands and their CLEO counterpart:
48+
49+
**PRINT_NOW**
50+
51+
| Native Command | CLEO Command |
52+
| ----------------------------------------------------- | ------------------------------------------------------- |
53+
| `PRINT_NOW {key} 'SAN_AND' {duration} 3000 {style} 1` | `PRINT_STRING_NOW {text} "San Andreas" {duration} 3000` |
54+
55+
<img src="/img/ch-04-02.png" alt="PRINT_NOW Example" />
56+
57+
**PRINT_BIG**
58+
59+
| Native Command | CLEO Command |
60+
| ----------------------------------------------------- | ----------------------------------------------------------------- |
61+
| `PRINT_BIG {key} 'SAN_AND' {duration} 3000 {style} 1` | `PRINT_BIG_STRING {text} "San Andreas" {duration} 3000 {style} 1` |
62+
63+
<img src="/img/ch-04-03.png" alt="PRINT_BIG Example" />
64+
65+
To find more information about each command and different styles, visit [the Text class](https://library.sannybuilder.com/#/sa/script/classes/Text) in Sanny Builder Library.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: Formatted Messages
3+
description: Showing different types of formatting
4+
slug: formatted-messages
5+
tableOfContents: true
6+
---
7+
8+
## Native Formatting
9+
10+
The game allows the use of special tokens to highlight different parts of text. They usually appear like a specific character surrounded by `~`, e.g. `~b~` or `~y~`. [This page](https://gtamods.com/wiki/GXT#Symbols_and_colors) describes each token in detail.
11+
12+
For example, the GXT key `STOCK` references the message `~r~out of stock` (`~r~` means red), which in the game looks like this:
13+
14+
```sb
15+
PRINT_HELP {key} 'STOCK'
16+
```
17+
18+
<img src="/img/ch-04-04.png" alt="Help box with red text" />
19+
20+
Some messages include placeholders for numbers, represented as ~1~. Regardless of their position and total number of placeholders, the token is always ~1~.
21+
22+
For example, the message displayed when you pick up a horseshoe is `Horseshoes ~1~ out of ~1~`, referenced by the key HO_ONE. To display it in the game, use one of the commands that include `WITH_NUMBER` in it. For two numbers, for example, use `PRINT_WITH_2_NUMBERS_NOW` or `PRINT_WITH_2_NUMBERS_BIG`:
23+
24+
```sb
25+
PRINT_WITH_2_NUMBERS_BIG {key} 'HO_ONE' {num1} 5 {num2} 50 {duration} 3000 {style} 1
26+
```
27+
28+
<img src="/img/ch-04-05.png" alt="Formatted message with two numbers" />
29+
30+
## CLEO Formatting
31+
32+
CLEO supports C++-like inline formatting with placeholders that can be replaced with actual values at runtime. The syntax is similar to C++'s `printf` function. These commands have [`FORMATTED`](https://library.sannybuilder.com/#/sa/script?q=print%20formatted) in their name. For example, the following command would display the same message as above.
33+
34+
```sb
35+
PRINT_BIG_FORMATTED {format} "Horseshoes %d out of %d" {time} 3000 {style} 1 {args} 5 50
36+
```
37+
38+
You can combine native and CLEO formatting for richer visual effects:
39+
40+
```sb
41+
PRINT_BIG_FORMATTED {format} "~r~Horseshoes %d out of %d" {time} 3000 {style} 1 {args} 5 50
42+
```
43+
44+
<img
45+
src="/img/ch-04-06.png"
46+
alt="CLEO Formatted message with two numbers in red"
47+
/>

0 commit comments

Comments
 (0)