CLEO Help How to read from .ini string, can anyone help?

CLEO related
Status
Not open for further replies.

Supermacy31

Active member
Joined
Mar 13, 2013
Messages
173
Reaction score
1
This is my .ini file:

Code:
[kb]
unislimit=1000

[msgsnormal
m0= /stats
m1= /help

This is my cleo file:

Code:
{$CLEO .cs}
0000:
repeat
wait 40
until 0AFA: is_samp_structures_available


:Main
wait 0
if and
0AAB: file_exists "CLEO\kbult.ini" 
   056D: actor $PLAYER_ACTOR defined
   jf @Main

   if and 
   0AB0: key_pressed 101
   8B21: not samp is_chat_opened 
   then    
   jump @KBind
   end   
   
jump @Main

:KBind
wait 0 
0AF4: 0@v = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m0"
0AF9: samp say_msg 0@ // If I put samp say_msg 0@v it doesn't seem to fix it?
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@

jump @Main

When I go in-game and press Numpad-5 it works but the string is left out it's like John_Johnson says: 
and it's blank like that. Any ideas?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
if you copied and pasted it properly then msgsnormal lacks one bracket. Idk how it reads the string, but if by some chance it reads till the first empty space it wouldn't catch anything if you start with a space.

[kb]
unislimit=1000

[msgsnormal]
m0=/stats
m1=/help


About this part:
0AF4: 0@v = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m0"
0AF9: samp say_msg 0@ // If I put samp say_msg 0@v it doesn't seem to fix it?

springfield wrote:

0@s mean short string, you use it to store short strings(under 8bytes). It will also occupy the next variable.


0@ = 4 bytes
1@s = 8 bytes = 1@, 2@
1@v = 16 bytes = 1@, 2@, 3@, 4@

so it's better to use 0@v at 0AF9
 

Supermacy31

Active member
Joined
Mar 13, 2013
Messages
173
Reaction score
1
monday said:
if you copied and pasted it properly then msgsnormal lacks one bracket. Idk how it reads the string, but if by some chance it reads till the first empty space it wouldn't catch anything if you start with a space.

[kb]
unislimit=1000

[msgsnormal]
m0=/stats
m1=/help


About this part:
0AF4: 0@v = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m0"
0AF9: samp say_msg 0@ // If I put samp say_msg 0@v it doesn't seem to fix it?

springfield wrote:

0@s mean short string, you use it to store short strings(under 8bytes). It will also occupy the next variable.


0@ = 4 bytes
1@s = 8 bytes = 1@, 2@
1@v = 16 bytes = 1@, 2@, 3@, 4@

so it's better to use 0@v at 0AF9
OK, it took forever and like 329432948239 tries but I finally found the problem and the solution to it. You have to allocate size for the string(s) and character(s) within and it seems like it has to be done ALWAYS.

Here is a snippet of my fix:


Code:
:KBind
wait 0
0AC8: 0@ = allocate_memory_size 260
0AF4: 0@ = read_string_from_ini_file "cleo\kbult.ini" section "msgsnormal" key "m0"
0AF9: samp say_msg 0@
0AF0: 1@ = get_int_from_ini_file "cleo\kbult.ini" section "kb" key "unislimit"
wait 1@
0AC9: free_allocated_memory 1@ //Free!

jump @Main

...and it works.

Thanks for the help!

Also thanks to Opcode for his Keybinding script(s) that I looked into to gain some insights ;p

-- INI:

Code:
[kb]
unislimit=1000

[msgsnormal
m0=/stats
m1=/help
 
Status
Not open for further replies.
Top