CLEO Help Help read chat line and then stop reading and wait for a key press

CLEO related
Status
Not open for further replies.

Derrekgamer

Active member
Joined
Oct 26, 2020
Messages
93
Reaction score
1
Location
Grecee
Hello ug base, i hope u can help me.. Im trying this hours and hours and no succes.

Im trying to make a code that will read the chat line, lets say the word "heeey" was detected in chat line, when that word was detected the code should do this:
say that word heeey in chat, and then stop read more chat lines untill a key taste is pressed. When the key was pressed then the code should start again reading chat lines.

I tryed this and many way but not work ..

All the other things work like a charm but the script wont stop reading the chat lines.. it should to wait for the key press and then continue reading lines again.

I need this to find someone instantly when him commited a crime, and there are more people that do that.. and the mod will switch from one to another lol...

Code:
{$CLEO}

0AB1: call_scm_func @chatmsg 0


REPEAT
   WAIT 0
UNTIL 0AFA:  SAMP_IS_READY

0B34: samp register_client_command "toggle" to_label @toggle

WHILE TRUE
WAIT 0
if 30@ == 1 //if you type that command it will change variable to 1
        then
        wait 500
        if 30@ == 0
        then continue
        else
        FOR 0@ = 99 TO 99 // Can be changed to 98 to 99, 97 to 99 - it reads the last amount of lines from the log. In this case, it reads just the last one.
        0AC8: 1@ = allocate_memory_size 260
        0AC8: 2@ = allocate_memory_size 260
        if 30@ == 0
        then continue
        else
        0B75: samp get_chat_string 0@ text_to 1@ prefix_to 2@ color_to $NOT_USED prefix_color_to $NOT_USED
        If 30@ == 0
        then continue
        else
        if
        0AD4: $NOT_USED = scan_string 1@ format "{844185}DISPATCH >> {FFFFFF}%s (%d) HAS {ffcc00}COMITED A CRIME " 4@v 5@
        THEN
                wait 700
                say "/find %d" 5@
                if key_down 52
                then continue
                else
                SAMP.CmdRet()
        END
    END                                
END

END
end
end
end
end

:toggle //command
0B12: 30@ = 30@ XOR 1
if 30@ == 1
then
0AF8: samp add_message_to_chat "{46FF00}Mod on!" color 0xFFFFFF
else
0AF8: samp add_message_to_chat "{46FF00}Mod of!" color 0xFFFFFF
end
SAMP.CmdRet()[CODE]
 

Derrekgamer

Active member
Joined
Oct 26, 2020
Messages
93
Reaction score
1
Location
Grecee
I tryed also to add say msg : "/toggle" but it says unknown command lol

I tryed this :

If chat line detected
Then :
Samp say msg : "/find %d" 5@
Wait 500
Samp say msg: "/toggle" it will dezactivate the mod untill i press the key
If key press 52
Then
Samp say msg "/toggle" it will activate the mod since i pressed the key

But now working it says that command toggle unknown.. But in using it in game to set on/off the code... Any idea?
 

Derrekgamer

Active member
Joined
Oct 26, 2020
Messages
93
Reaction score
1
Location
Grecee
and why if i use this :

wait 700
say "/find %d" 5@
wait 500
say "/toggle"


it says ERROR: This command doesn't exist. Type /help! but that command its registered for turn on and off the mod.. any way to fix this?
 

blvck0v

Active member
Joined
Feb 23, 2019
Messages
98
Reaction score
51
Location
ugbase.eu
Jesus, learn tabulation man, looking at how you have if and end in this script makes my head hurt.
if 30@ == 0 is useless because the code only executes when 30@ == 1, remove all of them.
Remove wait 500 wait 700 because this delay can possibly break the chat string detection part.
Say /toggle is the same as you typing in chat the command /toggle, and because the server doesn't have that command, you get error.
After comparing the strings, use (repeat wait 0 until key down), and that should fix the waiting part.
 

Derrekgamer

Active member
Joined
Oct 26, 2020
Messages
93
Reaction score
1
Location
Grecee
Jesus, learn tabulation man, looking at how you have if and end in this script makes my head hurt.
if 30@ == 0 is useless because the code only executes when 30@ == 1, remove all of them.
Remove wait 500 wait 700 because this delay can possibly break the chat string detection part.
Say /toggle is the same as you typing in chat the command /toggle, and because the server doesn't have that command, you get error.
After comparing the strings, use (repeat wait 0 until key down), and that should fix the waiting part.


Alll the stuff it's working fine men. I just want to brake the code when it type /find %d and continue when I press a key. The same with 30=1 and 30=1,its working properly..

All the waiting deelay detect and what u said there its working
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Jesus, learn tabulation man, looking at how you have if and end in this script makes my head hurt.
if 30@ == 0 is useless because the code only executes when 30@ == 1, remove all of them.
Remove wait 500 wait 700 because this delay can possibly break the chat string detection part.
Say /toggle is the same as you typing in chat the command /toggle, and because the server doesn't have that command, you get error.
After comparing the strings, use (repeat wait 0 until key down), and that should fix the waiting part.
Congrats! for trying.
 

blvck0v

Active member
Joined
Feb 23, 2019
Messages
98
Reaction score
51
Location
ugbase.eu
Congrats! for trying.
Yea..
Alll the stuff it's working fine men. I just want to brake the code when it type /find %d and continue when I press a key. The same with 30=1 and 30=1,its working properly..

All the waiting deelay detect and what u said there its working
My bad if that works so fine as you say, and also I told you how to "break the code" when that specific chat line is detected.
 

Derrekgamer

Active member
Joined
Oct 26, 2020
Messages
93
Reaction score
1
Location
Grecee
Yea..

My bad if that works so fine as you say, and also I told you how to "break the code" when that specific chat line is detected.


I fixed it. By using 2 cleo. Cs files..

This is what I did :

Cleo1.cs
Detect chat line
Read specific text
Then
wait 500
Samp say msg "/find %d"
Wait 50
004E: STOP THIS CLEO
END

//now the code wont work anymore untill i restart it


Cleo2.cs here I put this :
if i press the S taste it will reset that Cleo1 after the command /find was ussed, ex :

If key pressed then restart "cleo1.cs

//now the cleo1 will be restarted and waiting for another chatline to read, when it finds the next chat line, it will repeat again the samp say msg and the stop cleo code.. This is the way that I found to make the code stop.. I'm sure there is more ways to do that but no one help

And it's working very well. Topic can be closed anyway
 
Last edited:

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
SIMPLE VARIABLE - TRUE / FALSE
PHP:
{$CLEO .cs}

0000:

REPEAT
   WAIT 0
UNTIL 0AFA:  SAMP_IS_READY

0B34: samp register_client_command "toggle" to_label @toggle

WHILE TRUE
WAIT 0

IF AND
31@ == TRUE
0B61:  samp is_local_player_spawned
THEN
    FOR 0@ = 99 TO 99 // Can be changed to 98 to 99, 97 to 99 - it reads the last amount of lines from the log. In this case, it reads just the last one.
        0AC8: 1@ = allocate_memory_size 1024
        0AC8: 2@ = allocate_memory_size 1024
        0B75: samp get_chat_string 0@ text_to 1@ prefix_to 2@ color_to 4@ prefix_color_to 5@
        0C28: strlwr in 1@ out 1@
        0AC8: 6@ = allocate_memory_size 1024
        0AB1: @DeleteColorCodes 2 text 1@ memory_to_store_characters_as_text 6@
        IF AND
        30@ == FALSE
        0C29: $NOT_USED = stristr string1 6@ string2 "has comited a crime"
        THEN
            0AC8: 7@ = allocate_memory_size 1024
            0AB1: @get_digits_to_print 2 text 6@ memory_to_store_digits_as_text 7@
            wait 700
            say "/find %s" 7@
            30@ = TRUE
        END
    END
 
    IF AND
    8B21:     samp not_chat_opened
    8B4C:  samp not_dialog_active -1
    0AB0: 52
    THEN 30@ = FALSE
    END                            
END

END

:toggle //command
IF 31@ == FALSE
THEN
    31@ = TRUE
    0AF8: samp add_message_to_chat "{46FF00}Mod on!" color 0xFFFFFF
ELSE
    31@ = FALSE
    0AF8: samp add_message_to_chat "{46FF00}Mod of!" color 0xFFFFFF
END
0B43: samp cmd_ret

:DeleteColorCodes
{
    0AC8: 6@ = allocate_memory_size 1024
    0AB1: @DeleteColorCodes 2 text 1@ memory_to_store_characters_as_text 6@
}
5@ = FALSE // inbracket
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 28@ == 123
        THEN 5@ = TRUE // inbracket
        END
     
        IF 5@ == FALSE
        THEN
            0A8C: write_memory 1@ size 1 value 28@ virtual_protect 1
            1@ += 1 // move to next address
        END
     
        IF 28@ == 125
        THEN 5@ = FALSE // inbracket
        END
    END
0A8C: write_memory 1@ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0


:get_digits_to_print
{
    0AC8: 6@ = allocate_memory_size 1024
    0AB1: @get_digits_to_print 2 text 1@ memory_to_store_digits_as_text 6@
}
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
 
Last edited:
Status
Not open for further replies.
Top