0AD9

From GTAModding
Jump to: navigation, search

GTA III Vice City San Andreas (with CLEO)


Description
Writes a formatted text to the file
Syntax
0AD9: write_formatted_text "[string]" in_file [file] ( [any] ... )
Parameter
[string]
Text to write into the file (see fprintf for explanation)
[file]
The handle of the file
[any]
Any values to write (optional)

This CLEO opcode writes a formatted text to the file. In Sanny Builder it is important that you disable case converting in order for the opcode to work as expected. In "Options..." under the "Formats" tab in the "Case converting" box, select "As is". For CLEO v2.0.0.4 and below for GTA III and Vice City, this opcode crashes the game.

Example

The following example allows you to record your positions into a file every time you press button 17 (ATTACK key).

const
FILE_HANDLE = [email protected]
X_POS = [email protected]
Y_POS = [email protected]
Z_POS = [email protected]
end

0A9A: FILE_HANDLE = openfile "output" mode 0x77  // w
while true
    wait 10
    if
        00E1:   player 0 pressed_button 17  // attack key
    then
        while 00E1:   player 0 pressed_button 17  // attack key
            wait 0
        end
        0054: store_player $PLAYER_CHAR position_to X_POS Y_POS Z_POS
        0AD9: write_formatted_text "%f %f %f%c" in_file FILE_HANDLE data X_POS Y_POS Z_POS 0xA
    end
end

Keywords

write, file, format, formatted, text