CLEO Help Problem with INI reading

CLEO related
Status
Not open for further replies.

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
I think problem is from ini reading..
Who have a lot of experience at INI and can help me?

[shcode=cpp]

{$CLEO .cs}
0000:

REPEAT
    WAIT 0
UNTIL 0AFA:  is_samp_available
// MAKE THE CLEO ONLY WORK IF SAMPFUNCS IS LOADED


while true
wait 0
if
0B4C: samp is_dialog_active -1
then
        //////////////////////////////////////////// Login Option ////////////////////////////////////////////
            if
            0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "ServerName" store_to 4@
            then
                0B3A: samp 5@ = get_current_server_name
                if
                0C14: strcmp string1 4@ string2 5@
                then
                    if
                    0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "LoginName" store_to 7@
                    then
                    0B2B: samp 6@ = get_player_id_by_actor_handle $PLAYER_ACTOR
                    0B36: samp 6@ = get_player_nickname 6@
                    if
                    0C14: strcmp string1 7@ string2 6@
                    then
                    if   
                    0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "Password" store_to 8@
                    then
                    0B4B: samp set_current_dialog_editbox_text 8@
                    0B47: samp close_current_dialog_with_button 1       
                    end
                end
             end
          end
        end   ////////  End of login option
    end
end   ////////  End ALL       



[/shcode]

INI
[shcode=cpp]

[FirstServer]
LoginName=White_God
Password=sixsword
ServerName=Savg.lt | Reikalingas 0.3.7 klientas

[/shcode]
 

mistery

Well-known member
Joined
Apr 23, 2014
Messages
262
Reaction score
5
try to check first if ini exists , then if true store content in var@
^ do this before while true
and then use strcmp
your reading method is weird.you're trying to read,check if exists and store in var, all 3 at the same time.maybe thats why it doesnt work
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
mistery said:
try to check first if ini exists , then if true store content in var@
^ do this before while true
and then use strcmp
your reading method is weird.you're trying to read,check if exists and store in var, all 3 at the same time.maybe thats why it doesnt work

I know very little about the ini, therefore my reading method is weird.
when fix this code, i can use not in one server.

You mean like that?
[shcode=cpp]

{$CLEO .cs}
0000:
 
REPEAT
    WAIT 0
UNTIL 0AFA:  is_samp_available
// MAKE THE CLEO ONLY WORK IF SAMPFUNCS IS LOADED
if
0AAB: file_exists "CLEO\INI\Autologin.ini"
then
0AF8: samp add_message_to_chat "{FFF700}[AUTO LOGIN]{FF0000} AutoLogin.ini successfully loaded..." color 0xFFF700
else
0AF8: samp add_message_to_chat "{FFF700}[AUTO LOGIN]{FF0000} AutoLogin.ini not be found in your ...\Cleo\INI folder." color 0xFFF700
end
 
while true
wait 0
if
0B4C: samp is_dialog_active -1
then
        //////////////////////////////////////////// Login Option ////////////////////////////////////////////
                0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "ServerName" store_to 4@
                0B3A: samp 5@ = get_current_server_name
                if
                0C14: strcmp string1 4@ string2 5@
                then
                    0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "LoginName" store_to 7@
                    0B2B: samp 6@ = get_player_id_by_actor_handle $PLAYER_ACTOR
                    0B36: samp 6@ = get_player_nickname 6@
                    if
                    0C14: strcmp string1 7@ string2 6@
                    then  
                    0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "Password" store_to 8@
                    0B4B: samp set_current_dialog_editbox_text 8@
                    0B47: samp close_current_dialog_with_button 1       
                    end
                end  ////////  End of login option

    end
end   ////////  End ALL 



[/shcode]
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
springfield said:
Allocate enough memory for variables when reading strings -> 4@, 5@, 7@, 8@

How much allocate memory need?
All - 4@, 5@, 7@, 8@
must be?.:

0AC8: 4@ = allocate_memory_size 260
0AC8: 5@ = allocate_memory_size 260
0AC8: 7@ = allocate_memory_size 260
0AC8: 8@ = allocate_memory_size 260


[shcode=cpp]

        //////////////////////////////////////////// Login Option ////////////////////////////////////////////
                0AC8: 4@ = allocate_memory_size 260
                0AC8: 5@ = allocate_memory_size 260
                0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "ServerName" store_to 4@
                0B3A: samp 5@ = get_current_server_name
                if
                0C14: strcmp string1 4@ string2 5@
                then
                    0AC8: 7@ = allocate_memory_size 260
                    0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "LoginName" store_to 7@
                    0B2B: samp 6@ = get_player_id_by_actor_handle $PLAYER_ACTOR
                    0B36: samp 6@ = get_player_nickname 6@
                    if
                    0C14: strcmp string1 7@ string2 6@
                    then
                    0AC8: 8@ = allocate_memory_size 260
                    0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "Password" store_to 8@
                    0B4B: samp set_current_dialog_editbox_text 8@
                    0B47: samp close_current_dialog_with_button 1       
                    end
                end  ////////  End of login option

[/shcode]
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
Parazitas said:
springfield said:
Allocate enough memory for variables when reading strings -> 4@, 5@, 7@, 8@

How much allocate memory need?
All - 4@, 5@, 7@, 8@
must be?.:

0AC8: 4@ = allocate_memory_size 260
0AC8: 5@ = allocate_memory_size 260
0AC8: 7@ = allocate_memory_size 260
0AC8: 8@ = allocate_memory_size 260

Yea but better allocate it before while true loop
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Now work good.

[shcode=cpp]

{$CLEO .cs}
0000:
 
REPEAT
   WAIT 0
UNTIL 0AFA:  is_samp_available
// MAKE THE CLEO ONLY WORK IF SAMPFUNCS IS LOADED
if
0AAB: file_exists "CLEO\INI\Autologin.ini"
then
0AF8: samp add_message_to_chat "{FFF700}[AUTO LOGIN]{FF0000} AutoLogin.ini successfully loaded..." color 0xFFF700
else
0AF8: samp add_message_to_chat "{FFF700}[AUTO LOGIN]{FF0000} AutoLogin.ini not be found in your ...\Cleo\INI folder." color 0xFFF700
end
/////////////// Memory ////////////
0AC8: 4@ = allocate_memory_size 260
0AC8: 5@ = allocate_memory_size 260
0AC8: 7@ = allocate_memory_size 260
0AC8: 8@ = allocate_memory_size 260
 
while true
wait 0
if
0B4C: samp is_dialog_active -1
then
       //////////////////////////////////////////// Login Option ////////////////////////////////////////////
               0AF4: 4@ = read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "ServerName"
               0B3A: samp 5@ = get_current_server_name
               if
               0C14: strcmp string1 4@ string2 5@
               then
                   0AF4: 7@ = read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "LoginName"
                   0B2B: samp 6@ = get_player_id_by_actor_handle $PLAYER_ACTOR
                   0B36: samp 6@ = get_player_nickname 6@
                   if
                   0C14: strcmp string1 7@ string2 6@
                   then  
                   0AF4: 8@ = read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "Password"
                   0B4B: samp set_current_dialog_editbox_text 8@
                   0B47: samp close_current_dialog_with_button 1      
                   end
               end  ////////  End of login option
   end
end   ////////  End ALL  

[/shcode]
 

mistery

Well-known member
Joined
Apr 23, 2014
Messages
262
Reaction score
5
instead of 0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "ServerName" store_to 4@
put 0AF4: 4@ = read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "ServerName"
do this for all
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
mistery said:
instead of 0AF4: read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "ServerName" store_to 4@
put  0AF4: 4@ = read_string_from_ini_file "CLEO\INI\Autologin.ini" section "FirstServer" key "ServerName"
do this for all

This work, thanks.


springfield said:
Allocate enough memory for variables when reading strings -> 4@, 5@, 7@, 8@

supahdupahnubah said:
Yea but better allocate it before while true loop

How check if already connected in to server? , I want add auto off in this auto login code.
I mean if i allready connected then this script just go to off.
 
Status
Not open for further replies.
Top