CLEO Help read ini data with indexed session

CLEO related
Status
Not open for further replies.

Diaboloiro_xd

Member
Joined
Feb 19, 2013
Messages
6
Reaction score
0
I'm trying to read data from an ini file through an index, but the data is not read correctly, I am doing something wrong, can someone help me?

...
:diabo_main
wait 0
if  0AAB: file_exists "cleo\test.ini"
then
    0AF0: 1@ = get_int_from_ini_file "cleo\test.ini" section "maxindex" key "max"
    for 0@ = 1 to 1@
        0AD3: 2@v = format "%s %d" "index" 0@
        0AF2: 3@ = get_float_from_ini_file "cleo\test.ini" section 2@v key "posx"
        0AF2: 4@ = get_float_from_ini_file "cleo\test.ini" section 2@v key "posy"
        0AF2: 5@ = get_float_from_ini_file "cleo\test.ini" section 2@v key "radius"
        0AF0: 6@ = get_int_from_ini_file "cleo\test.ini" section 2@v key "incar"
        0AF0: 7@ = get_int_from_ini_file "cleo\test.ini" section 2@v key "carmodel"
        if
                00EC: actor $PLAYER_ACTOR sphere 0 near_point 3@ 4@ radius 5@ 5@
        then
              printf "code running" 6000
              //...
        end
    end
end
...
Sorry my bad english.
 

alesu

Member
Joined
Apr 19, 2013
Messages
21
Reaction score
0
You need to allocate memory for the string before using 0ad3 with opcode 0ac8, and free that memory after using 0ad3 with opcode 0ac9. Also '0AD3: 2@v = format "%s %d" "index" 0@' should be '0AD3: 2@v = format "index %d" 0@'
Try this:
Code:
:diabo_main
wait 0
if  0AAB: file_exists "cleo\test.ini"
then
    0ac8: 2@ 1024
    0AF0: 1@ = get_int_from_ini_file "cleo\test.ini" section "maxindex" key "max"
    for 0@ = 1 to 1@
        0AD3: 2@ = format "index %d" 0@
        0AF2: 3@ = get_float_from_ini_file "cleo\test.ini" section 2@ key "posx"
        0AF2: 4@ = get_float_from_ini_file "cleo\test.ini" section 2@ key "posy"
        0AF2: 5@ = get_float_from_ini_file "cleo\test.ini" section 2@ key "radius"
        0AF0: 6@ = get_int_from_ini_file "cleo\test.ini" section 2@ key "incar"
        0AF0: 7@ = get_int_from_ini_file "cleo\test.ini" section 2@ key "carmodel"
        if
                00EC: actor $PLAYER_ACTOR sphere 0 near_point 3@ 4@ radius 5@ 5@
        then
              printf "code running" 6000
              //...
        end
     end
     0ac9: 2@
end
Btw, you don't need to use 2@v. You can use 2@, it will still work.
 
Status
Not open for further replies.
Top