CLEO Help Help with Cleo

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
Hi.

I trying create auto reconnect + auto login [with ini]
First time use ini settings and i am not sure is it good configure?
@springfield
@supahdupahnubah
@0x32789

Cleo
Code:
{$CLEO .cs}
0000:

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


WHILE TRUE
    WAIT 0
    0AC8: 0@ = allocate_memory_size 260 // ALLOCATE MEMORY FOR THE CHAT STRING
    0AB1: @GETCHATENTRYTEXT 1 id 99 to 0@ // THIS IS A FUNCTION THAT STORES THE LAST CHAT STRING INTO 0@    
    IF
    0C29: 2@ = stristr string1 0@ string2 "Server closed the connection." // COMPARE STRING 0@ WITH "Server closed the connection."
    THEN
        wait 5000
        0B27: samp set_gamestate 1 
        repeat
        wait 100
        until 0B4C: samp is_dialog_active -1
        wait 500
        0AF4: 4@v = read_string_from_ini_file "CLEO\INI\Autologin.ini" section "data1" key "LoginName"
        wait 200
        0AF4: 5@v = read_string_from_ini_file "CLEO\Autologin.ini" section "data1" key "Password"
        wait 500
        0B4B: samp set_current_dialog_editbox_text 5@v
        wait 3000
        0B47: samp close_current_dialog_with_button 1
        wait 200
    END    
    0AC9: free_allocated_memory 0@ // FREE THE MEMORY
END

:getChatEntryText
0AF7: samp 1@ = get_base
1@ += 0x21A0E4
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 // size of stChatEntry
005A: 1@ += 0@ // (int)
1@ += 28
0AB2: 1 1@


INI
Code:
[data1]
LoginName=Bad_Boy
Password=33459943
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
supahdupahnubah said:
Incorrect usage of 0AF4? 0AF4: read_string_from_ini_file "cleo\config.ini" section "SectionName" key "string" store_to 0@v

What wrong here? Why dont work?

Code:
{$CLEO .cs}
0000:

REPEAT
   WAIT 0
UNTIL 0AFA:  is_samp_available

WHILE TRUE
   WAIT 0
   0AC8: 0@ = allocate_memory_size 260
   0AB1: @GETCHATENTRYTEXT 1 id 99 to 0@    
   IF
   0C29: 2@ = stristr string1 0@ string2 "Server closed the connection."
   THEN 
       wait 50
       printf "Reconnect ~r~15 seconds~b~!" time 1500
       wait 15000
       0B27: samp set_gamestate 1
       wait 200
   END    
   0AC9: free_allocated_memory 0@
END

:getChatEntryText
0AF7: samp 1@ = get_base
1@ += 0x21A0E4
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 // size of stChatEntry
005A: 1@ += 0@ // (int)
1@ += 28
0AB2: 1 1@
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
supahdupahnubah said:
use 0C14: strcmp string1 0@ string2 1@ instead of  0C29: 2@ = stristr string1 0@ string2 "Server closed the connection."

Chat find work good , but reconnect not working when 0B27: samp set_gamestate 1 is set loading loading and samp stop working....

How fix reconnect problem?
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
supahdupahnubah said:
0B28: samp disconnect_with_reason 0
0B27: samp set_gamestate 1

Still get samp stop working... o_O

Code:
{$CLEO .cs}
0000:

REPEAT
   WAIT 0
UNTIL 0AFA:  is_samp_available

WHILE TRUE
   WAIT 0
   0AC8: 0@ = allocate_memory_size 260
   0AB1: @GETCHATENTRYTEXT 1 id 99 to 0@    
   IF
   0C29: 2@ = stristr string1 0@ string2 "Server closed the connection."
   THEN
       wait 50
       printf "Reconnect ~r~15 seconds~b~!" time 1500
       wait 15000
       0B28: samp disconnect_with_reason 0
       0B27: samp set_gamestate 1
       wait 200
   END    
   0AC9: free_allocated_memory 0@
END

:getChatEntryText
0AF7: samp 1@ = get_base
1@ += 0x21A0E4
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 // size of stChatEntry
005A: 1@ += 0@ // (int)
1@ += 28
0AB2: 1 1@
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
Parazitas said:
supahdupahnubah said:
0B28: samp disconnect_with_reason 0
0B27: samp set_gamestate 1

Still get samp stop working... o_O

Aw shit, rushed for this answer, dunno where I can emulate "Server closed the connection", so delete 0B28 and try 0B27 with one of these values :

GAMESTATE_NONE = 0
GAMESTATE_WAIT_CONNECT = 1
GAMESTATE_AWAIT_JOIN = 2
GAMESTATE_CONNECTED = 3
GAMESTATE_RESTARTING = 4
GAMESTATE_DISCONNECTED = 5
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
supahdupahnubah said:
Parazitas said:
supahdupahnubah said:
0B28: samp disconnect_with_reason 0
0B27: samp set_gamestate 1

Still get samp stop working... o_O

Aw shit, rushed for this answer, dunno where I can emulate "Server closed the connection", so delete 0B28 and try 0B27 with one of these values :

GAMESTATE_NONE = 0
GAMESTATE_WAIT_CONNECT = 1
GAMESTATE_AWAIT_JOIN = 2
GAMESTATE_CONNECTED = 3
GAMESTATE_RESTARTING = 4
GAMESTATE_DISCONNECTED = 5

When samp reconnected and samp status comes to Connected samp stoped working.
Looks like when samp reconnected and comes to Connected samp login dialog not respoding, i think therefore samp stoped working....

So how fix? o_O
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
Parazitas said:
When samp reconnected and samp status comes to Connected samp stoped working.
Looks like when samp reconnected and comes to Connected samp login dialog not respoding, i think therefore samp stoped working....

So how fix? o_O

Got no idea to be honest, just tried my best :sadpepe:

@springfield
 

PlasticBottle

Active member
Joined
Jul 13, 2016
Messages
162
Reaction score
1
Try using GAMESTATE_RESTARTING, all the reconnect mods I know show "the server is restarting..." , So I assume this might work.
Try it then tell me how it went
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
273
Disconnect first.

[shcode=cpp]
0B28: samp disconnect_with_reason 500 //500 = quit
wait 1000
0B27: samp set_gamestate 1 //wait connect
wait 1000
[/shcode]
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
springfield said:
Disconnect first.

[shcode=cpp]
       0B28: samp disconnect_with_reason 500 //500 = quit
       wait 1000
       0B27: samp set_gamestate 1 //wait connect
       wait 1000
[/shcode]

Still not working .. o_O
When connected and server say joining to ..... , then samp freeze wait 30 seconds and stoped work o_O.
@springfield


Code:
{$CLEO .cs}
0000:

REPEAT
   WAIT 0
UNTIL 0AFA:  is_samp_available

WHILE TRUE
   WAIT 0
   0AC8: 0@ = allocate_memory_size 260
   0AB1: @GETCHATENTRYTEXT 1 id 99 to 0@   
   IF
   0C29: 2@ = stristr string1 0@ string2 "Server closed the connection."
   THEN
       wait 100
       0B28: samp disconnect_with_reason 500 //500 = quit
       0AF8: samp add_message_to_chat "{FF0000}[RECONNECT]:{FFF700} Reconnect after {FF0000}15 {FFF700}seconds." color 0xFFF700
       wait 15000
       0AF8: samp add_message_to_chat "{FF0000}[RECONNECT]:{FFF700} Reconnected..." color 0xFFF700
       0B27: samp set_gamestate 1 //wait connect
       wait 200
   END    
   0AC9: free_allocated_memory 0@
END

:getChatEntryText
0AF7: samp 1@ = get_base
1@ += 0x21A0E4
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 // size of stChatEntry
005A: 1@ += 0@ // (int)
1@ += 28
0AB2: 1 1@
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
Parazitas said:
Still not working .. o_O
When connected and server say joining to ..... , then samp freeze wait 30 seconds and stoped work o_O.
@springfield


Code:
{$CLEO .cs}
0000:

REPEAT
   WAIT 0
UNTIL 0AFA:  is_samp_available

WHILE TRUE
   WAIT 0
   0AC8: 0@ = allocate_memory_size 260
   0AB1: @GETCHATENTRYTEXT 1 id 99 to 0@   
   IF
   0C29: 2@ = stristr string1 0@ string2 "Server closed the connection."
   THEN
       wait 100
       0B28: samp disconnect_with_reason 500 //500 = quit
       0AF8: samp add_message_to_chat "{FF0000}[RECONNECT]:{FFF700} Reconnect after {FF0000}15 {FFF700}seconds." color 0xFFF700
       wait 15000
       0AF8: samp add_message_to_chat "{FF0000}[RECONNECT]:{FFF700} Reconnected..." color 0xFFF700
       0B27: samp set_gamestate 1 //wait connect
       wait 200
   END    
   0AC9: free_allocated_memory 0@
END

:getChatEntryText
0AF7: samp 1@ = get_base
1@ += 0x21A0E4
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 // size of stChatEntry
005A: 1@ += 0@ // (int)
1@ += 28
0AB2: 1 1@

0B28 has only 2 incoming parameters, 0 and 1, 0 goes for instaquit, 1 goes for time-out quit (about 15 seconds), then you also wait 15 seconds, so this is why it is crashes after 30 seconds or so, there seems to be no way to reconnect after you got disconnected by the server, or it is not found yet
http://blast.hk/wiki/opcodes:0b28
However I also not recommend you to allocate and free memory in such fast loops, better just allocate memory to 0@ before while true, and don't care about it anymore, since it's an infinite loop
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
273
Well, if you wait 15 seconds ofc you'll disconnect.

Do something like this
[shcode=cpp]
wait 100
0B28: samp disconnect_with_reason 500 //500 = quit
0AF8: samp add_message_to_chat "{FF0000}[RECONNECT]:{FFF700} Reconnect after {FF0000}15 {FFF700}seconds." color 0xFFF700
wait 15000
0AF8: samp add_message_to_chat "{FF0000}[RECONNECT]:{FFF700} Reconnected..." color 0xFFF700

alloc 5@ = 32
0B39: samp get_current_server_address 5@ port 6@
0B38: samp connect_to_server 5@ 6@
free 5@
wait 200
[/shcode]
 
Status
Not open for further replies.
Top