CLEO Help Trying to write into an ini file a variable amount of section-key pairs.

CLEO related

Radush

New member
Joined
Sep 11, 2024
Messages
1
Reaction score
0
Hi, I'm trying to write a SA:MP script that automatically saves into an .ini file every phrase written.
In my example:
  • The command [/addtext Hello, World!] should save the text "Hello, World!" in the section "phrases" with the key "phrase_1"
  • The command [/addtext Hello, Forum!] should save the text "Hello, Forum!" in the section "phrases" with the key "phrase_2"
But at the moment, the integer doesn't get replaced, and every time I use the command, the text get overwritten in the key "phrase_%d"
Can anyone give me a hint on how I could fix that?


CSS:
0B34: samp register_client_command "addtext" to_label @ADDTEXT

REPEAT
    WAIT 0
UNTIL 0AFA:

WHILE TRUE
    WAIT 0
    0B35: samp 0@ = get_last_command_params
    LOG 0@
END

:ADDTEXT
0B35: samp 0@ = get_last_command_params
0AC8: 1@ = allocate_memory_size 260
0AD3: 1@ = format "%s" 0@
0AF8: samp add_message_to_chat 1@ -1
0AF0: 2@ = get_int_from_ini_file "cleo/Phrases.ini" section "total" key "totalphrases"  //I store the amount of phrases already in the file, so I'll know which number should the next added phrase be
//0AC8: 11@ = allocate_memory_size 16
//0AD3: 11@ = format "phrase_%d" 2@
//0AF8: samp add_message_to_chat 11@ -1
0AF5: write_string 1@ to_ini_file "cleo/Phrases.ini" section "phrases" key "phrase_%d" 2@
000A: 2@ += 1
0AF1: write_int 2@ to_ini_file "cleo/Phrases.ini" section "total" key "totalphrases"
free 1@
//free 11@
SAMP.CmdRet()
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,254
Solutions
6
Reaction score
924
Location
Lithuania
If cleo still not gonna work for you...

Try using directly from windows.
 
Top