Skip to content

CLEO4 Compat Mode (.cs4)

MiranDMC edited this page Jul 19, 2025 · 25 revisions

CLEO5 introduced multiple script error checks and validation mechanisms. It prevents faulty scripts from crashing the game and in many cases provides the only way for script developers to notice non critical bugs. However these features were not available in previous CLEO versions, so some scripts created with them may contain hidden mistakes. To keep such scripts working, without showing error messages, legacy compatibility modes were introduced.

How to activate

CLEO4 compatibility mode can be enabled by renaming script's filename extension from .cs to .cs4. To enable legacy mode for main.scm modify property MainScmLegacyMode in configuration file cleo\.cleo_config.ini. All scripts spawned from script in legacy mode will inherit same mode.

Differences in CLEO4 compatibility mode

Using CLEO4 mode for script will disable warning messages about non critical problems displayed on screen and logged into file. Opcode behavior changes:

  • disabled input/output parameter type validation used in most of CLEO opcodes (providing for example float value instead of integer will not be reported)
  • disabled check for past script end code execution (lack of terminate_this_(custom)script opcode)
  • CLEO functions can not exit with return (0051) command
  • cleo_return - no warning about expected and returned argument count mismatch
  • load_audiostream and load_audiostream_with_3d_support - stream type is set to legacy type defined in SA.Audio.ini config file
  • close_file - no warning if file handle is unknown or the file has been closed already
  • get_int_from_ini_file - on file error or missing key value 0x80000000 is returned. If key exists, but contains no valid number, condition result is set to true anyway and value 0 is returned
  • get_float_from_ini_file - If key exists, but contains no valid number, condition result is set to true anyway and value 0.0 is returned
  • call_function, call_function_return, call_method and call_method_return - mismatch in declared and provided input arguments count error is not displayed, missing values are replaced with zeros. String arguments are always passed as pointers to the variable carrying them
  • call_function, call_function_return, call_method and call_method_return - does not set command logical result
  • call_method and call_method_return - allow 'struct' param to be 0 or other invalid pointer, making it behave same as call_function/call_function_return with additional setting of ECX register
  • read_string_from_file - line feed characters are included at end of returned string
  • scan_string - disables target string variables size checks, allowing buffer overruns
  • write_int_to_ini_file, write_float_to_ini_file, write_string_to_ini_file can be called with key = 0 to delete the whole section from the INI file. Recommended way instead: delete_section_from_ini_file
  • write_string_to_ini_file can be called with value = 0 to delete the key from the INI file. Recommended way instead: delete_key_from_ini_file

Differences in CLEO3 compatibility mode

  • all differences of CLEO4 mode
  • open_file and all commands working with the file streams are implemented using GTA's internal methods

Clone this wiki locally