Hands-on: Showing a Message
3 min read
Let’s write our first script. We already know all the necessary elements to get started.
Create a new CLEO script file by clicking File -> New CLEO Script....
After nop add a new line:
print_string_now "Hello, world!" 2000Your script should look like this:
{$CLEO .cs}nop
print_string_now "Hello, world!" 2000
terminate_this_scriptSave the file under any name, e.g. show_message.txt. Click Run -> Compile + Copy or press F7 to compile the script and copy it to the game folder.
If it did not work, set the path to the game folder in the settings F10.
Now click Run -> Run San Andreas or press F8 to run the game.
Start a new game or load a save. You should see a message:
Congratulations! If you are curious to know what 2000 means in print_string_now, check the documentation. It controls how long the message is displayed. The value is in milliseconds. Try changing it to 20000 and see what happens.
If you don’t see the text, check the CLEO folder in the game directory. It should contain the compiled script file with the same name as the source file (e.g. show_message.cs). If it is there but the message is still not showing, check the CLEO log file (.cleo.log) in the CLEO folder. It may contain error messages.
What’s next?
Try these modifications and recompile:
- Change the message text to something else.
- Try using
print_big_stringinstead ofprint_string_now. Note that it has an extra third parameter, which is the style of the text. You will learn more about it in the next chapter. For now, you can just set it to1to see the difference.