CLEO Help Help with my CLEO

CLEO related
Status
Not open for further replies.

Zin

Expert
Joined
Aug 1, 2013
Messages
1,734
Solutions
2
Reaction score
117
Hi I'm trying to make a cleo where I can make my game send 2 commands via one command but it crashes on load. I'm pretty shit at doing cmds but it compiled fine but it crashes on load can anyone help me out?


Code:
{$CLEO .cs}
thread 'zin'

:START
wait 0
if and
samp.Available()
0AAB:   file_exists "CLEO\zin.ini"
jf @START 
0B34: samp register_client_command "zin" to_label @TYPE


:TYPE
0AF4: 0@ = read_string_from_ini_file "CLEO\zin.ini" section "Settings" key "Message1"
0AF4: 1@ = read_string_from_ini_file "CLEO\zin.ini" section "Settings" key "Message2"
say "%d" 0@
wait 50
say "%d" 1@
samp.CmdRet()
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
937
Location
Lithuania
Check if plugin "IniFiles.cleo" is in CLEO folder maybe are missing?.
Or you need to set register of letters to "as is", in SB options...

Try this:

Code:
0AF0: 0@ = get_int_from_ini_file "cleo\config.ini" section "SectionName" key "intKey"
0AF1: write_int 16 to_ini_file "cleo\config.ini" section "SectionName" key "intKey"

Or this another but simple code:

Code:
{$CLEO .cs}
0000:
thread "Zin"
0B34: samp register_client_command "zin" to_label @cmd
0@ = 0

/// wait 5000 - 5 seconds
/// wait 0 - 0 seconds


//////

:MAIN       
wait 0
if
0@ == 1
then
wait 0  /// You can change time , now is 0 seconds. This time set to wait beafore send message.      
0AF9: samp say_msg "Message1 or Your command"
end

if
0@ == 1
then
wait 0  /// You can change time , now is 0 seconds. This time set to wait beafore send message.         
0AF9: samp say_msg "Message2 or Your command"
end

SAMP.CmdRet()
jump @MAIN       

:CMD
wait 0
if
056D:   actor $PLAYER_ACTOR defined
then
0B12: 0@ = 0@ XOR 1
if
0@ == 1
then
0ACD: show_text_highpriority "Zin: ~g~ON~w~" time 1500
else
0ACD: show_text_highpriority "Zin: ~r~OFF~w~" time 1500
end
end
SAMP.CmdRet()
jump @MAIN
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,734
Solutions
2
Reaction score
117
Yeah that code above I could do but I want to set it via ini file or even better via a cmd like /cmd1 /cmd2 but ini is fine for me.
 

not490

Well-known member
Joined
Feb 8, 2014
Messages
453
Reaction score
4
zin said:
Yeah that code above I could do but I want to set it via ini file or even better via a cmd like /cmd1 /cmd2 but ini is fine for me.

After ":TYPE" put "wait 0"
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
You need to make a while true body for your script so it wont reach that function label without preparation (just the low level shit lazy to explain), also you need to allocate memory for your strings and try not to read anything from .ini file if it's doesn't exist, so make some check on initialization I guess
Also if this code causes your game crash even with the sampfunc installed, then check if you have IniFiles.cleo and FileSystemOperations.cleo in your cleo folder, which is should be there by default when you install CLEO

[shcode=cpp]
{$CLEO}

if not 31@ = samp.Base()
then
end_thread
else
   while not samp.Available()
   wait 100
   end
end

0000:
if
   0AAB:  file_exists "CLEO\zin.ini"
   then
   else
       0AF8: samp add_message_to_chat "no file msg" 120007
       alloc 0@ 8
       format 0@ "null"
       0AF5: write_string_to_ini_file 0@ path "CLEO\zin.ini" section "Settings" key "Message1"
       0AF5: write_string_to_ini_file 0@ path "CLEO\zin.ini" section "Settings" key "Message2"
       free 0@
end

0B34: samp register_client_command "zin" to_label @_zin

while true
wait 0
end //while true

:_zin
alloc 0@ 288
alloc 1@ 288
0AF4: 0@ = read_string_from_ini_file "CLEO\zin.ini" section "Settings" key "Message1"
0AF4: 1@ = read_string_from_ini_file "CLEO\zin.ini" section "Settings" key "Message2"
say "%d" 0@
wait 50
say "%d" 1@
free 0@
free 1@
Samp.CmdRet()
[/shcode]
 
Status
Not open for further replies.
Top