CLEO Help stop cleo

CLEO related
Status
Not open for further replies.

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
When i reconnect i want the cleo script to stop, even if i am at half of executions

For example i have
Code:
0af9: samp say_msg "1"
wait 10011
0af9: samp say_msg "2"
wait 10011
0af9: samp say_msg "3"
wait 10011
0af9: samp say_msg "4"
wait 10011
0af9: samp say_msg "5"
wait 10011
0af9: samp say_msg "6"
wait 10011

If i reconnect when execute 0af9: samp say_msg "3" i want to stop the cleo, not keep running..in the moment i log in i want to run the cleo from the beginning

this is the cleo
{$CLEO .cs}

THREAD 'ExamenTP'

0662: printstring "By Zin"
0662: printstring "UGBASE.EU"
REPEAT
WAIT 0
UNTIL 0AFA:

0B34: "hacka" @EXAMEN
0B34: "killcs" @killcs

31@ = FALSE
0A92: create_custom_thread "sss.cs"

WHILE TRUE
WAIT 0
IF AND
0B61: samp is_local_player_spawned
31@ == TRUE
THEN
wait 1000
0af9: samp say_msg "/exit"
wait 1000
0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x22 {PAGE DOWN }
wait 17000
0af9: samp say_msg "/enter"
wait 2000
0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x7B {f12}
wait 10000
0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x72 {f3 tpr}
wait 5000
0C8F: samp process_chat_input "/aaa"
wait 1000
if
0B4C: samp is_dialog_active -1
then
0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x24 {apasa HOME}
wait 1000
0af9: samp say_msg "/sl"
wait 1000
0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x79 {apasa F10}
wait 1000
0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x23 {apasa END}
wait 1000
0C8F: samp process_chat_input "/abra"
wait 100
0C8F: samp process_chat_input "/abra"
wait 100
0C8F: samp process_chat_input "/abra"
wait 100
0C8F: samp process_chat_input "/abra" //aici o saseparat
wait 10000
0C8F: samp process_chat_input "/+"
wait 75000
0af9: samp say_msg "/der"
wait 100
0C8F: samp process_chat_input "/hacka"
END
31@ = FALSE
END
END

:EXAMEN
0B12: 31@ = 31@ XOR 1
If
31@ == TRUE
Then
chatmsg "ON" -1
else
chatmsg "OFF" -1
end
SAMP.CmdRet()

/// Snippet
:FAKE_KEYPRESS
if 0AA2: 2@ = load_library "User32.dll"
then
if 0AA4: 2@ = get_proc_address "keybd_event" library 2@
then
0AA5: call 2@ num_params 4 pop 0 0 0 0 0@
wait 1@
0AA5: call 2@ num_params 4 pop 0 0 0x02 0 0@
end
end
0AB2: ret 0

:killcs // cancel mod from game
SAMP.IsCommandTyped(20@)
004E: end_thread
SAMP.CmdRet()

 

dovidas147

Active member
Joined
Nov 1, 2018
Messages
32
Reaction score
2
for loop this countdown and everytime check if player is connected by using if condition with opcode:
0B23: samp is_player_connected 0@
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,690
Reaction score
103
for loop this countdown and everytime check if player is connected by using if condition with opcode:
0B23: samp is_player_connected 0@
Can you use this on yourself? Otherwise checking if gamestate is == 4 (restarting) should be fine.
0B4F: samp 0@ = get_gamestate
 

dovidas147

Active member
Joined
Nov 1, 2018
Messages
32
Reaction score
2
Can you use this on yourself? Otherwise checking if gamestate is == 4 (restarting) should be fine.
0B4F: samp 0@ = get_gamestate
I don't know actually, haven't tried cleo scripting since 2019's fall . It seems it returns local player as always disconnected no matter what. Use @Zin 's solution instead
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
@Zin and how to stop the cleo? 31@ = FALSE

also if i compile the file with 0A92: create_custom_thread "sss.cs", the code will keep loading CLEOs. If i let the game running in 1 minute i will have 1231432 cleo scripts loaded..
 

Hidend

Expert
Joined
Mar 4, 2013
Messages
625
Reaction score
39
@Zin and how to stop the cleo? 31@ = FALSE

also if i compile the file with 0A92: create_custom_thread "sss.cs", the code will keep loading CLEOs. If i let the game running in 1 minute i will have 1231432 cleo scripts loaded..
Just execute what you want while your gamemode is not restarting? Or if you want to create threads you could also end them using https://gtagmodding.com/opcode-database/opcode/0ABA/
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,690
Reaction score
103
Just stop the loop. Or you can check out this snippet.
C++:
WHILE TRUE
    WAIT 0
    
    IF
        31@ == TRUE
    THEN
        // DO STUFF
    END
    
    0B4F: samp 0@ = get_gamestate
    IF
        0@ == 4 // GAMESTATE_RESTARTING
    THEN
        WAIT 10000 // 10 sec wait to stop spam as "restarting" phase usually lasts a while and it will spam during this phase.
        0A92: RESTART "CLEO.CS" // You have to put whatever CLEO file you want to restart.
        004E: STOP THIS CLEO // Stops the current CLEO from duping.
    END   
    
END
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Code:
{$CLEO .cs}

THREAD 'ExamenTP'
            
0662: printstring "By Zin"
0662: printstring "UGBASE.EU"
REPEAT
    WAIT 0
UNTIL 0AFA:

0B34: "hacka" @EXAMEN
0B34: "killcs" @killcs

31@ = FALSE

WHILE TRUE
WAIT 0
        IF and
     31@ == TRUE
        0B61: samp is_local_player_spawned
    THEN
        wait 1000
        0af9: samp say_msg "/exit"
        wait 1000
        0C8F: samp process_chat_input "/tpfry"
        wait 17000
        0af9: samp say_msg "/enter"
        wait 3000
        0C8F: samp process_chat_input "/morii"
        wait 10000
        0C8F: samp process_chat_input "/tpbr"
        wait 5000
        0C8F: samp process_chat_input "/aaa"
        wait 1000
            if
            0B4C: samp is_dialog_active -1
            then
            0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x24 {apasa HOME}
            wait 1000
            0af9: samp say_msg "/slp"
            wait 1000
            0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x79 {apasa F10}
            wait 1000
            0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x23 {apasa END}
            wait 1000
            0C8F: samp process_chat_input "/abra" //aicat
            wait 10000
            0C8F: samp process_chat_input "/+"
            wait 75000
            0af9: samp say_msg "/dr"
            wait 100

            31@ = FALSE
            END
        END
    END
END
:EXAMEN
0B12: 31@ = 31@ XOR 1
If
31@ == TRUE
Then
chatmsg "ON" -1
else
chatmsg "OFF" -1
end
SAMP.CmdRet()

/// Snippet
:FAKE_KEYPRESS
if 0AA2: 2@ = load_library "User32.dll"
then
   if 0AA4: 2@ = get_proc_address "keybd_event" library 2@
   then
       0AA5: call 2@ num_params 4 pop 0 0 0 0 0@
       wait 1@
       0AA5: call 2@ num_params 4 pop 0 0 0x02 0 0@
   end
end
0AB2: ret 0

:killcs // cancel mod from game
SAMP.IsCommandTyped(20@)
004E: end_thread
SAMP.CmdRet()
how can i put your snippet in this script? i tried but it doesn t work
if i make another cleo like that one then it is working, but if i put inside the script isnt working

{$CLEO .cs}

THREAD 'ExamenTP'

REPEAT
WAIT 0
UNTIL 0AFA:
chatmsg "sss" -1


WHILE TRUE
WAIT 0
0B4F: samp 0@ = get_gamestate
IF
0@ == 4 // GAMESTATE_RESTARTING
THEN
WAIT 10000 // 10 sec wait to stop spam as "restarting" phase usually lasts a while and it will spam during this phase.
0C8F: samp process_chat_input "/killcs"
wait 1000
0A92: RESTART "sss.CS" // You have to put whatever CLEO file you want to restart.
// Stops the current CLEO from duping.
END
END
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,690
Reaction score
103
Code:
{$CLEO .cs}

THREAD 'ExamenTP'
           
0662: printstring "By Zin"
0662: printstring "UGBASE.EU"
REPEAT
    WAIT 0
UNTIL 0AFA:

0B34: "hacka" @EXAMEN
0B34: "killcs" @killcs

31@ = FALSE

WHILE TRUE
WAIT 0
        IF and
     31@ == TRUE
        0B61: samp is_local_player_spawned
    THEN
        wait 1000
        0af9: samp say_msg "/exit"
        wait 1000
        0C8F: samp process_chat_input "/tpfry"
        wait 17000
        0af9: samp say_msg "/enter"
        wait 3000
        0C8F: samp process_chat_input "/morii"
        wait 10000
        0C8F: samp process_chat_input "/tpbr"
        wait 5000
        0C8F: samp process_chat_input "/aaa"
        wait 1000
            if
            0B4C: samp is_dialog_active -1
            then
            0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x24 {apasa HOME}
            wait 1000
            0af9: samp say_msg "/slp"
            wait 1000
            0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x79 {apasa F10}
            wait 1000
            0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x23 {apasa END}
            wait 1000
            0C8F: samp process_chat_input "/abra" //aicat
            wait 10000
            0C8F: samp process_chat_input "/+"
            wait 75000
            0af9: samp say_msg "/dr"
            wait 100

            31@ = FALSE
            END
        END
    END
END
:EXAMEN
0B12: 31@ = 31@ XOR 1
If
31@ == TRUE
Then
chatmsg "ON" -1
else
chatmsg "OFF" -1
end
SAMP.CmdRet()

/// Snippet
:FAKE_KEYPRESS
if 0AA2: 2@ = load_library "User32.dll"
then
   if 0AA4: 2@ = get_proc_address "keybd_event" library 2@
   then
       0AA5: call 2@ num_params 4 pop 0 0 0 0 0@
       wait 1@
       0AA5: call 2@ num_params 4 pop 0 0 0x02 0 0@
   end
end
0AB2: ret 0

:killcs // cancel mod from game
SAMP.IsCommandTyped(20@)
004E: end_thread
SAMP.CmdRet()
how can i put your snippet in this script? i tried but it doesn t work
if i make another cleo like that one then it is working, but if i put inside the script isnt working

{$CLEO .cs}

THREAD 'ExamenTP'

REPEAT
WAIT 0
UNTIL 0AFA:
chatmsg "sss" -1


WHILE TRUE
WAIT 0
0B4F: samp 0@ = get_gamestate
IF
0@ == 4 // GAMESTATE_RESTARTING
THEN
WAIT 10000 // 10 sec wait to stop spam as "restarting" phase usually lasts a while and it will spam during this phase.
0C8F: samp process_chat_input "/killcs"
wait 1000
0A92: RESTART "sss.CS" // You have to put whatever CLEO file you want to restart.
// Stops the current CLEO from duping.
END
END
Depends on which bit you want it to restart.
E.g. if you put the circled bit of code where the "// DO STUFF" bit is it will restart if 31@ == TRUE and obviously if the game is restarting. I imagine you will want to just have it restart just whenever which means you could use a "custom thread" however never really experimented properly with restarting custom threads alongside actual threads.
 

Attachments

  • Untitled.png
    Untitled.png
    26.4 KB · Views: 3

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Depends on which bit you want it to restart.
E.g. if you put the circled bit of code where the "// DO STUFF" bit is it will restart if 31@ == TRUE and obviously if the game is restarting. I imagine you will want to just have it restart just whenever which means you could use a "custom thread" however never really experimented properly with restarting custom threads alongside actual threads.
Ok but when i put custom thread it will load an infinite number of CLEOs, it is not a problem?
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,690
Reaction score
103
Ok but when i put custom thread it will load an infinite number of CLEOs, it is not a problem?
That's why you put the custom thread opcode at the start of the script (where samp.available and "THREAD" and that sort of thing go) and it will only execute once. Also when you use 0A93 opcode you will need to end any other "custom threads" you have created using 0C6E opcode.
C++:
0C6A: 31@ = create_custom_thread_at_label @THREAD2 // 31@ = Pointer to custom thread

0C6E: destroy_custom_thread 31@ // Using pointer to the custom thread this opcode will end that thread.
 
Last edited:

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Code:
{$CLEO .cs}

THREAD 'ExamenTP'

0662: printstring "By Zin"
0662: printstring "UGBASE.EU"
REPEAT
WAIT 0
UNTIL 0AFA:
chatmsg "vsa" -1
0B34: samp register_client_command "+" to_label @EXAMEN
0B34: samp register_client_command "killcss" to_label @killcss
31@ = FALSE

WHILE TRUE
WAIT 0
1@ = 2262
If 31@ == TRUE
then
IF 0C5D: samp textdraw 1@ is_exists
THEN
ALLOC 0@ = 1024
0C5A: samp textdraw 1@ get_string_to 0@
0AC8: 1@ = allocate_memory_size 260
0AB1: @get_digits_to_print param_count 2 text 0@ memory_to_store_digits_as_text 1@
0B49: samp set_current_dialog_list_item 0
0B4B: samp set_current_dialog_editbox_text 1@
0B47: samp close_current_dialog_with_button 1
31@ = FALSE
end
0B4F: samp 3@ = get_gamestate
    IF
        3@ == 4 // GAMESTATE_RESTARTING
    THEN
        WAIT 7000 // 10 sec wait to stop spam as "restarting" phase usually lasts a while and it will spam during this phase.
        0A92: RESTART "hearts.cs" // You have to put whatever CLEO file you want to restart. 
        004E: STOP THIS CLEO
    end
end
end
:EXAMEN
0B12: 31@ = 31@ XOR TRUE
IF 31@ == TRUE
then
chatmsg "ON" -1
else
chatmsg "OFF" -1
end
SAMP.CmdRet()

:killcss // cancel mod from game
SAMP.IsCommandTyped(20@)
004E: end_thread
SAMP.CmdRet()

:get_digits_to_print
{
0@ = text
1@ = pointer to memory where digits will be stored as text
}
0C17: 31@ = strlen 0@
for 30@ = 0 to 31@
0085: 29@ = 0@ // copy pointer
005A: 29@ += 30@ // add offset (as the loop progresses it becomes pointers to first-last character)
0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
if and
28@ >= 0x30 // '0'
28@ <= 0x39 // '9'
then
0A8C: write_memory 1@ size 1 value 28@ virtual_protect 1
1@ += 1 // move to next address
end
end
0A8C: write_memory 1@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0
One way or another I managed to do it, but not exactly as I want. The problem is that when the server is restarting, at every restart it will add me +1 cleo mode.
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,690
Reaction score
103
Code:
{$CLEO .cs}

THREAD 'ExamenTP'

0662: printstring "By Zin"
0662: printstring "UGBASE.EU"
REPEAT
WAIT 0
UNTIL 0AFA:
chatmsg "vsa" -1
0B34: samp register_client_command "+" to_label @EXAMEN
0B34: samp register_client_command "killcss" to_label @killcss
31@ = FALSE

WHILE TRUE
WAIT 0
1@ = 2262
If 31@ == TRUE
then
IF 0C5D: samp textdraw 1@ is_exists
THEN
ALLOC 0@ = 1024
0C5A: samp textdraw 1@ get_string_to 0@
0AC8: 1@ = allocate_memory_size 260
0AB1: @get_digits_to_print param_count 2 text 0@ memory_to_store_digits_as_text 1@
0B49: samp set_current_dialog_list_item 0
0B4B: samp set_current_dialog_editbox_text 1@
0B47: samp close_current_dialog_with_button 1
31@ = FALSE
end
0B4F: samp 3@ = get_gamestate
    IF
        3@ == 4 // GAMESTATE_RESTARTING
    THEN
        WAIT 7000 // 10 sec wait to stop spam as "restarting" phase usually lasts a while and it will spam during this phase.
        0A92: RESTART "hearts.cs" // You have to put whatever CLEO file you want to restart.
        004E: STOP THIS CLEO
    end
end
end
:EXAMEN
0B12: 31@ = 31@ XOR TRUE
IF 31@ == TRUE
then
chatmsg "ON" -1
else
chatmsg "OFF" -1
end
SAMP.CmdRet()

:killcss // cancel mod from game
SAMP.IsCommandTyped(20@)
004E: end_thread
SAMP.CmdRet()

:get_digits_to_print
{
0@ = text
1@ = pointer to memory where digits will be stored as text
}
0C17: 31@ = strlen 0@
for 30@ = 0 to 31@
0085: 29@ = 0@ // copy pointer
005A: 29@ += 30@ // add offset (as the loop progresses it becomes pointers to first-last character)
0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
if and
28@ >= 0x30 // '0'
28@ <= 0x39 // '9'
then
0A8C: write_memory 1@ size 1 value 28@ virtual_protect 1
1@ += 1 // move to next address
end
end
0A8C: write_memory 1@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0
One way or another I managed to do it, but not exactly as I want. The problem is that when the server is restarting, at every restart it will add me +1 cleo mode.
Probably was something with that WAIT 7000 like it wasn't long enough or something. Just realised you can just add a repeat until game isn't restarting for the perfect wait.
C++:
0B4F: samp 3@ = get_gamestate
    IF
        3@ == 4 // GAMESTATE_RESTARTING
    THEN
        REPEAT
            WAIT 0
        UNTIL NOT 3@ == 4 // WAITS UNTIL GAME ISN'T RESTARTING.
        0A92: RESTART "hearts.cs" // You have to put whatever CLEO file you want to restart.
        004E: STOP THIS CLEO
    end
end
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Probably was something with that WAIT 7000 like it wasn't long enough or something. Just realised you can just add a repeat until game isn't restarting for the perfect wait.
C++:
0B4F: samp 3@ = get_gamestate
    IF
        3@ == 4 // GAMESTATE_RESTARTING
    THEN
        REPEAT
            WAIT 0
        UNTIL NOT 3@ == 4 // WAITS UNTIL GAME ISN'T RESTARTING.
        0A92: RESTART "hearts.cs" // You have to put whatever CLEO file you want to restart.
        004E: STOP THIS CLEO
    end
end
not working
It will add an extra script only if that cleo is activated
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,690
Reaction score
103
I tested this and I know it works.
C++:
0B4F: samp 3@ = get_gamestate
    IF
        3@ == 4 // GAMESTATE_RESTARTING
    THEN
        REPEAT
            WAIT 0
            0B4F: samp 3@ = get_gamestate
        UNTIL NOT 3@ == 4 // WAITS UNTIL GAME ISN'T RESTARTING.
        0A92: RESTART "hearts.cs" // You have to put whatever CLEO file you want to restart.
        004E: STOP THIS CLEO
    end
 

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
I tested this and I know it works.
C++:
0B4F: samp 3@ = get_gamestate
    IF
        3@ == 4 // GAMESTATE_RESTARTING
    THEN
        REPEAT
            WAIT 0
            0B4F: samp 3@ = get_gamestate
        UNTIL NOT 3@ == 4 // WAITS UNTIL GAME ISN'T RESTARTING.
        0A92: RESTART "hearts.cs" // You have to put whatever CLEO file you want to restart.
        004E: STOP THIS CLEO
    end
idk maybe is something wrong with my script but it keep adding +1 cleo every time i restart even with your last
i will leave it that way and hope that the server doesnt restart a lot
thank you!
 
Status
Not open for further replies.
Top