Hi, I'm trying to write a SA:MP script that automatically saves into an .ini file every phrase written.
In my example:
Can anyone give me a hint on how I could fix that?
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"
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()