CLEO Help CLEO - Write on text file (Opcode 0A9A?)

CLEO related
Status
Not open for further replies.

Lukahlyo

Member
Joined
Nov 11, 2018
Messages
20
Reaction score
1
Hey! So being a complete stranger to CLEO writing, I'm trying to make a .cs that writes stuff to a text file.
I've gotten to the point I know I need to operate with 0A9A, but I can't progress any further since I don't know how the syntax for it works.

What I'm trying to do is recreate the following:
Type "/ant" in chat, followed by any sort of text (X X Z).
/ant is recognized and caught on by the CLEO, not being sent to the server.
Said text (X X Z) is recognized and copied to an external text file.
When typed again (/ant X X Y), said text is also copied to the text file, but X X Z from earlier prevails. Content is now X X Z, X X Y. Any new text is added, instead of replacing older text.

Any tips on how to achieve this?
 
Last edited:

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,488
Reaction score
231
Location
( ͡° ͜ʖ ͡°)
WHILE 8A9A: 0@ = openfile "CLEO\C\C-Console.log" mode "at" // IF and SET
wait 0
END
0AD9: write_formatted_text "-Line1%c" in_file 0@ 10
0AD9: write_formatted_text "-Line2%c" in_file 0@ 10


That how you write a string to a file...
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,488
Reaction score
231
Location
( ͡° ͜ʖ ͡°)
Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY
0B34: register_client_cmd "ant" @ant



WHILE TRUE
    WAIT 0
END









:ant
0B35: samp 1@ = get_last_command_params
if
0AD4: 33@ = scan_string 1@ format "%f %f %f" 5@ 6@ 7@
then
    0AF8: samp add_message_to_chat "Values written to file: %f %f %f" color -1 5@ 6@ 7@
    8A9A: 0@ = openfile "CLEO\pos.txt" mode "at"
    0AD9: write_formatted_text "%f %f %f%c" in_file 0@ 0xA 5@ 6@ 7@
    0A9B: closefile 0@

end

0B43: samp cmd_ret
 

Lukahlyo

Member
Joined
Nov 11, 2018
Messages
20
Reaction score
1
Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY
0B34: register_client_cmd "ant" @ant



WHILE TRUE
    WAIT 0
END









:ant
0B35: samp 1@ = get_last_command_params
if
0AD4: 33@ = scan_string 1@ format "%f %f %f" 5@ 6@ 7@
then
    0AF8: samp add_message_to_chat "Values written to file: %f %f %f" color -1 5@ 6@ 7@
    8A9A: 0@ = openfile "CLEO\pos.txt" mode "at"
    0AD9: write_formatted_text "%f %f %f%c" in_file 0@ 0xA 5@ 6@ 7@
    0A9B: closefile 0@

end

0B43: samp cmd_ret
Thank you! I was able to get a similar piece working with a lot of help from someone else, but I'm taking bits and pieces from your code to make it even better.
 
Status
Not open for further replies.
Top